blob: fbb5fa938efd722e669c76be1233fbafb7773f4e [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)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569}
570
571// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000572let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000573 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
574 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575
Sean Callananc0608152009-07-22 01:05:20 +0000576let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000577 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000578 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
579}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580
Owen Andersonf8053082007-11-12 07:39:39 +0000581// Indirect branches
582let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000583 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000585 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586 [(brind (loadi32 addr:$dst))]>;
Sean Callanan66fdfa02009-09-03 00:04:47 +0000587 def FARJMP16 : I<0xFF, MRM5m, (outs), (ins opaque32mem:$dst),
588 "ljmp{w}\t{*}$dst", []>, OpSize;
589 def FARJMP32 : I<0xFF, MRM5m, (outs), (ins opaque48mem:$dst),
590 "ljmp{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591}
592
593// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000594let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000595// Short conditional jumps
596def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
597def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
598def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
599def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
600def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
601def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
602def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
603def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
604def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
605def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
606def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
607def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
608def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
609def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
610def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
611def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
612
613def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
614
Dan Gohman91888f02007-07-31 20:11:57 +0000615def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000616 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000617def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000618 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000619def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000620 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000621def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000622 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000623def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000624 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000625def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000626 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627
Dan Gohman91888f02007-07-31 20:11:57 +0000628def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000629 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000630def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000631 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000632def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000633 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000634def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000635 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000636
Dan Gohman91888f02007-07-31 20:11:57 +0000637def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000638 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000639def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000640 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000641def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000642 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000643def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000644 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000645def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000646 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000647def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000648 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000649} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000650
651//===----------------------------------------------------------------------===//
652// Call Instructions...
653//
Evan Cheng37e7c752007-07-21 00:34:19 +0000654let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000655 // All calls clobber the non-callee saved registers. ESP is marked as
656 // a use to prevent stack-pointer assignments that appear immediately
657 // before calls from potentially appearing dead. Uses for argument
658 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
660 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000661 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
662 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000663 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000664 def CALLpcrel32 : Ii32<0xE8, RawFrm,
665 (outs), (ins i32imm_pcrel:$dst,variable_ops),
666 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000667 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000668 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000669 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000670 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Sean Callanan66fdfa02009-09-03 00:04:47 +0000671
672 def FARCALL16 : I<0xFF, MRM3m, (outs), (ins opaque32mem:$dst),
673 "lcall{w}\t{*}$dst", []>, OpSize;
674 def FARCALL32 : I<0xFF, MRM3m, (outs), (ins opaque48mem:$dst),
675 "lcall{l}\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 }
677
678// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000679
Evan Cheng37e7c752007-07-21 00:34:19 +0000680let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000681def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000682 "#TC_RETURN $dst $offset",
683 []>;
684
685let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000686def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000687 "#TC_RETURN $dst $offset",
688 []>;
689
690let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000691
Chris Lattner357a0ca2009-06-20 19:34:09 +0000692 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000694let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000695 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
696 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000697let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000698 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000699 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700
701//===----------------------------------------------------------------------===//
702// Miscellaneous Instructions...
703//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000704let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000706 (outs), (ins), "leave", []>;
707
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000708let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000709let mayLoad = 1 in {
710def POP16r : I<0x58, AddRegFrm, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
711 OpSize;
712def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
713def POP16rmr: I<0x8F, MRM0r, (outs GR16:$reg), (ins), "pop{w}\t$reg", []>,
714 OpSize;
715def POP16rmm: I<0x8F, MRM0m, (outs i16mem:$dst), (ins), "pop{w}\t$dst", []>,
716 OpSize;
717def POP32rmr: I<0x8F, MRM0r, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
718def POP32rmm: I<0x8F, MRM0m, (outs i32mem:$dst), (ins), "pop{l}\t$dst", []>;
719}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000721let mayStore = 1 in {
722def PUSH16r : I<0x50, AddRegFrm, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
723 OpSize;
Evan Chengd8434332007-09-26 01:29:06 +0000724def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Sean Callanan9f3c3f52009-09-10 18:29:13 +0000725def PUSH16rmr: I<0xFF, MRM6r, (outs), (ins GR16:$reg), "push{w}\t$reg",[]>,
726 OpSize;
727def PUSH16rmm: I<0xFF, MRM6m, (outs), (ins i16mem:$src), "push{w}\t$src",[]>,
728 OpSize;
729def PUSH32rmr: I<0xFF, MRM6r, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
730def PUSH32rmm: I<0xFF, MRM6m, (outs), (ins i32mem:$src), "push{l}\t$src",[]>;
731}
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000732}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000733
Bill Wendling4c2638c2009-06-15 19:39:04 +0000734let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
735def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000736 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000737def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000738 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000739def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000740 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000741}
742
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000743let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000744def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000745let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000746def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000747
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000748let isTwoAddress = 1 in // GR32 = bswap GR32
749 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000750 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
753
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754
Evan Cheng48679f42007-12-14 02:13:44 +0000755// Bit scan instructions.
756let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000757def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000758 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000759 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000760def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000761 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000762 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
763 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000764def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000765 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000766 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000767def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000768 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000769 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
770 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000771
Evan Cheng4e33de92007-12-14 18:49:43 +0000772def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000773 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000774 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000775def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000776 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000777 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
778 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000779def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000780 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000781 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000782def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000783 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000784 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
785 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000786} // Defs = [EFLAGS]
787
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000788let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000790 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000791 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000792let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000793def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000794 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000795 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
797
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000798let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000799def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000800 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000801def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000802 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000803def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000804 [(X86rep_movs i32)]>, REP;
805}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000807let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000808def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000809 [(X86rep_stos i8)]>, REP;
810let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000811def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000812 [(X86rep_stos i16)]>, REP, OpSize;
813let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000814def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000815 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816
Sean Callanan481f06d2009-09-12 00:37:19 +0000817def SCAS8 : I<0xAE, RawFrm, (outs), (ins), "scas{b}", []>;
818def SCAS16 : I<0xAF, RawFrm, (outs), (ins), "scas{w}", []>, OpSize;
819def SCAS32 : I<0xAF, RawFrm, (outs), (ins), "scas{l}", []>;
820
Sean Callanan25220d62009-09-12 02:25:20 +0000821def CMPS8 : I<0xA6, RawFrm, (outs), (ins), "cmps{b}", []>;
822def CMPS16 : I<0xA7, RawFrm, (outs), (ins), "cmps{w}", []>, OpSize;
823def CMPS32 : I<0xA7, RawFrm, (outs), (ins), "cmps{l}", []>;
824
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000825let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000826def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000827 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000829let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000830def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000831}
832
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000833def SYSCALL : I<0x05, RawFrm,
834 (outs), (ins), "syscall", []>, TB;
835def SYSRET : I<0x07, RawFrm,
836 (outs), (ins), "sysret", []>, TB;
837def SYSENTER : I<0x34, RawFrm,
838 (outs), (ins), "sysenter", []>, TB;
839def SYSEXIT : I<0x35, RawFrm,
840 (outs), (ins), "sysexit", []>, TB;
841
842
843
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844//===----------------------------------------------------------------------===//
845// Input/Output Instructions...
846//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000847let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000848def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000849 "in{b}\t{%dx, %al|%AL, %DX}", []>;
850let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000851def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000852 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
853let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000854def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000855 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000857let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000858def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000859 "in{b}\t{$port, %al|%AL, $port}", []>;
860let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000861def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000862 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
863let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000864def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000865 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000867let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000868def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000869 "out{b}\t{%al, %dx|%DX, %AL}", []>;
870let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000871def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000872 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
873let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000874def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000875 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000877let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000878def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000879 "out{b}\t{%al, $port|$port, %AL}", []>;
880let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000881def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000882 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
883let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000884def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000885 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886
887//===----------------------------------------------------------------------===//
888// Move Instructions...
889//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000890let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000891def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000892 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000893def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000894 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000895def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000896 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000897}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000898let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000899def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000900 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000902def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000903 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000905def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000906 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907 [(set GR32:$dst, imm:$src)]>;
908}
Evan Chengb783fa32007-07-19 01:14:50 +0000909def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000910 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000912def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000913 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000915def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000916 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 [(store (i32 imm:$src), addr:$dst)]>;
918
Sean Callanan70953a52009-09-10 18:33:42 +0000919def MOV8o8a : Ii8 <0xA0, RawFrm, (outs), (ins i8imm:$src),
920 "mov{b}\t{$src, %al|%al, $src}", []>;
921def MOV16o16a : Ii16 <0xA1, RawFrm, (outs), (ins i16imm:$src),
922 "mov{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
923def MOV32o32a : Ii32 <0xA1, RawFrm, (outs), (ins i32imm:$src),
924 "mov{l}\t{$src, %eax|%eax, $src}", []>;
925
926def MOV8ao8 : Ii8 <0xA2, RawFrm, (outs i8imm:$dst), (ins),
927 "mov{b}\t{%al, $dst|$dst, %al}", []>;
928def MOV16ao16 : Ii16 <0xA3, RawFrm, (outs i16imm:$dst), (ins),
929 "mov{w}\t{%ax, $dst|$dst, %ax}", []>, OpSize;
930def MOV32ao32 : Ii32 <0xA3, RawFrm, (outs i32imm:$dst), (ins),
931 "mov{l}\t{%eax, $dst|$dst, %eax}", []>;
932
Dan Gohman5574cc72008-12-03 18:15:48 +0000933let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000934def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000935 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000936 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000937def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000939 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000940def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000941 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000942 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000943}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000944
Evan Chengb783fa32007-07-19 01:14:50 +0000945def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000946 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000947 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000948def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000949 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000951def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000952 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000954
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000955// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
956// that they can be used for copying and storing h registers, which can't be
957// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000958let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000959def MOV8rr_NOREX : I<0x88, MRMDestReg,
960 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000961 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000962let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000963def MOV8mr_NOREX : I<0x88, MRMDestMem,
964 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
965 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000966let mayLoad = 1,
967 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000968def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
969 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
970 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000971
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972//===----------------------------------------------------------------------===//
973// Fixed-Register Multiplication and Division Instructions...
974//
975
976// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000977let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000978def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
980 // This probably ought to be moved to a def : Pat<> if the
981 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000982 [(set AL, (mul AL, GR8:$src)),
983 (implicit EFLAGS)]>; // AL,AH = AL*GR8
984
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000985let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000986def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
987 "mul{w}\t$src",
988 []>, OpSize; // AX,DX = AX*GR16
989
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000990let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000991def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
992 "mul{l}\t$src",
993 []>; // EAX,EDX = EAX*GR32
994
Evan Cheng55687072007-09-14 21:48:26 +0000995let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000996def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000997 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
999 // This probably ought to be moved to a def : Pat<> if the
1000 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +00001001 [(set AL, (mul AL, (loadi8 addr:$src))),
1002 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
1003
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001004let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001005let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001006def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001007 "mul{w}\t$src",
1008 []>, OpSize; // AX,DX = AX*[mem16]
1009
Evan Cheng55687072007-09-14 21:48:26 +00001010let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001011def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +00001012 "mul{l}\t$src",
1013 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001014}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001016let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001017let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001018def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
1019 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +00001020let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +00001021def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001022 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +00001023let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001024def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
1025 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001026let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +00001027let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00001028def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001029 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +00001030let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001031def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001032 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
1033let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001034def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001035 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001036}
Dan Gohmand44572d2008-11-18 21:29:14 +00001037} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001038
1039// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +00001040let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001041def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001042 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001043let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001044def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001045 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001046let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001047def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001048 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001049let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001050let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001051def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001052 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001053let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001054def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001055 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001056let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001057def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001058 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001059}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060
1061// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001062let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001063def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001064 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001065let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001066def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001067 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001068let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001069def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001070 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001071let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001072let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001073def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001074 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001075let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001076def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001077 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001078let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001079def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001080 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001081}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082
1083//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001084// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085//
1086let isTwoAddress = 1 in {
1087
1088// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001089let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001090
1091// X86 doesn't have 8-bit conditional moves. Use a customDAGSchedInserter to
1092// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1093// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001094// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1095// clobber EFLAGS, because if one of the operands is zero, the expansion
1096// could involve an xor.
1097let usesCustomDAGSchedInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001098def CMOV_GR8 : I<0, Pseudo,
1099 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1100 "#CMOV_GR8 PSEUDO!",
1101 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1102 imm:$cond, EFLAGS))]>;
1103
Dan Gohman90adb6c2009-08-27 18:16:24 +00001104let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001106 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001107 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001109 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001110 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001112 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001113 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001114 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001115 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001116 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001118 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001119 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001120 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001121 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001123def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001124 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001125 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001127 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001128 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001130 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001131 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001132 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001133 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001134 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001136 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001137 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001138 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001139 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001141def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001142 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001143 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001144 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001145 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001147def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001148 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001149 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001151 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001154 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001155 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001157 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001159def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001160 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001161 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001163 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001166 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001167 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001169 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001171def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001172 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001173 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001175 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001176 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001178 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001179 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001180 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001181 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001183def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001184 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001185 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001186 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001187 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001189def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001190 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001191 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001192 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001193 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001195def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001196 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001197 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001199 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001201def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001202 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001203 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001204 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001205 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001208 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001209 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001211 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001212 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001213def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001214 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001215 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001217 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001219def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001220 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001221 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001223 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001226 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001227 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001229 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001231def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001232 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001233 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001235 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001237def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001238 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001239 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001240 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001241 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001244 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001245 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001247 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001248 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001250 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001251 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001253 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001255def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001256 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001257 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001259 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001262 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001263 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001265 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001267def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001268 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001269 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001271 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001273def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1274 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1275 "cmovo\t{$src2, $dst|$dst, $src2}",
1276 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1277 X86_COND_O, EFLAGS))]>,
1278 TB, OpSize;
1279def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1280 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1281 "cmovo\t{$src2, $dst|$dst, $src2}",
1282 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1283 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001284 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001285def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1286 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1287 "cmovno\t{$src2, $dst|$dst, $src2}",
1288 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1289 X86_COND_NO, EFLAGS))]>,
1290 TB, OpSize;
1291def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1292 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1293 "cmovno\t{$src2, $dst|$dst, $src2}",
1294 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1295 X86_COND_NO, EFLAGS))]>,
1296 TB;
1297} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001298
1299def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1300 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1301 "cmovb\t{$src2, $dst|$dst, $src2}",
1302 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1303 X86_COND_B, EFLAGS))]>,
1304 TB, OpSize;
1305def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1306 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1307 "cmovb\t{$src2, $dst|$dst, $src2}",
1308 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1309 X86_COND_B, EFLAGS))]>,
1310 TB;
1311def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1312 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1313 "cmovae\t{$src2, $dst|$dst, $src2}",
1314 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1315 X86_COND_AE, EFLAGS))]>,
1316 TB, OpSize;
1317def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1318 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1319 "cmovae\t{$src2, $dst|$dst, $src2}",
1320 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1321 X86_COND_AE, EFLAGS))]>,
1322 TB;
1323def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1324 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1325 "cmove\t{$src2, $dst|$dst, $src2}",
1326 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1327 X86_COND_E, EFLAGS))]>,
1328 TB, OpSize;
1329def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1330 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1331 "cmove\t{$src2, $dst|$dst, $src2}",
1332 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1333 X86_COND_E, EFLAGS))]>,
1334 TB;
1335def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1336 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1337 "cmovne\t{$src2, $dst|$dst, $src2}",
1338 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1339 X86_COND_NE, EFLAGS))]>,
1340 TB, OpSize;
1341def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1342 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1343 "cmovne\t{$src2, $dst|$dst, $src2}",
1344 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1345 X86_COND_NE, EFLAGS))]>,
1346 TB;
1347def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1348 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1349 "cmovbe\t{$src2, $dst|$dst, $src2}",
1350 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1351 X86_COND_BE, EFLAGS))]>,
1352 TB, OpSize;
1353def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1354 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1355 "cmovbe\t{$src2, $dst|$dst, $src2}",
1356 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1357 X86_COND_BE, EFLAGS))]>,
1358 TB;
1359def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1360 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1361 "cmova\t{$src2, $dst|$dst, $src2}",
1362 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1363 X86_COND_A, EFLAGS))]>,
1364 TB, OpSize;
1365def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1366 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1367 "cmova\t{$src2, $dst|$dst, $src2}",
1368 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1369 X86_COND_A, EFLAGS))]>,
1370 TB;
1371def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1372 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1373 "cmovl\t{$src2, $dst|$dst, $src2}",
1374 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1375 X86_COND_L, EFLAGS))]>,
1376 TB, OpSize;
1377def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1378 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1379 "cmovl\t{$src2, $dst|$dst, $src2}",
1380 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1381 X86_COND_L, EFLAGS))]>,
1382 TB;
1383def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1384 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1385 "cmovge\t{$src2, $dst|$dst, $src2}",
1386 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1387 X86_COND_GE, EFLAGS))]>,
1388 TB, OpSize;
1389def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1390 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1391 "cmovge\t{$src2, $dst|$dst, $src2}",
1392 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1393 X86_COND_GE, EFLAGS))]>,
1394 TB;
1395def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1396 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1397 "cmovle\t{$src2, $dst|$dst, $src2}",
1398 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1399 X86_COND_LE, EFLAGS))]>,
1400 TB, OpSize;
1401def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1402 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1403 "cmovle\t{$src2, $dst|$dst, $src2}",
1404 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1405 X86_COND_LE, EFLAGS))]>,
1406 TB;
1407def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1408 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1409 "cmovg\t{$src2, $dst|$dst, $src2}",
1410 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1411 X86_COND_G, EFLAGS))]>,
1412 TB, OpSize;
1413def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1414 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1415 "cmovg\t{$src2, $dst|$dst, $src2}",
1416 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1417 X86_COND_G, EFLAGS))]>,
1418 TB;
1419def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1420 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1421 "cmovs\t{$src2, $dst|$dst, $src2}",
1422 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1423 X86_COND_S, EFLAGS))]>,
1424 TB, OpSize;
1425def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1426 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1427 "cmovs\t{$src2, $dst|$dst, $src2}",
1428 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1429 X86_COND_S, EFLAGS))]>,
1430 TB;
1431def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1432 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1433 "cmovns\t{$src2, $dst|$dst, $src2}",
1434 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1435 X86_COND_NS, EFLAGS))]>,
1436 TB, OpSize;
1437def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1438 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1439 "cmovns\t{$src2, $dst|$dst, $src2}",
1440 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1441 X86_COND_NS, EFLAGS))]>,
1442 TB;
1443def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1444 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1445 "cmovp\t{$src2, $dst|$dst, $src2}",
1446 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1447 X86_COND_P, EFLAGS))]>,
1448 TB, OpSize;
1449def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1450 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1451 "cmovp\t{$src2, $dst|$dst, $src2}",
1452 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1453 X86_COND_P, EFLAGS))]>,
1454 TB;
1455def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1456 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1457 "cmovnp\t{$src2, $dst|$dst, $src2}",
1458 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1459 X86_COND_NP, EFLAGS))]>,
1460 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001461def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1462 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1463 "cmovnp\t{$src2, $dst|$dst, $src2}",
1464 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1465 X86_COND_NP, EFLAGS))]>,
1466 TB;
1467def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1468 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1469 "cmovo\t{$src2, $dst|$dst, $src2}",
1470 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1471 X86_COND_O, EFLAGS))]>,
1472 TB, OpSize;
1473def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1474 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1475 "cmovo\t{$src2, $dst|$dst, $src2}",
1476 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1477 X86_COND_O, EFLAGS))]>,
1478 TB;
1479def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1480 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1481 "cmovno\t{$src2, $dst|$dst, $src2}",
1482 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1483 X86_COND_NO, EFLAGS))]>,
1484 TB, OpSize;
1485def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1486 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1487 "cmovno\t{$src2, $dst|$dst, $src2}",
1488 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1489 X86_COND_NO, EFLAGS))]>,
1490 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001491} // Uses = [EFLAGS]
1492
1493
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494// unary instructions
1495let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001496let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001497def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001498 [(set GR8:$dst, (ineg GR8:$src)),
1499 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001500def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001501 [(set GR16:$dst, (ineg GR16:$src)),
1502 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001503def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001504 [(set GR32:$dst, (ineg GR32:$src)),
1505 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001506let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001507 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001508 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1509 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001510 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001511 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1512 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001513 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001514 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1515 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516}
Evan Cheng55687072007-09-14 21:48:26 +00001517} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001518
Evan Chengc6cee682009-01-21 02:09:05 +00001519// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1520let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001521def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001523def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001525def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001526 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001527}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001529 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001531 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001532 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001533 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001534 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1535}
1536} // CodeSize
1537
1538// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001539let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001541def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001542 [(set GR8:$dst, (add GR8:$src, 1)),
1543 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001544let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001545def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001546 [(set GR16:$dst, (add GR16:$src, 1)),
1547 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001549def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001550 [(set GR32:$dst, (add GR32:$src, 1)),
1551 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001552}
1553let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001554 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001555 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1556 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001557 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001558 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1559 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001560 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001561 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001562 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1563 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001564 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565}
1566
1567let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001568def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001569 [(set GR8:$dst, (add GR8:$src, -1)),
1570 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001571let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001572def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001573 [(set GR16:$dst, (add GR16:$src, -1)),
1574 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001576def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001577 [(set GR32:$dst, (add GR32:$src, -1)),
1578 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001579}
1580
1581let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001582 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001583 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1584 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001585 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001586 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1587 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001588 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001589 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001590 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1591 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001592 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001593}
Evan Cheng55687072007-09-14 21:48:26 +00001594} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595
1596// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001597let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001598let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1599def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001600 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001601 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001602 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1603 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001604def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001605 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001607 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1608 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001610 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001611 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001612 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1613 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614}
1615
1616def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001617 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001618 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001619 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001620 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001621def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001622 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001623 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001624 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001625 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001626def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001627 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001629 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001630 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631
1632def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001633 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001634 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001635 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1636 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001637def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001638 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001639 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001640 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1641 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001643 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001644 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001645 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1646 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001647def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001648 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001649 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001650 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1651 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001652 OpSize;
1653def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001654 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001656 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1657 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001658
1659let isTwoAddress = 0 in {
1660 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001661 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001662 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001663 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1664 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001666 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001667 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001668 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1669 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001670 OpSize;
1671 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001672 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001673 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001674 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1675 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001676 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001677 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001678 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001679 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1680 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001681 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001682 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001684 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1685 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001686 OpSize;
1687 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001688 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001690 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1691 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001693 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001694 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001695 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1696 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697 OpSize;
1698 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001699 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001700 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001701 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1702 (implicit EFLAGS)]>;
Sean Callanan251676e2009-09-02 00:55:49 +00001703
1704 def AND8i8 : Ii8<0x24, RawFrm, (outs), (ins i8imm:$src),
1705 "and{b}\t{$src, %al|%al, $src}", []>;
1706 def AND16i16 : Ii16<0x25, RawFrm, (outs), (ins i16imm:$src),
1707 "and{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1708 def AND32i32 : Ii32<0x25, RawFrm, (outs), (ins i32imm:$src),
1709 "and{l}\t{$src, %eax|%eax, $src}", []>;
1710
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711}
1712
1713
1714let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001715def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001717 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1718 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001719def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001721 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1722 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001723def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001725 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1726 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727}
Evan Chengb783fa32007-07-19 01:14:50 +00001728def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001730 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1731 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001732def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001733 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001734 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1735 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001736def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001737 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001738 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1739 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740
Evan Chengb783fa32007-07-19 01:14:50 +00001741def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001742 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001743 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1744 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001745def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001746 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001747 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1748 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001749def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001750 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001751 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1752 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001753
Evan Chengb783fa32007-07-19 01:14:50 +00001754def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001755 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001756 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1757 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001758def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001760 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1761 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001763 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001765 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1766 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001767 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001769 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1770 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001771 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001772 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001773 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1774 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001775 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001776 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001777 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1778 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001779 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001780 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001781 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1782 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001783 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001784 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001785 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001786 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1787 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001788 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001790 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1791 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001793 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001795 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1796 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00001797
1798 def OR8i8 : Ii8 <0x0C, RawFrm, (outs), (ins i8imm:$src),
1799 "or{b}\t{$src, %al|%al, $src}", []>;
1800 def OR16i16 : Ii16 <0x0D, RawFrm, (outs), (ins i16imm:$src),
1801 "or{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1802 def OR32i32 : Ii32 <0x0D, RawFrm, (outs), (ins i32imm:$src),
1803 "or{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001804} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001805
1806
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001807let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001808 def XOR8rr : I<0x30, MRMDestReg,
1809 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1810 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001811 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1812 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001813 def XOR16rr : I<0x31, MRMDestReg,
1814 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1815 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001816 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1817 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001818 def XOR32rr : I<0x31, MRMDestReg,
1819 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1820 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001821 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1822 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001823} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824
1825def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001826 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001827 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001828 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1829 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001831 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001833 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1834 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001835 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001837 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001838 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001839 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1840 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001841
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001842def XOR8ri : Ii8<0x80, MRM6r,
1843 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1844 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001845 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1846 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001847def XOR16ri : Ii16<0x81, MRM6r,
1848 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1849 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001850 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1851 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001852def XOR32ri : Ii32<0x81, MRM6r,
1853 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1854 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001855 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1856 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001857def XOR16ri8 : Ii8<0x83, MRM6r,
1858 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1859 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001860 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1861 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001862 OpSize;
1863def XOR32ri8 : Ii8<0x83, MRM6r,
1864 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1865 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001866 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1867 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001868
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869let isTwoAddress = 0 in {
1870 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001871 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001872 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001873 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1874 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001875 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001876 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001877 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001878 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1879 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001880 OpSize;
1881 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001882 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001883 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001884 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1885 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001887 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001888 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001889 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1890 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001892 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001894 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1895 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001896 OpSize;
1897 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001898 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001900 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1901 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001903 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001905 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1906 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 OpSize;
1908 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001909 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001910 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001911 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1912 (implicit EFLAGS)]>;
Sean Callanan794457a2009-09-10 19:52:26 +00001913
1914 def XOR8i8 : Ii8 <0x34, RawFrm, (outs), (ins i8imm:$src),
1915 "xor{b}\t{$src, %al|%al, $src}", []>;
1916 def XOR16i16 : Ii16 <0x35, RawFrm, (outs), (ins i16imm:$src),
1917 "xor{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
1918 def XOR32i32 : Ii32 <0x35, RawFrm, (outs), (ins i32imm:$src),
1919 "xor{l}\t{$src, %eax|%eax, $src}", []>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001920} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001921} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001922
1923// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001924let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001925let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001926def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001927 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001928 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001929def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001930 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001931 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001932def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001933 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001934 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001935} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001936
Evan Chengb783fa32007-07-19 01:14:50 +00001937def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1940let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001941def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001942 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001944def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001945 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001946 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001947// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1948// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001949} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950
1951let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001952 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001953 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001954 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001955 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001956 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001957 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001958 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001959 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001960 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001961 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1962 }
Evan Chengb783fa32007-07-19 01:14:50 +00001963 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001964 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001965 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001966 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001967 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001968 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1969 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001970 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001971 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1973
1974 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001975 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001976 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001978 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1981 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001982 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1985}
1986
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001987let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001988def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001989 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001990 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001991def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001992 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001993 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001994def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001995 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001996 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1997}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001998
Evan Chengb783fa32007-07-19 01:14:50 +00001999def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002002def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002003 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002004 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002005def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002006 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002007 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
2008
2009// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002010def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002011 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002012 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002013def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002016def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002017 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002018 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
2019
2020let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002021 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002022 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002023 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002024 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002025 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002026 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002028 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002029 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002030 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002031 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
2032 }
Evan Chengb783fa32007-07-19 01:14:50 +00002033 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002034 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002035 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002036 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002037 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002038 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2039 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002040 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002041 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002042 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2043
2044 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002045 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002048 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002049 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002051 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2054}
2055
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002056let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002057def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002058 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002059 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002060def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002061 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002062 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002063def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002064 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002065 [(set GR32:$dst, (sra GR32:$src, CL))]>;
2066}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067
Evan Chengb783fa32007-07-19 01:14:50 +00002068def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002071def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002072 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002073 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
2074 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002075def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002076 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2078
2079// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002080def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002081 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002083def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002084 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002085 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002086def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002087 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2089
2090let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002091 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002092 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002093 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002094 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002095 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002096 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002097 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002098 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002099 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002100 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2101 }
Evan Chengb783fa32007-07-19 01:14:50 +00002102 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002103 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002105 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002106 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2108 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002109 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002110 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002111 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2112
2113 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002114 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002115 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002116 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002117 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002118 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2120 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002121 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002122 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2124}
2125
2126// Rotate instructions
2127// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002128let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002129def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002130 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002131 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002132def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002133 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002134 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002135def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002136 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002137 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2138}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139
Evan Chengb783fa32007-07-19 01:14:50 +00002140def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002141 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002142 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002143def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002144 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002145 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002146def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2149
2150// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002151def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002154def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002155 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002156 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002157def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002158 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002159 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2160
2161let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002162 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002163 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002164 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002165 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002166 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002167 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002168 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002169 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002170 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002171 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2172 }
Evan Chengb783fa32007-07-19 01:14:50 +00002173 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002174 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002175 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002176 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002177 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002178 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2179 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002180 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002181 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2183
2184 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002185 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002186 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002187 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002188 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002189 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002190 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2191 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002192 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002194 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2195}
2196
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002197let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002198def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002199 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002200 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002201def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002202 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002203 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002204def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002205 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002206 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2207}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002208
Evan Chengb783fa32007-07-19 01:14:50 +00002209def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002210 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002211 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002212def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002215def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002216 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002217 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2218
2219// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002220def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002221 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002222 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002223def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002224 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002225 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002226def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002227 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002228 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2229
2230let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002231 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002232 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002233 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002234 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002235 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002236 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002237 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002238 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002239 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002240 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2241 }
Evan Chengb783fa32007-07-19 01:14:50 +00002242 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002243 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002244 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002245 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002246 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002247 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2248 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002249 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002250 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2252
2253 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002254 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002255 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002256 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002257 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002258 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002259 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2260 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002261 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002262 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2264}
2265
2266
2267
2268// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002269let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002270def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002271 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002272 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002273def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002274 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002275 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002276def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002277 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002278 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002279 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002280def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002281 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002283 TB, OpSize;
2284}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002285
2286let isCommutable = 1 in { // These instructions commute to each other.
2287def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002288 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002289 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2291 (i8 imm:$src3)))]>,
2292 TB;
2293def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002294 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002295 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002296 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2297 (i8 imm:$src3)))]>,
2298 TB;
2299def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002300 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002301 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002302 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2303 (i8 imm:$src3)))]>,
2304 TB, OpSize;
2305def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002306 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002307 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002308 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2309 (i8 imm:$src3)))]>,
2310 TB, OpSize;
2311}
2312
2313let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002314 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002315 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002316 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002317 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002318 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002319 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002320 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002321 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002322 addr:$dst)]>, TB;
2323 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002324 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002325 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002326 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2328 (i8 imm:$src3)), addr:$dst)]>,
2329 TB;
2330 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002331 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002332 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002333 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2334 (i8 imm:$src3)), addr:$dst)]>,
2335 TB;
2336
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002337 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002338 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002339 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002340 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002341 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002342 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002343 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002344 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002345 addr:$dst)]>, TB, OpSize;
2346 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002347 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002348 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002350 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2351 (i8 imm:$src3)), addr:$dst)]>,
2352 TB, OpSize;
2353 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002354 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002355 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2357 (i8 imm:$src3)), addr:$dst)]>,
2358 TB, OpSize;
2359}
Evan Cheng55687072007-09-14 21:48:26 +00002360} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002361
2362
2363// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002364let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002365let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002366// Register-Register Addition
2367def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2368 (ins GR8 :$src1, GR8 :$src2),
2369 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002370 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002371 (implicit EFLAGS)]>;
2372
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002373let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002374// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002375def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2376 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002377 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002378 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2379 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002380def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2381 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002382 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002383 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2384 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002385} // end isConvertibleToThreeAddress
2386} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002387
2388// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002389def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2390 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002391 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002392 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2393 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002394def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2395 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002396 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002397 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2398 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002399def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2400 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002401 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002402 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2403 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002404
Bill Wendlingae034ed2008-12-12 00:56:36 +00002405// Register-Integer Addition
2406def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2407 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002408 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2409 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002410
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002411let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002412// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002413def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2414 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002415 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002416 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2417 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002418def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2419 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002420 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002421 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2422 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002423def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2424 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002425 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002426 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2427 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002428def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2429 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002430 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002431 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2432 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002433}
2434
2435let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002436 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002437 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002438 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002439 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2440 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002441 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002442 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002443 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2444 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002445 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002446 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002447 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2448 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002449 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002450 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002451 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2452 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002453 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002454 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002455 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2456 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002457 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002458 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002459 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2460 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002461 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002462 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002463 [(store (add (load addr:$dst), i16immSExt8:$src2),
2464 addr:$dst),
2465 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002466 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002467 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002468 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002469 addr:$dst),
2470 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002471
2472 // addition to rAX
2473 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002474 "add{b}\t{$src, %al|%al, $src}", []>;
Sean Callanan0316b342009-08-11 21:26:06 +00002475 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002476 "add{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
Sean Callanan0316b342009-08-11 21:26:06 +00002477 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
Sean Callanan251676e2009-09-02 00:55:49 +00002478 "add{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002479}
2480
Evan Cheng259471d2007-10-05 17:59:57 +00002481let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002482let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002483def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002484 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002485 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002486def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2487 (ins GR16:$src1, GR16:$src2),
2488 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002489 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002490def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2491 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002492 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002493 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002494}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002495def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2496 (ins GR8:$src1, i8mem:$src2),
2497 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002498 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002499def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2500 (ins GR16:$src1, i16mem:$src2),
2501 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002502 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002503 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002504def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2505 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002506 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002507 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2508def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002509 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002510 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002511def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2512 (ins GR16:$src1, i16imm:$src2),
2513 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002514 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002515def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2516 (ins GR16:$src1, i16i8imm:$src2),
2517 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002518 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2519 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002520def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2521 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002522 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002523 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002524def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2525 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002526 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002527 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002528
2529let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002530 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002531 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002532 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2533 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002534 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002535 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2536 OpSize;
2537 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002538 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002539 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2540 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002541 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002542 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2543 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002544 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002545 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2546 OpSize;
2547 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002548 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002549 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2550 OpSize;
2551 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002552 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002553 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2554 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002555 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002556 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002557
2558 def ADC8i8 : Ii8<0x14, RawFrm, (outs), (ins i8imm:$src),
2559 "adc{b}\t{$src, %al|%al, $src}", []>;
2560 def ADC16i16 : Ii16<0x15, RawFrm, (outs), (ins i16imm:$src),
2561 "adc{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2562 def ADC32i32 : Ii32<0x15, RawFrm, (outs), (ins i32imm:$src),
2563 "adc{l}\t{$src, %eax|%eax, $src}", []>;
Dale Johannesen747fe522009-06-02 03:12:52 +00002564}
Evan Cheng259471d2007-10-05 17:59:57 +00002565} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002566
Bill Wendlingae034ed2008-12-12 00:56:36 +00002567// Register-Register Subtraction
2568def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2569 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002570 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2571 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002572def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2573 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002574 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2575 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002576def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2577 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002578 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2579 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002580
2581// Register-Memory Subtraction
2582def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2583 (ins GR8 :$src1, i8mem :$src2),
2584 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002585 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2586 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002587def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2588 (ins GR16:$src1, i16mem:$src2),
2589 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002590 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2591 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002592def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2593 (ins GR32:$src1, i32mem:$src2),
2594 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002595 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2596 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002597
2598// Register-Integer Subtraction
2599def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2600 (ins GR8:$src1, i8imm:$src2),
2601 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002602 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2603 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002604def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2605 (ins GR16:$src1, i16imm:$src2),
2606 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002607 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2608 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002609def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2610 (ins GR32:$src1, i32imm:$src2),
2611 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002612 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2613 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002614def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2615 (ins GR16:$src1, i16i8imm:$src2),
2616 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002617 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2618 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002619def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2620 (ins GR32:$src1, i32i8imm:$src2),
2621 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002622 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2623 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002624
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002625let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002626 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002627 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002628 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002629 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2630 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002631 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002632 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002633 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2634 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002635 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002636 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002637 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2638 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002639
2640 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002641 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002642 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002643 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2644 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002645 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002646 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002647 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2648 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002649 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002650 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002651 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2652 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002653 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002654 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002655 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002656 addr:$dst),
2657 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002658 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002659 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002660 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002661 addr:$dst),
2662 (implicit EFLAGS)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002663
2664 def SUB8i8 : Ii8<0x2C, RawFrm, (outs), (ins i8imm:$src),
2665 "sub{b}\t{$src, %al|%al, $src}", []>;
2666 def SUB16i16 : Ii16<0x2D, RawFrm, (outs), (ins i16imm:$src),
2667 "sub{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2668 def SUB32i32 : Ii32<0x2D, RawFrm, (outs), (ins i32imm:$src),
2669 "sub{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002670}
2671
Evan Cheng259471d2007-10-05 17:59:57 +00002672let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002673def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2674 (ins GR8:$src1, GR8:$src2),
2675 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002676 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002677def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2678 (ins GR16:$src1, GR16:$src2),
2679 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002680 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002681def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2682 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002683 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002684 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002685
2686let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002687 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2688 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002689 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002690 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2691 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002692 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002693 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002694 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002695 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002696 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002697 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002698 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002699 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002700 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2701 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002702 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002703 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002704 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2705 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002706 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002707 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002708 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002709 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002710 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002711 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002712 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002713 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Sean Callanan8562bef2009-09-11 19:01:56 +00002714
2715 def SBB8i8 : Ii8<0x1C, RawFrm, (outs), (ins i8imm:$src),
2716 "sbb{b}\t{$src, %al|%al, $src}", []>;
2717 def SBB16i16 : Ii16<0x1D, RawFrm, (outs), (ins i16imm:$src),
2718 "sbb{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2719 def SBB32i32 : Ii32<0x1D, RawFrm, (outs), (ins i32imm:$src),
2720 "sbb{l}\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002721}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002722def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2723 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002724 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002725def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2726 (ins GR16:$src1, i16mem:$src2),
2727 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002728 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002729 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002730def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2731 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002732 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002733 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002734def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2735 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002736 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002737def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2738 (ins GR16:$src1, i16imm:$src2),
2739 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002740 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002741def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2742 (ins GR16:$src1, i16i8imm:$src2),
2743 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002744 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2745 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002746def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2747 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002748 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002749 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002750def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2751 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002752 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002753 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002754} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002755} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002756
Evan Cheng55687072007-09-14 21:48:26 +00002757let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002758let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002759// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002760def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002761 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002762 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2763 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002764def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002765 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002766 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2767 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002768}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002769
Bill Wendlingf5399032008-12-12 21:15:41 +00002770// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002771def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2772 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002773 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002774 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2775 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002776def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002777 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002778 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2779 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002780} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002781} // end Two Address instructions
2782
2783// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002784let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002785// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002786def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002787 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002788 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002789 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2790 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002791def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002792 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002793 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002794 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2795 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002796def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002797 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002798 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002799 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2800 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002801def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002802 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002803 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002804 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2805 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002806
Bill Wendlingf5399032008-12-12 21:15:41 +00002807// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002808def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002809 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002810 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002811 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2812 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002813def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002814 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002815 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002816 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2817 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002818def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002819 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002820 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002821 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002822 i16immSExt8:$src2)),
2823 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002824def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002825 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002826 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002827 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002828 i32immSExt8:$src2)),
2829 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002830} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002831
2832//===----------------------------------------------------------------------===//
2833// Test instructions are just like AND, except they don't generate a result.
2834//
Evan Cheng950aac02007-09-25 01:57:46 +00002835let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002836let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002837def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002838 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002839 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002840 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002841def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002842 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002843 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002844 (implicit EFLAGS)]>,
2845 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002846def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002847 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002848 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002849 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002850}
2851
Sean Callanan3e4b1a32009-09-01 18:14:18 +00002852def TEST8i8 : Ii8<0xA8, RawFrm, (outs), (ins i8imm:$src),
2853 "test{b}\t{$src, %al|%al, $src}", []>;
2854def TEST16i16 : Ii16<0xA9, RawFrm, (outs), (ins i16imm:$src),
2855 "test{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
2856def TEST32i32 : Ii32<0xA9, RawFrm, (outs), (ins i32imm:$src),
2857 "test{l}\t{$src, %eax|%eax, $src}", []>;
2858
Evan Chengb783fa32007-07-19 01:14:50 +00002859def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002860 "test{b}\t{$src2, $src1|$src1, $src2}",
2861 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2862 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002863def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002864 "test{w}\t{$src2, $src1|$src1, $src2}",
2865 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2866 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002867def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002868 "test{l}\t{$src2, $src1|$src1, $src2}",
2869 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2870 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002871
2872def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002873 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002874 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002875 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002876 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002877def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002878 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002879 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002880 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002881 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002882def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002883 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002884 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002885 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002886 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002887
Evan Cheng621216e2007-09-29 00:00:36 +00002888def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002889 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002890 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002891 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2892 (implicit EFLAGS)]>;
2893def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002894 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002895 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002896 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2897 (implicit EFLAGS)]>, OpSize;
2898def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002899 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002900 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002901 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002902 (implicit EFLAGS)]>;
2903} // Defs = [EFLAGS]
2904
2905
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002906// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002907let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002908def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002909let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002910def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002911
Evan Cheng950aac02007-09-25 01:57:46 +00002912let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002913def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002914 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002915 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002916 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002917 TB; // GR8 = ==
2918def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002919 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002920 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002921 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002922 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002923
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002924def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002925 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002926 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002927 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002928 TB; // GR8 = !=
2929def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002930 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002931 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002932 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002933 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002934
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002935def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002936 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002937 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002938 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002939 TB; // GR8 = < signed
2940def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002941 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002942 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002943 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002944 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002945
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002946def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002947 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002948 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002949 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002950 TB; // GR8 = >= signed
2951def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002952 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002953 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002954 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002955 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002956
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002957def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002958 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002959 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002960 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002961 TB; // GR8 = <= signed
2962def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002963 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002964 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002965 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002966 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002967
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002968def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002969 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002970 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002971 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002972 TB; // GR8 = > signed
2973def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002974 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002975 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002976 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002977 TB; // [mem8] = > signed
2978
2979def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002980 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002981 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002982 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002983 TB; // GR8 = < unsign
2984def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002985 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002986 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002987 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002988 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002989
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002990def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002991 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002992 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002993 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002994 TB; // GR8 = >= unsign
2995def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002996 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002997 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002998 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002999 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003000
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003001def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003002 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003003 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003004 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003005 TB; // GR8 = <= unsign
3006def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003007 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003008 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003009 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003010 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003011
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003012def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003013 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003014 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003015 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003016 TB; // GR8 = > signed
3017def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003018 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003019 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003020 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003021 TB; // [mem8] = > signed
3022
3023def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003024 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003025 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003026 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003027 TB; // GR8 = <sign bit>
3028def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003029 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003030 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003031 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003032 TB; // [mem8] = <sign bit>
3033def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003034 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003035 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003036 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003037 TB; // GR8 = !<sign bit>
3038def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003039 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003040 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003041 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003042 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003043
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003044def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003045 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003046 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003047 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003048 TB; // GR8 = parity
3049def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003050 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003051 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003052 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003053 TB; // [mem8] = parity
3054def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00003055 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003056 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003057 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003058 TB; // GR8 = not parity
3059def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00003060 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00003061 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00003062 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003063 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00003064
3065def SETOr : I<0x90, MRM0r,
3066 (outs GR8 :$dst), (ins),
3067 "seto\t$dst",
3068 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
3069 TB; // GR8 = overflow
3070def SETOm : I<0x90, MRM0m,
3071 (outs), (ins i8mem:$dst),
3072 "seto\t$dst",
3073 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
3074 TB; // [mem8] = overflow
3075def SETNOr : I<0x91, MRM0r,
3076 (outs GR8 :$dst), (ins),
3077 "setno\t$dst",
3078 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
3079 TB; // GR8 = not overflow
3080def SETNOm : I<0x91, MRM0m,
3081 (outs), (ins i8mem:$dst),
3082 "setno\t$dst",
3083 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
3084 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00003085} // Uses = [EFLAGS]
3086
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003087
3088// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00003089let Defs = [EFLAGS] in {
Sean Callanan251676e2009-09-02 00:55:49 +00003090def CMP8i8 : Ii8<0x3C, RawFrm, (outs), (ins i8imm:$src),
3091 "cmp{b}\t{$src, %al|%al, $src}", []>;
3092def CMP16i16 : Ii16<0x3D, RawFrm, (outs), (ins i16imm:$src),
3093 "cmp{w}\t{$src, %ax|%ax, $src}", []>, OpSize;
3094def CMP32i32 : Ii32<0x3D, RawFrm, (outs), (ins i32imm:$src),
3095 "cmp{l}\t{$src, %eax|%eax, $src}", []>;
3096
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003097def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003098 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003099 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003100 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003101def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003102 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003103 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003104 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003105def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00003106 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003107 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003108 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003110 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003111 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003112 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3113 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003114def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003115 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003116 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003117 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3118 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003119def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003120 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003121 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003122 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3123 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003124def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003125 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003126 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003127 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3128 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003129def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003130 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003131 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003132 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3133 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003134def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003135 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003136 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003137 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3138 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003139def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003140 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003141 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003142 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003143def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003144 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003145 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003146 [(X86cmp GR16:$src1, imm:$src2),
3147 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003148def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003149 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003150 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003151 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003152def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003153 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003154 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003155 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3156 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003157def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003158 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003159 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003160 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3161 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003162def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003163 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003164 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003165 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3166 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003167def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003168 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003169 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003170 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3171 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003172def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003173 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003174 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003175 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3176 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003177def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003178 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003179 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003180 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3181 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003182def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003183 (outs), (ins GR32:$src1, i32i8imm:$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, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003186 (implicit EFLAGS)]>;
3187} // Defs = [EFLAGS]
3188
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003189// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003190// TODO: BTC, BTR, and BTS
3191let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003192def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003193 "bt{w}\t{$src2, $src1|$src1, $src2}",
3194 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003195 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003196def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003197 "bt{l}\t{$src2, $src1|$src1, $src2}",
3198 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003199 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003200
3201// Unlike with the register+register form, the memory+register form of the
3202// bt instruction does not ignore the high bits of the index. From ISel's
3203// perspective, this is pretty bizarre. Disable these instructions for now.
3204//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3205// "bt{w}\t{$src2, $src1|$src1, $src2}",
3206// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3207// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3208//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3209// "bt{l}\t{$src2, $src1|$src1, $src2}",
3210// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3211// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003212
3213def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3214 "bt{w}\t{$src2, $src1|$src1, $src2}",
3215 [(X86bt GR16:$src1, i16immSExt8:$src2),
3216 (implicit EFLAGS)]>, OpSize, TB;
3217def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3218 "bt{l}\t{$src2, $src1|$src1, $src2}",
3219 [(X86bt GR32:$src1, i32immSExt8:$src2),
3220 (implicit EFLAGS)]>, TB;
3221// Note that these instructions don't need FastBTMem because that
3222// only applies when the other operand is in a register. When it's
3223// an immediate, bt is still fast.
3224def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3225 "bt{w}\t{$src2, $src1|$src1, $src2}",
3226 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3227 (implicit EFLAGS)]>, OpSize, TB;
3228def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3229 "bt{l}\t{$src2, $src1|$src1, $src2}",
3230 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3231 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003232} // Defs = [EFLAGS]
3233
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003234// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003235// Use movsbl intead of movsbw; we don't care about the high 16 bits
3236// of the register here. This has a smaller encoding and avoids a
3237// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003238def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003239 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3240 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003241def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003242 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3243 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003244def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003245 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003246 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003247def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003248 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003249 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003250def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003251 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003252 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003253def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003254 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003255 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3256
Dan Gohman9203ab42008-07-30 18:09:17 +00003257// Use movzbl intead of movzbw; we don't care about the high 16 bits
3258// of the register here. This has a smaller encoding and avoids a
3259// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003260def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003261 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3262 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003263def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003264 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3265 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003266def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003267 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003268 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003269def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003270 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003271 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003272def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003273 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003274 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003275def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003276 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003277 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3278
Dan Gohman744d4622009-04-13 16:09:41 +00003279// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3280// except that they use GR32_NOREX for the output operand register class
3281// instead of GR32. This allows them to operate on h registers on x86-64.
3282def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3283 (outs GR32_NOREX:$dst), (ins GR8:$src),
3284 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3285 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003286let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003287def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3288 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3289 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3290 []>, TB;
3291
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003292let neverHasSideEffects = 1 in {
3293 let Defs = [AX], Uses = [AL] in
3294 def CBW : I<0x98, RawFrm, (outs), (ins),
3295 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3296 let Defs = [EAX], Uses = [AX] in
3297 def CWDE : I<0x98, RawFrm, (outs), (ins),
3298 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003299
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003300 let Defs = [AX,DX], Uses = [AX] in
3301 def CWD : I<0x99, RawFrm, (outs), (ins),
3302 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3303 let Defs = [EAX,EDX], Uses = [EAX] in
3304 def CDQ : I<0x99, RawFrm, (outs), (ins),
3305 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3306}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003307
3308//===----------------------------------------------------------------------===//
3309// Alias Instructions
3310//===----------------------------------------------------------------------===//
3311
3312// Alias instructions that map movr0 to xor.
3313// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003314let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3315 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003316def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003317 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003318 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003319// Use xorl instead of xorw since we don't care about the high 16 bits,
3320// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003321def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003322 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3323 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003324def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003325 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003326 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003327}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003328
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003329//===----------------------------------------------------------------------===//
3330// Thread Local Storage Instructions
3331//
3332
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003333// All calls clobber the non-callee saved registers. ESP is marked as
3334// a use to prevent stack-pointer assignments that appear immediately
3335// before calls from potentially appearing dead.
3336let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3337 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3338 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3339 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003340 Uses = [ESP] in
3341def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3342 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003343 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003344 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003345 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003346
Daniel Dunbar75a07302009-08-11 22:24:40 +00003347let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003348def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3349 "movl\t%gs:$src, $dst",
3350 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3351
Daniel Dunbar75a07302009-08-11 22:24:40 +00003352let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003353def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3354 "movl\t%fs:$src, $dst",
3355 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3356
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003357//===----------------------------------------------------------------------===//
3358// DWARF Pseudo Instructions
3359//
3360
Evan Chengb783fa32007-07-19 01:14:50 +00003361def DWARF_LOC : I<0, Pseudo, (outs),
3362 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Chris Lattner64b54552009-07-10 22:34:11 +00003363 ".loc\t$file $line $col",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003364 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3365 (i32 imm:$file))]>;
3366
3367//===----------------------------------------------------------------------===//
3368// EH Pseudo Instructions
3369//
3370let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003371 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003372def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003373 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003374 [(X86ehret GR32:$addr)]>;
3375
3376}
3377
3378//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003379// Atomic support
3380//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003381
Evan Cheng3e171562008-04-19 01:20:30 +00003382// Atomic swap. These are just normal xchg instructions. But since a memory
3383// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003384let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003385def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3386 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3387 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3388def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3389 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3390 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3391 OpSize;
3392def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3393 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3394 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3395}
3396
Evan Chengd49dbb82008-04-18 20:55:36 +00003397// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003398let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003399def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003400 "lock\n\t"
3401 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003402 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003403}
Dale Johannesenf160d802008-10-02 18:53:47 +00003404let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003405def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003406 "lock\n\t"
3407 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003408 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3409}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003410
3411let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003412def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003413 "lock\n\t"
3414 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003415 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003416}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003417let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003418def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003419 "lock\n\t"
3420 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003421 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003422}
3423
Evan Chengd49dbb82008-04-18 20:55:36 +00003424// Atomic exchange and add
3425let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3426def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003427 "lock\n\t"
3428 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003429 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003430 TB, LOCK;
3431def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003432 "lock\n\t"
3433 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003434 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003435 TB, OpSize, LOCK;
3436def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003437 "lock\n\t"
3438 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003439 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003440 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003441}
3442
Evan Chengb723fb52009-07-30 08:33:02 +00003443// Optimized codegen when the non-memory output is not used.
3444// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3445def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3446 "lock\n\t"
3447 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3448def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3449 "lock\n\t"
3450 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3451def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3452 "lock\n\t"
3453 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3454def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3455 "lock\n\t"
3456 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3457def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3458 "lock\n\t"
3459 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3460def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3461 "lock\n\t"
3462 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3463def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3464 "lock\n\t"
3465 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3466def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3467 "lock\n\t"
3468 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3469
3470def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3471 "lock\n\t"
3472 "inc{b}\t$dst", []>, LOCK;
3473def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3474 "lock\n\t"
3475 "inc{w}\t$dst", []>, OpSize, LOCK;
3476def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3477 "lock\n\t"
3478 "inc{l}\t$dst", []>, LOCK;
3479
3480def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3481 "lock\n\t"
3482 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3483def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3484 "lock\n\t"
3485 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3486def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3487 "lock\n\t"
3488 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3489def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3490 "lock\n\t"
3491 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3492def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3493 "lock\n\t"
3494 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3495def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3496 "lock\n\t"
3497 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3498def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3499 "lock\n\t"
3500 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3501def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3502 "lock\n\t"
3503 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3504
3505def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3506 "lock\n\t"
3507 "dec{b}\t$dst", []>, LOCK;
3508def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3509 "lock\n\t"
3510 "dec{w}\t$dst", []>, OpSize, LOCK;
3511def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3512 "lock\n\t"
3513 "dec{l}\t$dst", []>, LOCK;
3514
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003515// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003516let Constraints = "$val = $dst", Defs = [EFLAGS],
3517 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003518def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003519 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003520 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003521def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003522 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003523 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003524def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003525 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003526 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003527def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003528 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003529 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003530def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003531 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003532 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003533def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003534 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003535 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003536def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003537 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003538 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003539def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003540 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003541 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003542
3543def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003544 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003545 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003546def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003547 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003548 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003549def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003550 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003551 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003552def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003553 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003554 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003555def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003556 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003557 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003558def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003559 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003560 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003561def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003562 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003563 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003564def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003565 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003566 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003567
3568def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003569 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003570 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003571def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003572 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003573 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003574def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003575 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003576 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003577def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003578 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003579 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003580}
3581
Dale Johannesenf160d802008-10-02 18:53:47 +00003582let Constraints = "$val1 = $dst1, $val2 = $dst2",
3583 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3584 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003585 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003586 usesCustomDAGSchedInserter = 1 in {
3587def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3588 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003589 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003590def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3591 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003592 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003593def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3594 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003595 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003596def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3597 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003598 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003599def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3600 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003601 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003602def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3603 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003604 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003605def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3606 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003607 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003608}
3609
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003610//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003611// Non-Instruction Patterns
3612//===----------------------------------------------------------------------===//
3613
Bill Wendlingfef06052008-09-16 21:48:12 +00003614// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003615def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3616def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003617def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003618def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3619def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3620
3621def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3622 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3623def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3624 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3625def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3626 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3627def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3628 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3629
3630def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3631 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3632def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3633 (MOV32mi addr:$dst, texternalsym:$src)>;
3634
3635// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003636// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003637def : Pat<(X86tcret GR32:$dst, imm:$off),
3638 (TCRETURNri GR32:$dst, imm:$off)>;
3639
3640def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3641 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3642
3643def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3644 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003645
Dan Gohmance5dbff2009-08-02 16:10:01 +00003646// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003647def : Pat<(X86call (i32 tglobaladdr:$dst)),
3648 (CALLpcrel32 tglobaladdr:$dst)>;
3649def : Pat<(X86call (i32 texternalsym:$dst)),
3650 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003651def : Pat<(X86call (i32 imm:$dst)),
3652 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003653
3654// X86 specific add which produces a flag.
3655def : Pat<(addc GR32:$src1, GR32:$src2),
3656 (ADD32rr GR32:$src1, GR32:$src2)>;
3657def : Pat<(addc GR32:$src1, (load addr:$src2)),
3658 (ADD32rm GR32:$src1, addr:$src2)>;
3659def : Pat<(addc GR32:$src1, imm:$src2),
3660 (ADD32ri GR32:$src1, imm:$src2)>;
3661def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3662 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3663
3664def : Pat<(subc GR32:$src1, GR32:$src2),
3665 (SUB32rr GR32:$src1, GR32:$src2)>;
3666def : Pat<(subc GR32:$src1, (load addr:$src2)),
3667 (SUB32rm GR32:$src1, addr:$src2)>;
3668def : Pat<(subc GR32:$src1, imm:$src2),
3669 (SUB32ri GR32:$src1, imm:$src2)>;
3670def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3671 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3672
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003673// Comparisons.
3674
3675// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003676def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003677 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003678def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003679 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003680def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003681 (TEST32rr GR32:$src1, GR32:$src1)>;
3682
Dan Gohman0a3c5222009-01-07 01:00:24 +00003683// Conditional moves with folded loads with operands swapped and conditions
3684// inverted.
3685def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3686 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3687def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3688 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3689def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3690 (CMOVB16rm GR16:$src2, addr:$src1)>;
3691def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3692 (CMOVB32rm GR32:$src2, addr:$src1)>;
3693def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3694 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3695def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3696 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3697def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3698 (CMOVE16rm GR16:$src2, addr:$src1)>;
3699def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3700 (CMOVE32rm GR32:$src2, addr:$src1)>;
3701def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3702 (CMOVA16rm GR16:$src2, addr:$src1)>;
3703def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3704 (CMOVA32rm GR32:$src2, addr:$src1)>;
3705def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3706 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3707def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3708 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3709def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3710 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3711def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3712 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3713def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3714 (CMOVL16rm GR16:$src2, addr:$src1)>;
3715def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3716 (CMOVL32rm GR32:$src2, addr:$src1)>;
3717def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3718 (CMOVG16rm GR16:$src2, addr:$src1)>;
3719def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3720 (CMOVG32rm GR32:$src2, addr:$src1)>;
3721def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3722 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3723def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3724 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3725def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3726 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3727def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3728 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3729def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3730 (CMOVP16rm GR16:$src2, addr:$src1)>;
3731def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3732 (CMOVP32rm GR32:$src2, addr:$src1)>;
3733def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3734 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3735def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3736 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3737def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3738 (CMOVS16rm GR16:$src2, addr:$src1)>;
3739def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3740 (CMOVS32rm GR32:$src2, addr:$src1)>;
3741def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3742 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3743def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3744 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3745def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3746 (CMOVO16rm GR16:$src2, addr:$src1)>;
3747def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3748 (CMOVO32rm GR32:$src2, addr:$src1)>;
3749
Duncan Sands082524c2008-01-23 20:39:46 +00003750// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003751def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3752def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3753def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3754
3755// extload bool -> extload byte
3756def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003757def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003758def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003759def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003760def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3761def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3762
Dan Gohman9959b052009-08-26 14:59:13 +00003763// anyext. Define these to do an explicit zero-extend to
3764// avoid partial-register updates.
3765def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3766def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3767def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003768
Evan Chengf2abee72007-12-13 00:43:27 +00003769// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003770def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3771 (MOVZX32rm8 addr:$src)>;
3772def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3773 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003774
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003775//===----------------------------------------------------------------------===//
3776// Some peepholes
3777//===----------------------------------------------------------------------===//
3778
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003779// Odd encoding trick: -128 fits into an 8-bit immediate field while
3780// +128 doesn't, so in this special case use a sub instead of an add.
3781def : Pat<(add GR16:$src1, 128),
3782 (SUB16ri8 GR16:$src1, -128)>;
3783def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3784 (SUB16mi8 addr:$dst, -128)>;
3785def : Pat<(add GR32:$src1, 128),
3786 (SUB32ri8 GR32:$src1, -128)>;
3787def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3788 (SUB32mi8 addr:$dst, -128)>;
3789
Dan Gohman9203ab42008-07-30 18:09:17 +00003790// r & (2^16-1) ==> movz
3791def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003792 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003793// r & (2^8-1) ==> movz
3794def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003795 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003796 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003797 Requires<[In32BitMode]>;
3798// r & (2^8-1) ==> movz
3799def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003800 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003801 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003802 Requires<[In32BitMode]>;
3803
3804// sext_inreg patterns
3805def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003806 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003807def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003808 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003809 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003810 Requires<[In32BitMode]>;
3811def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003812 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003813 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003814 Requires<[In32BitMode]>;
3815
3816// trunc patterns
3817def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003818 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003819def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003820 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003821 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003822 Requires<[In32BitMode]>;
3823def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003824 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003825 x86_subreg_8bit)>,
3826 Requires<[In32BitMode]>;
3827
3828// h-register tricks
3829def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003830 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003831 x86_subreg_8bit_hi)>,
3832 Requires<[In32BitMode]>;
3833def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003834 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003835 x86_subreg_8bit_hi)>,
3836 Requires<[In32BitMode]>;
3837def : Pat<(srl_su GR16:$src, (i8 8)),
3838 (EXTRACT_SUBREG
3839 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003840 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003841 x86_subreg_8bit_hi)),
3842 x86_subreg_16bit)>,
3843 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003844def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3845 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3846 x86_subreg_8bit_hi))>,
3847 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00003848def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
3849 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3850 x86_subreg_8bit_hi))>,
3851 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003852def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003853 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003854 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003855 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003856
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003857// (shl x, 1) ==> (add x, x)
3858def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3859def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3860def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3861
Evan Cheng76a64c72008-08-30 02:03:58 +00003862// (shl x (and y, 31)) ==> (shl x, y)
3863def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3864 (SHL8rCL GR8:$src1)>;
3865def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3866 (SHL16rCL GR16:$src1)>;
3867def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3868 (SHL32rCL GR32:$src1)>;
3869def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3870 (SHL8mCL addr:$dst)>;
3871def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3872 (SHL16mCL addr:$dst)>;
3873def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3874 (SHL32mCL addr:$dst)>;
3875
3876def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3877 (SHR8rCL GR8:$src1)>;
3878def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3879 (SHR16rCL GR16:$src1)>;
3880def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3881 (SHR32rCL GR32:$src1)>;
3882def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3883 (SHR8mCL addr:$dst)>;
3884def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3885 (SHR16mCL addr:$dst)>;
3886def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3887 (SHR32mCL addr:$dst)>;
3888
3889def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3890 (SAR8rCL GR8:$src1)>;
3891def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3892 (SAR16rCL GR16:$src1)>;
3893def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3894 (SAR32rCL GR32:$src1)>;
3895def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3896 (SAR8mCL addr:$dst)>;
3897def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3898 (SAR16mCL addr:$dst)>;
3899def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3900 (SAR32mCL addr:$dst)>;
3901
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003902// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3903def : Pat<(or (srl GR32:$src1, CL:$amt),
3904 (shl GR32:$src2, (sub 32, CL:$amt))),
3905 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3906
3907def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3908 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3909 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3910
Dan Gohman921581d2008-10-17 01:23:35 +00003911def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3912 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3913 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3914
3915def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3916 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3917 addr:$dst),
3918 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3919
3920def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3921 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3922
3923def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3924 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3925 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3926
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003927// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3928def : Pat<(or (shl GR32:$src1, CL:$amt),
3929 (srl GR32:$src2, (sub 32, CL:$amt))),
3930 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3931
3932def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3933 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3934 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3935
Dan Gohman921581d2008-10-17 01:23:35 +00003936def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3937 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3938 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3939
3940def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3941 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3942 addr:$dst),
3943 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3944
3945def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3946 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3947
3948def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3949 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3950 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3951
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003952// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3953def : Pat<(or (srl GR16:$src1, CL:$amt),
3954 (shl GR16:$src2, (sub 16, CL:$amt))),
3955 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3956
3957def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3958 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3959 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3960
Dan Gohman921581d2008-10-17 01:23:35 +00003961def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3962 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3963 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3964
3965def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3966 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3967 addr:$dst),
3968 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3969
3970def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3971 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3972
3973def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3974 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3975 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3976
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003977// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3978def : Pat<(or (shl GR16:$src1, CL:$amt),
3979 (srl GR16:$src2, (sub 16, CL:$amt))),
3980 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3981
3982def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3983 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3984 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3985
Dan Gohman921581d2008-10-17 01:23:35 +00003986def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3987 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3988 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3989
3990def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3991 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3992 addr:$dst),
3993 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3994
3995def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3996 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3997
3998def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3999 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
4000 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
4001
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004002//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00004003// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00004004//===----------------------------------------------------------------------===//
4005
Dan Gohman99a12192009-03-04 19:44:21 +00004006// Register-Register Addition with EFLAGS result
4007def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004008 (implicit EFLAGS)),
4009 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004010def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004011 (implicit EFLAGS)),
4012 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004013def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004014 (implicit EFLAGS)),
4015 (ADD32rr GR32:$src1, GR32:$src2)>;
4016
Dan Gohman99a12192009-03-04 19:44:21 +00004017// Register-Memory Addition with EFLAGS result
4018def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004019 (implicit EFLAGS)),
4020 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004021def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004022 (implicit EFLAGS)),
4023 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004024def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004025 (implicit EFLAGS)),
4026 (ADD32rm GR32:$src1, addr:$src2)>;
4027
Dan Gohman99a12192009-03-04 19:44:21 +00004028// Register-Integer Addition with EFLAGS result
4029def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004030 (implicit EFLAGS)),
4031 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004032def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004033 (implicit EFLAGS)),
4034 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004035def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004036 (implicit EFLAGS)),
4037 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004038def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004039 (implicit EFLAGS)),
4040 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004041def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004042 (implicit EFLAGS)),
4043 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
4044
Dan Gohman99a12192009-03-04 19:44:21 +00004045// Memory-Register Addition with EFLAGS result
4046def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004047 addr:$dst),
4048 (implicit EFLAGS)),
4049 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004050def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004051 addr:$dst),
4052 (implicit EFLAGS)),
4053 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004054def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004055 addr:$dst),
4056 (implicit EFLAGS)),
4057 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00004058
4059// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00004060def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004061 addr:$dst),
4062 (implicit EFLAGS)),
4063 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004064def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004065 addr:$dst),
4066 (implicit EFLAGS)),
4067 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004068def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004069 addr:$dst),
4070 (implicit EFLAGS)),
4071 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004072def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004073 addr:$dst),
4074 (implicit EFLAGS)),
4075 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004076def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004077 addr:$dst),
4078 (implicit EFLAGS)),
4079 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
4080
Dan Gohman99a12192009-03-04 19:44:21 +00004081// Register-Register Subtraction with EFLAGS result
4082def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004083 (implicit EFLAGS)),
4084 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004085def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004086 (implicit EFLAGS)),
4087 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004088def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004089 (implicit EFLAGS)),
4090 (SUB32rr GR32:$src1, GR32:$src2)>;
4091
Dan Gohman99a12192009-03-04 19:44:21 +00004092// Register-Memory Subtraction with EFLAGS result
4093def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004094 (implicit EFLAGS)),
4095 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004096def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004097 (implicit EFLAGS)),
4098 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004099def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004100 (implicit EFLAGS)),
4101 (SUB32rm GR32:$src1, addr:$src2)>;
4102
Dan Gohman99a12192009-03-04 19:44:21 +00004103// Register-Integer Subtraction with EFLAGS result
4104def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004105 (implicit EFLAGS)),
4106 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004107def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004108 (implicit EFLAGS)),
4109 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004110def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004111 (implicit EFLAGS)),
4112 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004113def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004114 (implicit EFLAGS)),
4115 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004116def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004117 (implicit EFLAGS)),
4118 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4119
Dan Gohman99a12192009-03-04 19:44:21 +00004120// Memory-Register Subtraction with EFLAGS result
4121def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004122 addr:$dst),
4123 (implicit EFLAGS)),
4124 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004125def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004126 addr:$dst),
4127 (implicit EFLAGS)),
4128 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004129def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004130 addr:$dst),
4131 (implicit EFLAGS)),
4132 (SUB32mr addr:$dst, GR32:$src2)>;
4133
Dan Gohman99a12192009-03-04 19:44:21 +00004134// Memory-Integer Subtraction with EFLAGS result
4135def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004136 addr:$dst),
4137 (implicit EFLAGS)),
4138 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004139def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004140 addr:$dst),
4141 (implicit EFLAGS)),
4142 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004143def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004144 addr:$dst),
4145 (implicit EFLAGS)),
4146 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004147def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004148 addr:$dst),
4149 (implicit EFLAGS)),
4150 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004151def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004152 addr:$dst),
4153 (implicit EFLAGS)),
4154 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4155
4156
Dan Gohman99a12192009-03-04 19:44:21 +00004157// Register-Register Signed Integer Multiply with EFLAGS result
4158def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004159 (implicit EFLAGS)),
4160 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004161def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004162 (implicit EFLAGS)),
4163 (IMUL32rr GR32:$src1, GR32:$src2)>;
4164
Dan Gohman99a12192009-03-04 19:44:21 +00004165// Register-Memory Signed Integer Multiply with EFLAGS result
4166def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004167 (implicit EFLAGS)),
4168 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004169def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004170 (implicit EFLAGS)),
4171 (IMUL32rm GR32:$src1, addr:$src2)>;
4172
Dan Gohman99a12192009-03-04 19:44:21 +00004173// Register-Integer Signed Integer Multiply with EFLAGS result
4174def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004175 (implicit EFLAGS)),
4176 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004177def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004178 (implicit EFLAGS)),
4179 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004180def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004181 (implicit EFLAGS)),
4182 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004183def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004184 (implicit EFLAGS)),
4185 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4186
Dan Gohman99a12192009-03-04 19:44:21 +00004187// Memory-Integer Signed Integer Multiply with EFLAGS result
4188def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004189 (implicit EFLAGS)),
4190 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004191def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004192 (implicit EFLAGS)),
4193 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004194def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004195 (implicit EFLAGS)),
4196 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004197def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004198 (implicit EFLAGS)),
4199 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4200
Dan Gohman99a12192009-03-04 19:44:21 +00004201// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004202let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004203def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004204 (implicit EFLAGS)),
4205 (ADD16rr GR16:$src1, GR16:$src1)>;
4206
Dan Gohman99a12192009-03-04 19:44:21 +00004207def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004208 (implicit EFLAGS)),
4209 (ADD32rr GR32:$src1, GR32:$src1)>;
4210}
4211
Dan Gohman99a12192009-03-04 19:44:21 +00004212// INC and DEC with EFLAGS result. Note that these do not set CF.
4213def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4214 (INC8r GR8:$src)>;
4215def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4216 (implicit EFLAGS)),
4217 (INC8m addr:$dst)>;
4218def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4219 (DEC8r GR8:$src)>;
4220def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4221 (implicit EFLAGS)),
4222 (DEC8m addr:$dst)>;
4223
4224def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004225 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004226def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4227 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004228 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004229def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004230 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004231def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4232 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004233 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004234
4235def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004236 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004237def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4238 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004239 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004240def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004241 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004242def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4243 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004244 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004245
Dan Gohmane84197b2009-09-03 17:18:51 +00004246// -disable-16bit support.
4247def : Pat<(truncstorei16 (i32 imm:$src), addr:$dst),
4248 (MOV16mi addr:$dst, imm:$src)>;
4249def : Pat<(truncstorei16 GR32:$src, addr:$dst),
4250 (MOV16mr addr:$dst, (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
4251def : Pat<(i32 (sextloadi16 addr:$dst)),
4252 (MOVSX32rm16 addr:$dst)>;
4253def : Pat<(i32 (zextloadi16 addr:$dst)),
4254 (MOVZX32rm16 addr:$dst)>;
4255def : Pat<(i32 (extloadi16 addr:$dst)),
4256 (MOVZX32rm16 addr:$dst)>;
4257
Bill Wendlingf5399032008-12-12 21:15:41 +00004258//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004259// Floating Point Stack Support
4260//===----------------------------------------------------------------------===//
4261
4262include "X86InstrFPStack.td"
4263
4264//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00004265// X86-64 Support
4266//===----------------------------------------------------------------------===//
4267
Chris Lattner2de8d2b2008-01-10 05:50:42 +00004268include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00004269
4270//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004271// XMM Floating point support (requires SSE / SSE2)
4272//===----------------------------------------------------------------------===//
4273
4274include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00004275
4276//===----------------------------------------------------------------------===//
4277// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4278//===----------------------------------------------------------------------===//
4279
4280include "X86InstrMMX.td"