blob: 056335f167e9612f6575766b599644f25356d73c [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
192def i8mem : X86MemOperand<"printi8mem">;
193def i16mem : X86MemOperand<"printi16mem">;
194def i32mem : X86MemOperand<"printi32mem">;
195def i64mem : X86MemOperand<"printi64mem">;
196def i128mem : X86MemOperand<"printi128mem">;
David Greene6b75fca2009-06-30 19:24:59 +0000197def i256mem : X86MemOperand<"printi256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198def f32mem : X86MemOperand<"printf32mem">;
199def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000200def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000201def f128mem : X86MemOperand<"printf128mem">;
David Greene6b75fca2009-06-30 19:24:59 +0000202def f256mem : X86MemOperand<"printf256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203
Dan Gohman744d4622009-04-13 16:09:41 +0000204// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
205// plain GR64, so that it doesn't potentially require a REX prefix.
206def i8mem_NOREX : Operand<i64> {
207 let PrintMethod = "printi8mem";
Dan Gohmanfe606822009-07-30 01:56:29 +0000208 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000209 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman744d4622009-04-13 16:09:41 +0000210}
211
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000212def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000213 let PrintMethod = "printlea32mem";
Dan Gohmanefbd3bc2009-08-05 17:40:24 +0000214 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000215 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000216}
217
218def SSECC : Operand<i8> {
219 let PrintMethod = "printSSECC";
220}
221
222def piclabel: Operand<i32> {
223 let PrintMethod = "printPICLabel";
224}
225
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000226def ImmSExt8AsmOperand : AsmOperandClass {
227 let Name = "ImmSExt8";
228 let SuperClass = ImmAsmOperand;
229}
230
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231// A couple of more descriptive operand definitions.
232// 16-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000233def i16i8imm : Operand<i16> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000234 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000235}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000236// 32-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000237def i32i8imm : Operand<i32> {
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
Chris Lattner357a0ca2009-06-20 19:34:09 +0000241// Branch targets have OtherVT type and print as pc-relative values.
242def brtarget : Operand<OtherVT> {
243 let PrintMethod = "print_pcrel_imm";
244}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000245
Evan Chengd11052b2009-07-21 06:00:18 +0000246def brtarget8 : Operand<OtherVT> {
247 let PrintMethod = "print_pcrel_imm";
248}
249
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000250//===----------------------------------------------------------------------===//
251// X86 Complex Pattern Definitions.
252//
253
254// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000255def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000256def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman0c0d7412009-08-02 16:09:17 +0000257 [add, sub, mul, X86mul_imm, shl, or, frameindex],
258 []>;
Chris Lattnerf1940742009-06-20 20:38:48 +0000259def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
260 [tglobaltlsaddr], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000261
262//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263// X86 Instruction Predicate Definitions.
264def HasMMX : Predicate<"Subtarget->hasMMX()">;
265def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
266def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
267def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
268def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000269def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
270def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene8bf22bc2009-06-26 22:46:54 +0000271def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
272def HasAVX : Predicate<"Subtarget->hasAVX()">;
273def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
274def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000275def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
276def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000277def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
278def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +0000279def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
280def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000281def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
282def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
283def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov7e1178f2009-08-06 09:11:19 +0000284 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000285def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
286 "TM.getCodeModel() == CodeModel::Kernel">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000288def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000289def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000290def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291
292//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000293// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294//
295
Evan Cheng86ab7d32007-07-31 08:04:03 +0000296include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000297
298//===----------------------------------------------------------------------===//
299// Pattern fragments...
300//
301
302// X86 specific condition code. These correspond to CondCode in
303// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000304def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
305def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
306def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
307def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
308def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
309def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
310def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
311def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
312def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
313def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000314def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000315def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000317def X86_COND_O : PatLeaf<(i8 13)>;
318def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
319def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320
321def i16immSExt8 : PatLeaf<(i16 imm), [{
322 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
323 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000324 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325}]>;
326
327def i32immSExt8 : PatLeaf<(i32 imm), [{
328 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
329 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000330 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331}]>;
332
333// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000334// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
335// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000336def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000337 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000338 if (const Value *Src = LD->getSrcValue())
339 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000340 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000341 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000342 ISD::LoadExtType ExtType = LD->getExtensionType();
343 if (ExtType == ISD::NON_EXTLOAD)
344 return true;
345 if (ExtType == ISD::EXTLOAD)
346 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000347 return false;
348}]>;
349
Dan Gohman2a174122008-10-15 06:50:19 +0000350def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000351 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000352 if (const Value *Src = LD->getSrcValue())
353 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000354 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000355 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000356 ISD::LoadExtType ExtType = LD->getExtensionType();
357 if (ExtType == ISD::EXTLOAD)
358 return LD->getAlignment() >= 2 && !LD->isVolatile();
359 return false;
360}]>;
361
Dan Gohman2a174122008-10-15 06:50:19 +0000362def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000363 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000364 if (const Value *Src = LD->getSrcValue())
365 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000366 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000367 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000368 ISD::LoadExtType ExtType = LD->getExtensionType();
369 if (ExtType == ISD::NON_EXTLOAD)
370 return true;
371 if (ExtType == ISD::EXTLOAD)
372 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000373 return false;
374}]>;
375
Dan Gohman2a174122008-10-15 06:50:19 +0000376def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000377 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000378 if (const Value *Src = LD->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000380 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000381 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000382 if (LD->isVolatile())
383 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000384 ISD::LoadExtType ExtType = LD->getExtensionType();
385 if (ExtType == ISD::NON_EXTLOAD)
386 return true;
387 if (ExtType == ISD::EXTLOAD)
388 return LD->getAlignment() >= 4;
389 return false;
390}]>;
391
sampo9cc09a32009-01-26 01:24:32 +0000392def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000393 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
394 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
395 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000396 return false;
397}]>;
398
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000399def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
400 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
401 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
402 return PT->getAddressSpace() == 257;
403 return false;
404}]>;
405
Chris Lattner12208612009-04-10 00:16:23 +0000406def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
407 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
408 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000409 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000410 return false;
411 return true;
412}]>;
413def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
414 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
415 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000416 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000417 return false;
418 return true;
419}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420
Chris Lattner12208612009-04-10 00:16:23 +0000421def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
422 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
423 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000424 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000425 return false;
426 return true;
427}]>;
428def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
429 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
430 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000431 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000432 return false;
433 return true;
434}]>;
435def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
436 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
437 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000438 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000439 return false;
440 return true;
441}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000443def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
444def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
445def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
446
447def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
448def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
449def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
450def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
451def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
452def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
453
454def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
455def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
456def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
457def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
458def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
459def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
460
Chris Lattner21da6382008-02-19 17:37:35 +0000461
462// An 'and' node with a single use.
463def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000464 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000465}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000466// An 'srl' node with a single use.
467def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
468 return N->hasOneUse();
469}]>;
470// An 'trunc' node with a single use.
471def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
472 return N->hasOneUse();
473}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000474
Dan Gohman921581d2008-10-17 01:23:35 +0000475// 'shld' and 'shrd' instruction patterns. Note that even though these have
476// the srl and shl in their patterns, the C++ code must still check for them,
477// because predicates are tested before children nodes are explored.
478
479def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
480 (or (srl node:$src1, node:$amt1),
481 (shl node:$src2, node:$amt2)), [{
482 assert(N->getOpcode() == ISD::OR);
483 return N->getOperand(0).getOpcode() == ISD::SRL &&
484 N->getOperand(1).getOpcode() == ISD::SHL &&
485 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
486 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
487 N->getOperand(0).getConstantOperandVal(1) ==
488 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
489}]>;
490
491def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
492 (or (shl node:$src1, node:$amt1),
493 (srl node:$src2, node:$amt2)), [{
494 assert(N->getOpcode() == ISD::OR);
495 return N->getOperand(0).getOpcode() == ISD::SHL &&
496 N->getOperand(1).getOpcode() == ISD::SRL &&
497 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
498 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
499 N->getOperand(0).getConstantOperandVal(1) ==
500 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
501}]>;
502
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000503//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504// Instruction list...
505//
506
507// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
508// a stack adjustment and the codegen must know that they may modify the stack
509// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000510// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
511// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000512let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000513def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
514 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000515 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000516 Requires<[In32BitMode]>;
517def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
518 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000519 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000520 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000521}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522
Dan Gohman34228bf2009-08-15 01:38:56 +0000523// x86-64 va_start lowering magic.
524let usesCustomDAGSchedInserter = 1 in
525def VASTART_SAVE_XMM_REGS : I<0, Pseudo,
526 (outs),
527 (ins GR8:$al,
528 i64imm:$regsavefi, i64imm:$offset,
529 variable_ops),
530 "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset",
531 [(X86vastart_save_xmm_regs GR8:$al,
532 imm:$regsavefi,
533 imm:$offset)]>;
534
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535// Nop
Sean Callananf94a0542009-07-23 23:39:34 +0000536let neverHasSideEffects = 1 in {
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000537 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callananf94a0542009-07-23 23:39:34 +0000538 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
539 "nopl\t$zero", []>, TB;
540}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000541
Sean Callanan9b195f82009-08-11 01:09:06 +0000542// Trap
543def INT3 : I<0xcc, RawFrm, (outs), (ins), "int 3", []>;
544def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
545
Evan Cheng0729ccf2008-01-05 00:41:47 +0000546// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000547let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000548 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman70a8a112009-04-27 15:13:28 +0000549 "call\t$label\n\t"
550 "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551
552//===----------------------------------------------------------------------===//
553// Control Flow Instructions...
554//
555
556// Return instructions.
557let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000558 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000559 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000560 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000561 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000562 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
563 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000564 [(X86retflag imm:$amt)]>;
565}
566
567// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000568let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000569 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
570 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000571
Sean Callananc0608152009-07-22 01:05:20 +0000572let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000573 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000574 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
575}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576
Owen Andersonf8053082007-11-12 07:39:39 +0000577// Indirect branches
578let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000579 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000581 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000582 [(brind (loadi32 addr:$dst))]>;
583}
584
585// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000586let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000587// Short conditional jumps
588def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
589def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
590def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
591def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
592def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
593def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
594def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
595def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
596def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
597def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
598def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
599def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
600def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
601def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
602def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
603def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
604
605def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
606
Dan Gohman91888f02007-07-31 20:11:57 +0000607def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000608 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000609def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000610 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000611def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000612 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000613def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000614 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000615def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000616 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000617def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000618 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619
Dan Gohman91888f02007-07-31 20:11:57 +0000620def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000621 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000622def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000623 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000624def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000625 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000626def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000627 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000628
Dan Gohman91888f02007-07-31 20:11:57 +0000629def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000630 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000631def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000632 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000633def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000634 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000635def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000636 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000637def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000638 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000639def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000640 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000641} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642
643//===----------------------------------------------------------------------===//
644// Call Instructions...
645//
Evan Cheng37e7c752007-07-21 00:34:19 +0000646let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000647 // All calls clobber the non-callee saved registers. ESP is marked as
648 // a use to prevent stack-pointer assignments that appear immediately
649 // before calls from potentially appearing dead. Uses for argument
650 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000651 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
652 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000653 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
654 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000655 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000656 def CALLpcrel32 : Ii32<0xE8, RawFrm,
657 (outs), (ins i32imm_pcrel:$dst,variable_ops),
658 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000659 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000660 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000661 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000662 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000663 }
664
665// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000666
Evan Cheng37e7c752007-07-21 00:34:19 +0000667let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000668def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000669 "#TC_RETURN $dst $offset",
670 []>;
671
672let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000673def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000674 "#TC_RETURN $dst $offset",
675 []>;
676
677let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000678
Chris Lattner357a0ca2009-06-20 19:34:09 +0000679 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000680 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000681let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000682 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
683 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000684let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000685 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000686 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687
688//===----------------------------------------------------------------------===//
689// Miscellaneous Instructions...
690//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000691let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000693 (outs), (ins), "leave", []>;
694
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000695let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
696let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000697def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000698
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000699let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000700def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000701}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702
Bill Wendling4c2638c2009-06-15 19:39:04 +0000703let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
704def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000705 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000706def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000707 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000708def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000709 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000710}
711
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000712let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000713def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000714let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000715def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000716
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717let isTwoAddress = 1 in // GR32 = bswap GR32
718 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000719 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000720 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
722
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723
Evan Cheng48679f42007-12-14 02:13:44 +0000724// Bit scan instructions.
725let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000726def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000727 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000728 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000729def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000730 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000731 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
732 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000733def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000734 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000735 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000736def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000737 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000738 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
739 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000740
Evan Cheng4e33de92007-12-14 18:49:43 +0000741def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000742 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000743 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000744def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000745 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000746 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
747 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000748def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000749 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000750 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000751def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000752 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000753 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
754 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000755} // Defs = [EFLAGS]
756
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000757let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000759 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000760 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000761let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000763 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000764 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
766
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000767let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000768def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000769 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000770def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000771 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000772def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000773 [(X86rep_movs i32)]>, REP;
774}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000776let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000777def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000778 [(X86rep_stos i8)]>, REP;
779let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000780def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000781 [(X86rep_stos i16)]>, REP, OpSize;
782let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000783def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000784 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000786let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000787def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000788 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000790let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000791def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000792}
793
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000794def SYSCALL : I<0x05, RawFrm,
795 (outs), (ins), "syscall", []>, TB;
796def SYSRET : I<0x07, RawFrm,
797 (outs), (ins), "sysret", []>, TB;
798def SYSENTER : I<0x34, RawFrm,
799 (outs), (ins), "sysenter", []>, TB;
800def SYSEXIT : I<0x35, RawFrm,
801 (outs), (ins), "sysexit", []>, TB;
802
803
804
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805//===----------------------------------------------------------------------===//
806// Input/Output Instructions...
807//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000808let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000809def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000810 "in{b}\t{%dx, %al|%AL, %DX}", []>;
811let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000812def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000813 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
814let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000815def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000816 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000818let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000819def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000820 "in{b}\t{$port, %al|%AL, $port}", []>;
821let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000822def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000823 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
824let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000825def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000826 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000828let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000829def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000830 "out{b}\t{%al, %dx|%DX, %AL}", []>;
831let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000832def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000833 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
834let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000835def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000836 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000838let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000839def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000840 "out{b}\t{%al, $port|$port, %AL}", []>;
841let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000842def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000843 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
844let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000845def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000846 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847
848//===----------------------------------------------------------------------===//
849// Move Instructions...
850//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000851let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000852def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000853 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000854def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000855 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000856def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000857 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000858}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000859let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000860def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000863def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000864 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000866def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000867 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868 [(set GR32:$dst, imm:$src)]>;
869}
Evan Chengb783fa32007-07-19 01:14:50 +0000870def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000871 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000873def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000874 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000876def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000877 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000878 [(store (i32 imm:$src), addr:$dst)]>;
879
Dan Gohman5574cc72008-12-03 18:15:48 +0000880let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000881def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000882 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000883 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000884def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000885 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000886 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000887def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000888 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000889 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000890}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891
Evan Chengb783fa32007-07-19 01:14:50 +0000892def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000893 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000895def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000896 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000898def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000899 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000901
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000902// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
903// that they can be used for copying and storing h registers, which can't be
904// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000905let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000906def MOV8rr_NOREX : I<0x88, MRMDestReg,
907 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000908 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000909let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000910def MOV8mr_NOREX : I<0x88, MRMDestMem,
911 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
912 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000913let mayLoad = 1,
914 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000915def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
916 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
917 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000918
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000919//===----------------------------------------------------------------------===//
920// Fixed-Register Multiplication and Division Instructions...
921//
922
923// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000924let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000925def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000926 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
927 // This probably ought to be moved to a def : Pat<> if the
928 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000929 [(set AL, (mul AL, GR8:$src)),
930 (implicit EFLAGS)]>; // AL,AH = AL*GR8
931
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000932let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000933def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
934 "mul{w}\t$src",
935 []>, OpSize; // AX,DX = AX*GR16
936
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000937let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000938def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
939 "mul{l}\t$src",
940 []>; // EAX,EDX = EAX*GR32
941
Evan Cheng55687072007-09-14 21:48:26 +0000942let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000943def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000944 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
946 // This probably ought to be moved to a def : Pat<> if the
947 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000948 [(set AL, (mul AL, (loadi8 addr:$src))),
949 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
950
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000951let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000952let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000953def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000954 "mul{w}\t$src",
955 []>, OpSize; // AX,DX = AX*[mem16]
956
Evan Cheng55687072007-09-14 21:48:26 +0000957let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000958def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000959 "mul{l}\t$src",
960 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000961}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000963let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000964let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000965def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
966 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000967let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000968def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000969 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000970let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000971def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
972 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000973let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000974let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000975def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000976 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000977let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000978def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000979 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
980let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000981def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000982 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000983}
Dan Gohmand44572d2008-11-18 21:29:14 +0000984} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985
986// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000987let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000988def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000989 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000990let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000991def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000992 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000993let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000994def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000995 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000996let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000997let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000998def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000999 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001000let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001001def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001002 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001003let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001004def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001005 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001006}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007
1008// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +00001009let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001010def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001011 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001012let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001013def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001014 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001015let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001016def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001017 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001018let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +00001019let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001020def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001021 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001022let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001023def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001024 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001025let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001026def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001027 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001028}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029
1030//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001031// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032//
1033let isTwoAddress = 1 in {
1034
1035// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001036let Uses = [EFLAGS] in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001037
1038// X86 doesn't have 8-bit conditional moves. Use a customDAGSchedInserter to
1039// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1040// however that requires promoting the operands, and can induce additional
Dan Gohman1596dd22009-08-29 22:19:15 +00001041// i8 register pressure. Note that CMOV_GR8 is conservatively considered to
1042// clobber EFLAGS, because if one of the operands is zero, the expansion
1043// could involve an xor.
1044let usesCustomDAGSchedInserter = 1, isTwoAddress = 0, Defs = [EFLAGS] in
Dan Gohman29b998f2009-08-27 00:14:12 +00001045def CMOV_GR8 : I<0, Pseudo,
1046 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1047 "#CMOV_GR8 PSEUDO!",
1048 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1049 imm:$cond, EFLAGS))]>;
1050
Dan Gohman90adb6c2009-08-27 18:16:24 +00001051let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001053 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001054 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001056 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001059 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001060 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001062 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001065 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001066 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001068 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001069 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001071 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001072 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001074 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001077 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001078 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001080 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001083 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001084 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001086 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001088def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001089 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001090 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001092 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001095 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001096 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001098 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001101 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001102 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001103 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001104 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001107 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001108 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001110 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001113 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001114 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001116 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001119 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001120 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001122 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001123 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001125 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001126 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001127 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001128 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001131 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001132 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001134 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001137 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001138 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001140 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001141 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001142def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001143 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001144 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001146 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001147 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001149 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001150 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001152 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001155 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001156 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001157 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001158 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001159 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001161 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001162 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001163 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001164 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001167 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001168 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001170 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001171 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001172def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001173 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001174 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001176 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001178def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001179 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001180 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001182 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001183 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001185 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001186 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001187 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001188 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001189 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001190def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001191 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001192 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001194 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001195 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001196def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001197 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001198 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001199 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001200 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001201 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001203 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001204 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001206 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001208def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001209 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001210 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001212 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001213 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001214def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001215 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001216 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001217 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001218 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001219 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001220def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1221 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1222 "cmovo\t{$src2, $dst|$dst, $src2}",
1223 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1224 X86_COND_O, EFLAGS))]>,
1225 TB, OpSize;
1226def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1227 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1228 "cmovo\t{$src2, $dst|$dst, $src2}",
1229 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1230 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001231 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001232def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1233 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1234 "cmovno\t{$src2, $dst|$dst, $src2}",
1235 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1236 X86_COND_NO, EFLAGS))]>,
1237 TB, OpSize;
1238def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1239 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1240 "cmovno\t{$src2, $dst|$dst, $src2}",
1241 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1242 X86_COND_NO, EFLAGS))]>,
1243 TB;
1244} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001245
1246def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1247 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1248 "cmovb\t{$src2, $dst|$dst, $src2}",
1249 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1250 X86_COND_B, EFLAGS))]>,
1251 TB, OpSize;
1252def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1253 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1254 "cmovb\t{$src2, $dst|$dst, $src2}",
1255 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1256 X86_COND_B, EFLAGS))]>,
1257 TB;
1258def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1259 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1260 "cmovae\t{$src2, $dst|$dst, $src2}",
1261 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1262 X86_COND_AE, EFLAGS))]>,
1263 TB, OpSize;
1264def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1265 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1266 "cmovae\t{$src2, $dst|$dst, $src2}",
1267 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1268 X86_COND_AE, EFLAGS))]>,
1269 TB;
1270def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1271 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1272 "cmove\t{$src2, $dst|$dst, $src2}",
1273 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1274 X86_COND_E, EFLAGS))]>,
1275 TB, OpSize;
1276def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1277 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1278 "cmove\t{$src2, $dst|$dst, $src2}",
1279 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1280 X86_COND_E, EFLAGS))]>,
1281 TB;
1282def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1283 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1284 "cmovne\t{$src2, $dst|$dst, $src2}",
1285 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1286 X86_COND_NE, EFLAGS))]>,
1287 TB, OpSize;
1288def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1289 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1290 "cmovne\t{$src2, $dst|$dst, $src2}",
1291 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1292 X86_COND_NE, EFLAGS))]>,
1293 TB;
1294def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1295 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1296 "cmovbe\t{$src2, $dst|$dst, $src2}",
1297 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1298 X86_COND_BE, EFLAGS))]>,
1299 TB, OpSize;
1300def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1301 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1302 "cmovbe\t{$src2, $dst|$dst, $src2}",
1303 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1304 X86_COND_BE, EFLAGS))]>,
1305 TB;
1306def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1307 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1308 "cmova\t{$src2, $dst|$dst, $src2}",
1309 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1310 X86_COND_A, EFLAGS))]>,
1311 TB, OpSize;
1312def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1313 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1314 "cmova\t{$src2, $dst|$dst, $src2}",
1315 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1316 X86_COND_A, EFLAGS))]>,
1317 TB;
1318def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1319 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1320 "cmovl\t{$src2, $dst|$dst, $src2}",
1321 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1322 X86_COND_L, EFLAGS))]>,
1323 TB, OpSize;
1324def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1325 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1326 "cmovl\t{$src2, $dst|$dst, $src2}",
1327 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1328 X86_COND_L, EFLAGS))]>,
1329 TB;
1330def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1331 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1332 "cmovge\t{$src2, $dst|$dst, $src2}",
1333 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1334 X86_COND_GE, EFLAGS))]>,
1335 TB, OpSize;
1336def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1337 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1338 "cmovge\t{$src2, $dst|$dst, $src2}",
1339 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1340 X86_COND_GE, EFLAGS))]>,
1341 TB;
1342def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1343 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1344 "cmovle\t{$src2, $dst|$dst, $src2}",
1345 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1346 X86_COND_LE, EFLAGS))]>,
1347 TB, OpSize;
1348def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1349 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1350 "cmovle\t{$src2, $dst|$dst, $src2}",
1351 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1352 X86_COND_LE, EFLAGS))]>,
1353 TB;
1354def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1355 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1356 "cmovg\t{$src2, $dst|$dst, $src2}",
1357 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1358 X86_COND_G, EFLAGS))]>,
1359 TB, OpSize;
1360def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1361 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1362 "cmovg\t{$src2, $dst|$dst, $src2}",
1363 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1364 X86_COND_G, EFLAGS))]>,
1365 TB;
1366def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1367 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1368 "cmovs\t{$src2, $dst|$dst, $src2}",
1369 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1370 X86_COND_S, EFLAGS))]>,
1371 TB, OpSize;
1372def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1373 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1374 "cmovs\t{$src2, $dst|$dst, $src2}",
1375 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1376 X86_COND_S, EFLAGS))]>,
1377 TB;
1378def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1379 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1380 "cmovns\t{$src2, $dst|$dst, $src2}",
1381 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1382 X86_COND_NS, EFLAGS))]>,
1383 TB, OpSize;
1384def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1385 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1386 "cmovns\t{$src2, $dst|$dst, $src2}",
1387 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1388 X86_COND_NS, EFLAGS))]>,
1389 TB;
1390def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1391 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1392 "cmovp\t{$src2, $dst|$dst, $src2}",
1393 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1394 X86_COND_P, EFLAGS))]>,
1395 TB, OpSize;
1396def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1397 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1398 "cmovp\t{$src2, $dst|$dst, $src2}",
1399 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1400 X86_COND_P, EFLAGS))]>,
1401 TB;
1402def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1403 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1404 "cmovnp\t{$src2, $dst|$dst, $src2}",
1405 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1406 X86_COND_NP, EFLAGS))]>,
1407 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001408def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1409 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1410 "cmovnp\t{$src2, $dst|$dst, $src2}",
1411 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1412 X86_COND_NP, EFLAGS))]>,
1413 TB;
1414def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1415 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1416 "cmovo\t{$src2, $dst|$dst, $src2}",
1417 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1418 X86_COND_O, EFLAGS))]>,
1419 TB, OpSize;
1420def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1421 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1422 "cmovo\t{$src2, $dst|$dst, $src2}",
1423 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1424 X86_COND_O, EFLAGS))]>,
1425 TB;
1426def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1427 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1428 "cmovno\t{$src2, $dst|$dst, $src2}",
1429 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1430 X86_COND_NO, EFLAGS))]>,
1431 TB, OpSize;
1432def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1433 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1434 "cmovno\t{$src2, $dst|$dst, $src2}",
1435 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1436 X86_COND_NO, EFLAGS))]>,
1437 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001438} // Uses = [EFLAGS]
1439
1440
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001441// unary instructions
1442let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001443let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001444def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001445 [(set GR8:$dst, (ineg GR8:$src)),
1446 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001447def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001448 [(set GR16:$dst, (ineg GR16:$src)),
1449 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001450def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001451 [(set GR32:$dst, (ineg GR32:$src)),
1452 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001453let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001454 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001455 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1456 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001457 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001458 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1459 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001460 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001461 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1462 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001463}
Evan Cheng55687072007-09-14 21:48:26 +00001464} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001465
Evan Chengc6cee682009-01-21 02:09:05 +00001466// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1467let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001468def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001469 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001470def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001472def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001474}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001475let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001476 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001477 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001478 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001479 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001480 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001481 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1482}
1483} // CodeSize
1484
1485// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001486let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001487let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001488def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001489 [(set GR8:$dst, (add GR8:$src, 1)),
1490 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001491let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001492def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001493 [(set GR16:$dst, (add GR16:$src, 1)),
1494 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001495 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001496def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001497 [(set GR32:$dst, (add GR32:$src, 1)),
1498 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001499}
1500let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001501 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001502 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1503 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001504 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001505 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1506 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001507 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001508 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001509 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1510 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001511 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001512}
1513
1514let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001515def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001516 [(set GR8:$dst, (add GR8:$src, -1)),
1517 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001518let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001519def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001520 [(set GR16:$dst, (add GR16:$src, -1)),
1521 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001523def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001524 [(set GR32:$dst, (add GR32:$src, -1)),
1525 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001526}
1527
1528let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001529 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001530 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1531 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001532 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001533 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1534 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001535 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001536 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001537 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1538 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001539 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540}
Evan Cheng55687072007-09-14 21:48:26 +00001541} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001542
1543// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001544let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001545let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1546def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001547 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001548 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001549 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1550 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001552 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001554 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1555 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001557 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001559 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1560 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561}
1562
1563def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001564 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001565 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001566 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001567 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001568def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001569 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001570 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001571 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001572 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001573def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001574 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001575 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001576 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001577 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578
1579def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001580 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001581 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001582 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1583 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001584def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001585 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001586 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001587 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1588 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001589def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001590 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001591 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001592 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1593 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001594def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001595 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001596 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001597 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1598 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 OpSize;
1600def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001601 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001603 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1604 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001605
1606let isTwoAddress = 0 in {
1607 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001608 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001609 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001610 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1611 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001612 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001613 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001614 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001615 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1616 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617 OpSize;
1618 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001619 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001620 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001621 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1622 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001624 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001625 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001626 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1627 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001628 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001629 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001630 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001631 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1632 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001633 OpSize;
1634 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001635 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001636 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001637 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1638 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001640 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001642 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1643 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644 OpSize;
1645 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001646 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001648 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1649 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650}
1651
1652
1653let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001654def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001656 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1657 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001658def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001659 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001660 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1661 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001662def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001664 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1665 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001666}
Evan Chengb783fa32007-07-19 01:14:50 +00001667def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001668 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001669 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1670 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001671def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001672 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001673 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1674 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001675def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001676 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001677 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1678 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001679
Evan Chengb783fa32007-07-19 01:14:50 +00001680def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001681 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001682 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1683 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001684def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001685 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001686 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1687 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001688def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001690 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1691 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692
Evan Chengb783fa32007-07-19 01:14:50 +00001693def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001694 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001695 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1696 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001697def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001698 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001699 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1700 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001702 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001703 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001704 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1705 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001706 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001707 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001708 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1709 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001710 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001712 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1713 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001714 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001715 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001716 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1717 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001718 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001720 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1721 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001723 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001725 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1726 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001727 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001728 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001729 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1730 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001731 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001732 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001733 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001734 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1735 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001736} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737
1738
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001739let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001740 def XOR8rr : I<0x30, MRMDestReg,
1741 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1742 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001743 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1744 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001745 def XOR16rr : I<0x31, MRMDestReg,
1746 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1747 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001748 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1749 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001750 def XOR32rr : I<0x31, MRMDestReg,
1751 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1752 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001753 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1754 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001755} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001756
1757def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001758 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001760 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1761 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001763 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001765 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1766 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001767 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001768def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001769 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001770 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001771 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1772 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001773
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001774def XOR8ri : Ii8<0x80, MRM6r,
1775 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1776 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001777 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1778 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001779def XOR16ri : Ii16<0x81, MRM6r,
1780 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1781 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001782 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1783 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001784def XOR32ri : Ii32<0x81, MRM6r,
1785 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1786 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001787 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1788 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001789def XOR16ri8 : Ii8<0x83, MRM6r,
1790 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1791 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001792 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1793 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001794 OpSize;
1795def XOR32ri8 : Ii8<0x83, MRM6r,
1796 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1797 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001798 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1799 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001800
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801let isTwoAddress = 0 in {
1802 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001803 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001805 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1806 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001807 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001808 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001809 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001810 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1811 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812 OpSize;
1813 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001814 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001815 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001816 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1817 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001818 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001819 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001821 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1822 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001824 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001826 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1827 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001828 OpSize;
1829 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001830 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001832 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1833 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001834 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001835 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001837 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1838 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001839 OpSize;
1840 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001841 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001842 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001843 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1844 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001845} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001846} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001847
1848// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001849let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001850let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001851def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001852 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001853 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001854def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001855 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001856 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001857def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001858 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001859 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001860} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001861
Evan Chengb783fa32007-07-19 01:14:50 +00001862def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1865let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001866def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001868 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001869def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001870 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001872// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1873// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001874} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001875
1876let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001877 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001878 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001879 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001880 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001881 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001882 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001883 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001884 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001885 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001886 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1887 }
Evan Chengb783fa32007-07-19 01:14:50 +00001888 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001889 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001890 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001891 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001892 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001893 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1894 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001895 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001896 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001897 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1898
1899 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001900 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001903 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001905 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1906 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001907 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1910}
1911
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001912let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001913def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001914 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001915 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001916def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001917 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001918 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001919def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001920 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001921 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1922}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923
Evan Chengb783fa32007-07-19 01:14:50 +00001924def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001927def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001930def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001931 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1933
1934// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001935def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001936 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001937 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001938def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001939 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001940 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001941def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001942 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1944
1945let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001946 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001947 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001948 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001949 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001950 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001951 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001952 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001953 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001954 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001955 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001956 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1957 }
Evan Chengb783fa32007-07-19 01:14:50 +00001958 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001961 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1964 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001965 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1968
1969 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001970 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001971 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001973 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001974 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001976 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001977 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1979}
1980
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001981let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001982def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001983 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001984 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001985def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001986 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001987 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001988def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001989 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001990 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1991}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992
Evan Chengb783fa32007-07-19 01:14:50 +00001993def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001994 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001995 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001996def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001997 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001998 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1999 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002000def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002001 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2003
2004// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002005def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002006 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002007 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002008def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002009 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002011def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002012 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002013 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2014
2015let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002016 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002017 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002018 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002019 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002020 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002021 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002022 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002023 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002024 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002025 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2026 }
Evan Chengb783fa32007-07-19 01:14:50 +00002027 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002028 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002030 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002031 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002032 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2033 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002034 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002035 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2037
2038 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002039 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002040 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002042 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002043 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2045 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002046 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002047 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002048 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2049}
2050
2051// Rotate instructions
2052// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002053let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002054def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002055 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002056 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002057def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002058 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002059 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002060def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002061 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002062 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2063}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002064
Evan Chengb783fa32007-07-19 01:14:50 +00002065def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002068def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002071def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002072 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002073 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2074
2075// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002076def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002077 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002079def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002082def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002083 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2085
2086let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002087 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002088 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002089 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002090 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002091 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002092 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002093 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002094 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002095 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002096 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2097 }
Evan Chengb783fa32007-07-19 01:14:50 +00002098 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002099 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002100 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002101 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002102 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2104 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002105 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002106 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2108
2109 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002110 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002113 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002114 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002115 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2116 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002117 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002118 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2120}
2121
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002122let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002123def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002124 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002125 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002126def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002127 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002128 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002129def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002130 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002131 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2132}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133
Evan Chengb783fa32007-07-19 01:14:50 +00002134def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002135 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002136 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002137def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002138 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002140def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002141 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002142 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2143
2144// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002145def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002146 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002147 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002148def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002149 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002150 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002151def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2154
2155let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002156 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002157 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002158 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002159 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002160 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002161 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002162 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002163 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002164 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002165 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2166 }
Evan Chengb783fa32007-07-19 01:14:50 +00002167 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002168 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002169 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002170 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002172 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2173 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002174 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002175 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002176 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2177
2178 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002179 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002180 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002181 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002182 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002183 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2185 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002186 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002187 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2189}
2190
2191
2192
2193// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002194let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002195def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002196 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002197 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002198def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002199 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002200 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002201def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002202 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002203 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002204 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002205def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002206 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002207 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002208 TB, OpSize;
2209}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002210
2211let isCommutable = 1 in { // These instructions commute to each other.
2212def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002213 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002214 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002215 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2216 (i8 imm:$src3)))]>,
2217 TB;
2218def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002219 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002220 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002221 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2222 (i8 imm:$src3)))]>,
2223 TB;
2224def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002225 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002226 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002227 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2228 (i8 imm:$src3)))]>,
2229 TB, OpSize;
2230def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002231 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002232 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002233 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2234 (i8 imm:$src3)))]>,
2235 TB, OpSize;
2236}
2237
2238let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002239 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002240 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002241 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002242 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002243 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002244 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002245 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002246 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002247 addr:$dst)]>, TB;
2248 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002249 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002250 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002251 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002252 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2253 (i8 imm:$src3)), addr:$dst)]>,
2254 TB;
2255 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002256 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002258 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2259 (i8 imm:$src3)), addr:$dst)]>,
2260 TB;
2261
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002262 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002263 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002264 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002265 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002266 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002267 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002268 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002270 addr:$dst)]>, TB, OpSize;
2271 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002272 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002273 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002274 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002275 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2276 (i8 imm:$src3)), addr:$dst)]>,
2277 TB, OpSize;
2278 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002279 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002280 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002281 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2282 (i8 imm:$src3)), addr:$dst)]>,
2283 TB, OpSize;
2284}
Evan Cheng55687072007-09-14 21:48:26 +00002285} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002286
2287
2288// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002289let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002291// Register-Register Addition
2292def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2293 (ins GR8 :$src1, GR8 :$src2),
2294 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002295 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002296 (implicit EFLAGS)]>;
2297
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002298let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002299// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002300def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2301 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002302 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002303 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2304 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002305def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2306 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002307 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002308 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2309 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002310} // end isConvertibleToThreeAddress
2311} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002312
2313// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002314def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2315 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002316 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002317 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2318 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002319def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2320 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002321 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002322 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2323 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002324def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2325 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002326 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002327 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2328 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002329
Bill Wendlingae034ed2008-12-12 00:56:36 +00002330// Register-Integer Addition
2331def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2332 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002333 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2334 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002335
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002336let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002337// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002338def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2339 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002340 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002341 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2342 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002343def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2344 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002345 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002346 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2347 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002348def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2349 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002350 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002351 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2352 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002353def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2354 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002355 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002356 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2357 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002358}
2359
2360let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002361 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002362 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002363 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002364 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2365 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002366 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002367 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002368 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2369 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002370 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002372 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2373 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002374 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002375 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002376 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2377 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002378 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002379 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002380 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2381 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002382 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002383 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002384 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2385 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002386 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002387 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002388 [(store (add (load addr:$dst), i16immSExt8:$src2),
2389 addr:$dst),
2390 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002391 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002392 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002393 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002394 addr:$dst),
2395 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002396
2397 // addition to rAX
2398 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2399 "add\t{$src, %al|%al, $src}", []>;
2400 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2401 "add\t{$src, %ax|%ax, $src}", []>, OpSize;
2402 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2403 "add\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002404}
2405
Evan Cheng259471d2007-10-05 17:59:57 +00002406let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002407let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002408def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002409 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002410 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002411def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2412 (ins GR16:$src1, GR16:$src2),
2413 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002414 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002415def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2416 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002417 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002418 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002419}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002420def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2421 (ins GR8:$src1, i8mem:$src2),
2422 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002423 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002424def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2425 (ins GR16:$src1, i16mem:$src2),
2426 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002427 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002428 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002429def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2430 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002431 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002432 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2433def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002434 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002435 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002436def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2437 (ins GR16:$src1, i16imm:$src2),
2438 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002439 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002440def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2441 (ins GR16:$src1, i16i8imm:$src2),
2442 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002443 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2444 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002445def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2446 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002447 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002448 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002449def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2450 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002451 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002452 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002453
2454let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002455 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002456 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002457 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2458 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002459 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002460 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2461 OpSize;
2462 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002463 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002464 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2465 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002466 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002467 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2468 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002469 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002470 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2471 OpSize;
2472 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002473 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002474 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2475 OpSize;
2476 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002477 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002478 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2479 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002480 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002481 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2482}
Evan Cheng259471d2007-10-05 17:59:57 +00002483} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002484
Bill Wendlingae034ed2008-12-12 00:56:36 +00002485// Register-Register Subtraction
2486def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2487 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002488 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2489 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002490def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2491 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002492 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2493 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002494def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2495 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002496 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2497 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002498
2499// Register-Memory Subtraction
2500def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2501 (ins GR8 :$src1, i8mem :$src2),
2502 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002503 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2504 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002505def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2506 (ins GR16:$src1, i16mem:$src2),
2507 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002508 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2509 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002510def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2511 (ins GR32:$src1, i32mem:$src2),
2512 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002513 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2514 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002515
2516// Register-Integer Subtraction
2517def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2518 (ins GR8:$src1, i8imm:$src2),
2519 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002520 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2521 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002522def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2523 (ins GR16:$src1, i16imm:$src2),
2524 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002525 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2526 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002527def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2528 (ins GR32:$src1, i32imm:$src2),
2529 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002530 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2531 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002532def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2533 (ins GR16:$src1, i16i8imm:$src2),
2534 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002535 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2536 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002537def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2538 (ins GR32:$src1, i32i8imm:$src2),
2539 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002540 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2541 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002542
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002543let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002544 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002545 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002546 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002547 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2548 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002549 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002550 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002551 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2552 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002553 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002554 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002555 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2556 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002557
2558 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002559 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002560 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002561 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2562 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002563 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002564 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002565 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2566 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002567 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002568 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002569 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2570 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002571 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002572 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002573 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002574 addr:$dst),
2575 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002576 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002577 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002578 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002579 addr:$dst),
2580 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002581}
2582
Evan Cheng259471d2007-10-05 17:59:57 +00002583let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002584def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2585 (ins GR8:$src1, GR8:$src2),
2586 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002587 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002588def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2589 (ins GR16:$src1, GR16:$src2),
2590 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002591 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002592def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2593 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002594 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002595 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002596
2597let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002598 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2599 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002600 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002601 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2602 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002603 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002604 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002605 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002606 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002607 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002608 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002609 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002610 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002611 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2612 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002613 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002614 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002615 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2616 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002617 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002618 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002619 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002620 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002621 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002622 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002623 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002624 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002625}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002626def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2627 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002628 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002629def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2630 (ins GR16:$src1, i16mem:$src2),
2631 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002632 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002633 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002634def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2635 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002636 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002637 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002638def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2639 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002640 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002641def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2642 (ins GR16:$src1, i16imm:$src2),
2643 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002644 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002645def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2646 (ins GR16:$src1, i16i8imm:$src2),
2647 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002648 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2649 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002650def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2651 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002652 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002653 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002654def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2655 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002656 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002657 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002658} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002659} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002660
Evan Cheng55687072007-09-14 21:48:26 +00002661let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002662let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002663// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002664def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002665 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002666 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2667 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002668def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002669 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002670 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2671 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002672}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002673
Bill Wendlingf5399032008-12-12 21:15:41 +00002674// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002675def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2676 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002677 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002678 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2679 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002680def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002681 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002682 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2683 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002684} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002685} // end Two Address instructions
2686
2687// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002688let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002689// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002690def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002691 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002692 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002693 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2694 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002695def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002696 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002697 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002698 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2699 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002700def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002701 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002702 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002703 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2704 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002705def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002706 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002707 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002708 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2709 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002710
Bill Wendlingf5399032008-12-12 21:15:41 +00002711// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002712def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002713 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002714 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002715 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2716 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002717def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002718 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002719 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002720 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2721 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002722def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002723 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002724 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002725 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002726 i16immSExt8:$src2)),
2727 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002728def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002729 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002730 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002731 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002732 i32immSExt8:$src2)),
2733 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002734} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002735
2736//===----------------------------------------------------------------------===//
2737// Test instructions are just like AND, except they don't generate a result.
2738//
Evan Cheng950aac02007-09-25 01:57:46 +00002739let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002740let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002741def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002742 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002743 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002744 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002745def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002746 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002747 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002748 (implicit EFLAGS)]>,
2749 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002750def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002751 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002752 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002753 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002754}
2755
Evan Chengb783fa32007-07-19 01:14:50 +00002756def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002757 "test{b}\t{$src2, $src1|$src1, $src2}",
2758 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2759 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002760def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002761 "test{w}\t{$src2, $src1|$src1, $src2}",
2762 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2763 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002764def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002765 "test{l}\t{$src2, $src1|$src1, $src2}",
2766 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2767 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002768
2769def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002770 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002771 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002772 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002773 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002774def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002775 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002776 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002777 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002778 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002779def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002780 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002781 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002782 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002783 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002784
Evan Cheng621216e2007-09-29 00:00:36 +00002785def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002786 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002787 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002788 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2789 (implicit EFLAGS)]>;
2790def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002791 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002792 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002793 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2794 (implicit EFLAGS)]>, OpSize;
2795def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002796 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002797 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002798 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002799 (implicit EFLAGS)]>;
2800} // Defs = [EFLAGS]
2801
2802
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002803// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002804let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002805def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002806let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002807def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002808
Evan Cheng950aac02007-09-25 01:57:46 +00002809let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002810def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002811 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002812 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002813 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002814 TB; // GR8 = ==
2815def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002816 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002817 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002818 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002819 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002820
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002821def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002822 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002823 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002824 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002825 TB; // GR8 = !=
2826def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002827 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002828 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002829 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002830 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002831
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002832def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002833 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002834 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002835 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002836 TB; // GR8 = < signed
2837def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002838 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002839 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002840 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002841 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002842
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002843def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002844 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002845 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002846 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002847 TB; // GR8 = >= signed
2848def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002849 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002850 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002851 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002852 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002853
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002855 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002856 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002857 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002858 TB; // GR8 = <= signed
2859def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002860 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002861 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002862 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002863 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002864
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002865def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002866 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002867 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002868 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002869 TB; // GR8 = > signed
2870def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002871 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002872 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002873 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002874 TB; // [mem8] = > signed
2875
2876def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002877 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002878 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002879 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002880 TB; // GR8 = < unsign
2881def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002882 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002883 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002884 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002885 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002886
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002887def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002888 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002889 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002890 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002891 TB; // GR8 = >= unsign
2892def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002893 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002894 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002895 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002896 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002897
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002898def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002899 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002900 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002901 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002902 TB; // GR8 = <= unsign
2903def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002904 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002905 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002906 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002907 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002908
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002909def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002910 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002911 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002912 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002913 TB; // GR8 = > signed
2914def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002915 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002916 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002917 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002918 TB; // [mem8] = > signed
2919
2920def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002921 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002922 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002923 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002924 TB; // GR8 = <sign bit>
2925def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002926 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002927 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002928 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002929 TB; // [mem8] = <sign bit>
2930def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002931 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002932 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002933 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002934 TB; // GR8 = !<sign bit>
2935def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002936 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002937 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002938 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002939 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002940
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002941def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002942 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002943 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002944 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002945 TB; // GR8 = parity
2946def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002947 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002948 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002949 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002950 TB; // [mem8] = parity
2951def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002952 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002953 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002954 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002955 TB; // GR8 = not parity
2956def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002957 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002958 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002959 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002960 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002961
2962def SETOr : I<0x90, MRM0r,
2963 (outs GR8 :$dst), (ins),
2964 "seto\t$dst",
2965 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2966 TB; // GR8 = overflow
2967def SETOm : I<0x90, MRM0m,
2968 (outs), (ins i8mem:$dst),
2969 "seto\t$dst",
2970 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2971 TB; // [mem8] = overflow
2972def SETNOr : I<0x91, MRM0r,
2973 (outs GR8 :$dst), (ins),
2974 "setno\t$dst",
2975 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2976 TB; // GR8 = not overflow
2977def SETNOm : I<0x91, MRM0m,
2978 (outs), (ins i8mem:$dst),
2979 "setno\t$dst",
2980 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2981 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002982} // Uses = [EFLAGS]
2983
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002984
2985// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002986let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002987def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002988 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002989 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002990 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002991def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002992 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002993 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002994 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002995def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002996 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002997 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002998 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002999def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003000 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003001 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003002 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3003 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003004def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003005 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003006 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003007 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3008 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003009def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003010 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003011 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003012 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3013 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003014def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003015 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003016 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003017 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3018 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003019def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003020 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003021 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003022 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3023 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003024def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003025 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003026 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003027 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3028 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003029def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003030 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003031 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003032 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003033def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003034 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003035 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003036 [(X86cmp GR16:$src1, imm:$src2),
3037 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003038def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003039 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003040 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003041 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003042def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003043 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003044 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003045 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3046 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003047def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003048 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003049 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003050 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3051 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003052def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003053 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003054 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003055 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3056 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003057def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003058 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003059 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003060 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3061 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003062def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003063 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003064 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003065 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3066 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003067def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003068 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003069 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003070 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3071 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003072def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003073 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003074 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003075 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003076 (implicit EFLAGS)]>;
3077} // Defs = [EFLAGS]
3078
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003079// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003080// TODO: BTC, BTR, and BTS
3081let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003082def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003083 "bt{w}\t{$src2, $src1|$src1, $src2}",
3084 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003085 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003086def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003087 "bt{l}\t{$src2, $src1|$src1, $src2}",
3088 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003089 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003090
3091// Unlike with the register+register form, the memory+register form of the
3092// bt instruction does not ignore the high bits of the index. From ISel's
3093// perspective, this is pretty bizarre. Disable these instructions for now.
3094//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3095// "bt{w}\t{$src2, $src1|$src1, $src2}",
3096// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3097// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3098//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3099// "bt{l}\t{$src2, $src1|$src1, $src2}",
3100// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3101// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003102
3103def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3104 "bt{w}\t{$src2, $src1|$src1, $src2}",
3105 [(X86bt GR16:$src1, i16immSExt8:$src2),
3106 (implicit EFLAGS)]>, OpSize, TB;
3107def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3108 "bt{l}\t{$src2, $src1|$src1, $src2}",
3109 [(X86bt GR32:$src1, i32immSExt8:$src2),
3110 (implicit EFLAGS)]>, TB;
3111// Note that these instructions don't need FastBTMem because that
3112// only applies when the other operand is in a register. When it's
3113// an immediate, bt is still fast.
3114def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3115 "bt{w}\t{$src2, $src1|$src1, $src2}",
3116 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3117 (implicit EFLAGS)]>, OpSize, TB;
3118def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3119 "bt{l}\t{$src2, $src1|$src1, $src2}",
3120 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3121 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003122} // Defs = [EFLAGS]
3123
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003124// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003125// Use movsbl intead of movsbw; we don't care about the high 16 bits
3126// of the register here. This has a smaller encoding and avoids a
3127// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003128def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003129 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3130 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003131def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003132 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3133 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003134def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003135 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003136 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003137def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003138 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003139 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003140def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003141 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003142 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003143def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003144 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003145 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3146
Dan Gohman9203ab42008-07-30 18:09:17 +00003147// Use movzbl intead of movzbw; we don't care about the high 16 bits
3148// of the register here. This has a smaller encoding and avoids a
3149// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003150def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003151 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3152 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003153def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003154 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3155 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003156def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003157 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003158 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003159def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003160 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003161 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003162def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003163 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003164 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003165def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003166 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003167 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3168
Dan Gohman744d4622009-04-13 16:09:41 +00003169// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3170// except that they use GR32_NOREX for the output operand register class
3171// instead of GR32. This allows them to operate on h registers on x86-64.
3172def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3173 (outs GR32_NOREX:$dst), (ins GR8:$src),
3174 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3175 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003176let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003177def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3178 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3179 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3180 []>, TB;
3181
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003182let neverHasSideEffects = 1 in {
3183 let Defs = [AX], Uses = [AL] in
3184 def CBW : I<0x98, RawFrm, (outs), (ins),
3185 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3186 let Defs = [EAX], Uses = [AX] in
3187 def CWDE : I<0x98, RawFrm, (outs), (ins),
3188 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003189
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003190 let Defs = [AX,DX], Uses = [AX] in
3191 def CWD : I<0x99, RawFrm, (outs), (ins),
3192 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3193 let Defs = [EAX,EDX], Uses = [EAX] in
3194 def CDQ : I<0x99, RawFrm, (outs), (ins),
3195 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3196}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003197
3198//===----------------------------------------------------------------------===//
3199// Alias Instructions
3200//===----------------------------------------------------------------------===//
3201
3202// Alias instructions that map movr0 to xor.
3203// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003204let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3205 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003206def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003207 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003208 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003209// Use xorl instead of xorw since we don't care about the high 16 bits,
3210// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003211def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003212 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3213 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003214def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003215 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003216 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003217}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003218
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003219//===----------------------------------------------------------------------===//
3220// Thread Local Storage Instructions
3221//
3222
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003223// All calls clobber the non-callee saved registers. ESP is marked as
3224// a use to prevent stack-pointer assignments that appear immediately
3225// before calls from potentially appearing dead.
3226let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3227 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3228 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3229 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003230 Uses = [ESP] in
3231def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3232 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003233 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003234 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003235 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003236
Daniel Dunbar75a07302009-08-11 22:24:40 +00003237let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003238def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3239 "movl\t%gs:$src, $dst",
3240 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3241
Daniel Dunbar75a07302009-08-11 22:24:40 +00003242let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003243def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3244 "movl\t%fs:$src, $dst",
3245 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3246
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003247//===----------------------------------------------------------------------===//
3248// DWARF Pseudo Instructions
3249//
3250
Evan Chengb783fa32007-07-19 01:14:50 +00003251def DWARF_LOC : I<0, Pseudo, (outs),
3252 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Chris Lattner64b54552009-07-10 22:34:11 +00003253 ".loc\t$file $line $col",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003254 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3255 (i32 imm:$file))]>;
3256
3257//===----------------------------------------------------------------------===//
3258// EH Pseudo Instructions
3259//
3260let isTerminator = 1, isReturn = 1, isBarrier = 1,
Daniel Dunbar75513bd2009-08-27 07:58:05 +00003261 hasCtrlDep = 1, isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003262def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003263 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003264 [(X86ehret GR32:$addr)]>;
3265
3266}
3267
3268//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003269// Atomic support
3270//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003271
Evan Cheng3e171562008-04-19 01:20:30 +00003272// Atomic swap. These are just normal xchg instructions. But since a memory
3273// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003274let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003275def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3276 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3277 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3278def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3279 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3280 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3281 OpSize;
3282def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3283 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3284 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3285}
3286
Evan Chengd49dbb82008-04-18 20:55:36 +00003287// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003288let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003289def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003290 "lock\n\t"
3291 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003292 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003293}
Dale Johannesenf160d802008-10-02 18:53:47 +00003294let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003295def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003296 "lock\n\t"
3297 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003298 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3299}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003300
3301let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003302def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003303 "lock\n\t"
3304 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003305 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003306}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003307let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003308def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003309 "lock\n\t"
3310 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003311 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003312}
3313
Evan Chengd49dbb82008-04-18 20:55:36 +00003314// Atomic exchange and add
3315let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3316def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003317 "lock\n\t"
3318 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003319 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003320 TB, LOCK;
3321def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003322 "lock\n\t"
3323 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003324 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003325 TB, OpSize, LOCK;
3326def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003327 "lock\n\t"
3328 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003329 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003330 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003331}
3332
Evan Chengb723fb52009-07-30 08:33:02 +00003333// Optimized codegen when the non-memory output is not used.
3334// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3335def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3336 "lock\n\t"
3337 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3338def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3339 "lock\n\t"
3340 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3341def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3342 "lock\n\t"
3343 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3344def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3345 "lock\n\t"
3346 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3347def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3348 "lock\n\t"
3349 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3350def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3351 "lock\n\t"
3352 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3353def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3354 "lock\n\t"
3355 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3356def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3357 "lock\n\t"
3358 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3359
3360def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3361 "lock\n\t"
3362 "inc{b}\t$dst", []>, LOCK;
3363def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3364 "lock\n\t"
3365 "inc{w}\t$dst", []>, OpSize, LOCK;
3366def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3367 "lock\n\t"
3368 "inc{l}\t$dst", []>, LOCK;
3369
3370def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3371 "lock\n\t"
3372 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3373def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3374 "lock\n\t"
3375 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3376def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3377 "lock\n\t"
3378 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3379def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3380 "lock\n\t"
3381 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3382def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3383 "lock\n\t"
3384 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3385def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3386 "lock\n\t"
3387 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3388def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3389 "lock\n\t"
3390 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3391def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3392 "lock\n\t"
3393 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3394
3395def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3396 "lock\n\t"
3397 "dec{b}\t$dst", []>, LOCK;
3398def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3399 "lock\n\t"
3400 "dec{w}\t$dst", []>, OpSize, LOCK;
3401def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3402 "lock\n\t"
3403 "dec{l}\t$dst", []>, LOCK;
3404
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003405// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003406let Constraints = "$val = $dst", Defs = [EFLAGS],
3407 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003408def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003409 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003410 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003411def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003412 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003413 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003414def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003415 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003416 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003417def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003418 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003419 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003420def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003421 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003422 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003423def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003424 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003425 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003426def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003427 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003428 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003429def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003430 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003431 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003432
3433def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003434 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003435 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003436def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003437 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003438 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003439def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003440 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003441 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003442def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003443 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003444 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003445def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003446 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003447 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003448def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003449 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003450 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003451def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003452 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003453 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003454def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003455 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003456 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003457
3458def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003459 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003460 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003461def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003462 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003463 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003464def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003465 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003466 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003467def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003468 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003469 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003470}
3471
Dale Johannesenf160d802008-10-02 18:53:47 +00003472let Constraints = "$val1 = $dst1, $val2 = $dst2",
3473 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3474 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003475 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003476 usesCustomDAGSchedInserter = 1 in {
3477def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3478 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003479 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003480def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3481 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003482 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003483def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3484 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003485 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003486def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3487 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003488 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003489def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3490 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003491 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003492def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3493 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003494 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003495def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3496 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003497 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003498}
3499
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003500//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003501// Non-Instruction Patterns
3502//===----------------------------------------------------------------------===//
3503
Bill Wendlingfef06052008-09-16 21:48:12 +00003504// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003505def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3506def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003507def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003508def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3509def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3510
3511def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3512 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3513def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3514 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3515def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3516 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3517def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3518 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3519
3520def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3521 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3522def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3523 (MOV32mi addr:$dst, texternalsym:$src)>;
3524
3525// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003526// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003527def : Pat<(X86tcret GR32:$dst, imm:$off),
3528 (TCRETURNri GR32:$dst, imm:$off)>;
3529
3530def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3531 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3532
3533def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3534 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003535
Dan Gohmance5dbff2009-08-02 16:10:01 +00003536// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003537def : Pat<(X86call (i32 tglobaladdr:$dst)),
3538 (CALLpcrel32 tglobaladdr:$dst)>;
3539def : Pat<(X86call (i32 texternalsym:$dst)),
3540 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003541def : Pat<(X86call (i32 imm:$dst)),
3542 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003543
3544// X86 specific add which produces a flag.
3545def : Pat<(addc GR32:$src1, GR32:$src2),
3546 (ADD32rr GR32:$src1, GR32:$src2)>;
3547def : Pat<(addc GR32:$src1, (load addr:$src2)),
3548 (ADD32rm GR32:$src1, addr:$src2)>;
3549def : Pat<(addc GR32:$src1, imm:$src2),
3550 (ADD32ri GR32:$src1, imm:$src2)>;
3551def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3552 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3553
3554def : Pat<(subc GR32:$src1, GR32:$src2),
3555 (SUB32rr GR32:$src1, GR32:$src2)>;
3556def : Pat<(subc GR32:$src1, (load addr:$src2)),
3557 (SUB32rm GR32:$src1, addr:$src2)>;
3558def : Pat<(subc GR32:$src1, imm:$src2),
3559 (SUB32ri GR32:$src1, imm:$src2)>;
3560def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3561 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3562
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003563// Comparisons.
3564
3565// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003566def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003567 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003568def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003569 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003570def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003571 (TEST32rr GR32:$src1, GR32:$src1)>;
3572
Dan Gohman0a3c5222009-01-07 01:00:24 +00003573// Conditional moves with folded loads with operands swapped and conditions
3574// inverted.
3575def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3576 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3577def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3578 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3579def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3580 (CMOVB16rm GR16:$src2, addr:$src1)>;
3581def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3582 (CMOVB32rm GR32:$src2, addr:$src1)>;
3583def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3584 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3585def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3586 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3587def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3588 (CMOVE16rm GR16:$src2, addr:$src1)>;
3589def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3590 (CMOVE32rm GR32:$src2, addr:$src1)>;
3591def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3592 (CMOVA16rm GR16:$src2, addr:$src1)>;
3593def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3594 (CMOVA32rm GR32:$src2, addr:$src1)>;
3595def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3596 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3597def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3598 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3599def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3600 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3601def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3602 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3603def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3604 (CMOVL16rm GR16:$src2, addr:$src1)>;
3605def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3606 (CMOVL32rm GR32:$src2, addr:$src1)>;
3607def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3608 (CMOVG16rm GR16:$src2, addr:$src1)>;
3609def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3610 (CMOVG32rm GR32:$src2, addr:$src1)>;
3611def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3612 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3613def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3614 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3615def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3616 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3617def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3618 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3619def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3620 (CMOVP16rm GR16:$src2, addr:$src1)>;
3621def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3622 (CMOVP32rm GR32:$src2, addr:$src1)>;
3623def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3624 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3625def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3626 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3627def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3628 (CMOVS16rm GR16:$src2, addr:$src1)>;
3629def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3630 (CMOVS32rm GR32:$src2, addr:$src1)>;
3631def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3632 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3633def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3634 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3635def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3636 (CMOVO16rm GR16:$src2, addr:$src1)>;
3637def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3638 (CMOVO32rm GR32:$src2, addr:$src1)>;
3639
Duncan Sands082524c2008-01-23 20:39:46 +00003640// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003641def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3642def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3643def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3644
3645// extload bool -> extload byte
3646def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003647def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003648def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003649def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003650def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3651def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3652
Dan Gohman9959b052009-08-26 14:59:13 +00003653// anyext. Define these to do an explicit zero-extend to
3654// avoid partial-register updates.
3655def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3656def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3657def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003658
Evan Chengf2abee72007-12-13 00:43:27 +00003659// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003660def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3661 (MOVZX32rm8 addr:$src)>;
3662def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3663 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003664
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003665//===----------------------------------------------------------------------===//
3666// Some peepholes
3667//===----------------------------------------------------------------------===//
3668
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003669// Odd encoding trick: -128 fits into an 8-bit immediate field while
3670// +128 doesn't, so in this special case use a sub instead of an add.
3671def : Pat<(add GR16:$src1, 128),
3672 (SUB16ri8 GR16:$src1, -128)>;
3673def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3674 (SUB16mi8 addr:$dst, -128)>;
3675def : Pat<(add GR32:$src1, 128),
3676 (SUB32ri8 GR32:$src1, -128)>;
3677def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3678 (SUB32mi8 addr:$dst, -128)>;
3679
Dan Gohman9203ab42008-07-30 18:09:17 +00003680// r & (2^16-1) ==> movz
3681def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003682 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003683// r & (2^8-1) ==> movz
3684def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003685 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003686 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003687 Requires<[In32BitMode]>;
3688// r & (2^8-1) ==> movz
3689def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003690 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003691 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003692 Requires<[In32BitMode]>;
3693
3694// sext_inreg patterns
3695def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003696 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003697def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003698 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003699 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003700 Requires<[In32BitMode]>;
3701def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003702 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003703 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003704 Requires<[In32BitMode]>;
3705
3706// trunc patterns
3707def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003708 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003709def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003710 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003711 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003712 Requires<[In32BitMode]>;
3713def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003714 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003715 x86_subreg_8bit)>,
3716 Requires<[In32BitMode]>;
3717
3718// h-register tricks
3719def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003720 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003721 x86_subreg_8bit_hi)>,
3722 Requires<[In32BitMode]>;
3723def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003724 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003725 x86_subreg_8bit_hi)>,
3726 Requires<[In32BitMode]>;
3727def : Pat<(srl_su GR16:$src, (i8 8)),
3728 (EXTRACT_SUBREG
3729 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003730 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003731 x86_subreg_8bit_hi)),
3732 x86_subreg_16bit)>,
3733 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003734def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3735 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3736 x86_subreg_8bit_hi))>,
3737 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00003738def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
3739 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3740 x86_subreg_8bit_hi))>,
3741 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003742def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003743 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003744 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003745 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003746
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003747// (shl x, 1) ==> (add x, x)
3748def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3749def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3750def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3751
Evan Cheng76a64c72008-08-30 02:03:58 +00003752// (shl x (and y, 31)) ==> (shl x, y)
3753def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3754 (SHL8rCL GR8:$src1)>;
3755def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3756 (SHL16rCL GR16:$src1)>;
3757def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3758 (SHL32rCL GR32:$src1)>;
3759def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3760 (SHL8mCL addr:$dst)>;
3761def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3762 (SHL16mCL addr:$dst)>;
3763def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3764 (SHL32mCL addr:$dst)>;
3765
3766def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3767 (SHR8rCL GR8:$src1)>;
3768def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3769 (SHR16rCL GR16:$src1)>;
3770def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3771 (SHR32rCL GR32:$src1)>;
3772def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3773 (SHR8mCL addr:$dst)>;
3774def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3775 (SHR16mCL addr:$dst)>;
3776def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3777 (SHR32mCL addr:$dst)>;
3778
3779def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3780 (SAR8rCL GR8:$src1)>;
3781def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3782 (SAR16rCL GR16:$src1)>;
3783def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3784 (SAR32rCL GR32:$src1)>;
3785def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3786 (SAR8mCL addr:$dst)>;
3787def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3788 (SAR16mCL addr:$dst)>;
3789def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3790 (SAR32mCL addr:$dst)>;
3791
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003792// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3793def : Pat<(or (srl GR32:$src1, CL:$amt),
3794 (shl GR32:$src2, (sub 32, CL:$amt))),
3795 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3796
3797def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3798 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3799 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3800
Dan Gohman921581d2008-10-17 01:23:35 +00003801def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3802 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3803 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3804
3805def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3806 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3807 addr:$dst),
3808 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3809
3810def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3811 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3812
3813def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3814 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3815 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3816
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003817// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3818def : Pat<(or (shl GR32:$src1, CL:$amt),
3819 (srl GR32:$src2, (sub 32, CL:$amt))),
3820 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3821
3822def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3823 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3824 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3825
Dan Gohman921581d2008-10-17 01:23:35 +00003826def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3827 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3828 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3829
3830def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3831 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3832 addr:$dst),
3833 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3834
3835def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3836 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3837
3838def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3839 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3840 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3841
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003842// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3843def : Pat<(or (srl GR16:$src1, CL:$amt),
3844 (shl GR16:$src2, (sub 16, CL:$amt))),
3845 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3846
3847def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3848 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3849 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3850
Dan Gohman921581d2008-10-17 01:23:35 +00003851def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3852 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3853 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3854
3855def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3856 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3857 addr:$dst),
3858 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3859
3860def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3861 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3862
3863def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3864 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3865 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3866
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003867// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3868def : Pat<(or (shl GR16:$src1, CL:$amt),
3869 (srl GR16:$src2, (sub 16, CL:$amt))),
3870 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3871
3872def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3873 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3874 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3875
Dan Gohman921581d2008-10-17 01:23:35 +00003876def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3877 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3878 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3879
3880def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3881 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3882 addr:$dst),
3883 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3884
3885def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3886 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3887
3888def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3889 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3890 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3891
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003892//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003893// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003894//===----------------------------------------------------------------------===//
3895
Dan Gohman99a12192009-03-04 19:44:21 +00003896// Register-Register Addition with EFLAGS result
3897def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003898 (implicit EFLAGS)),
3899 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003900def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003901 (implicit EFLAGS)),
3902 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003903def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003904 (implicit EFLAGS)),
3905 (ADD32rr GR32:$src1, GR32:$src2)>;
3906
Dan Gohman99a12192009-03-04 19:44:21 +00003907// Register-Memory Addition with EFLAGS result
3908def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003909 (implicit EFLAGS)),
3910 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003911def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003912 (implicit EFLAGS)),
3913 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003914def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003915 (implicit EFLAGS)),
3916 (ADD32rm GR32:$src1, addr:$src2)>;
3917
Dan Gohman99a12192009-03-04 19:44:21 +00003918// Register-Integer Addition with EFLAGS result
3919def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003920 (implicit EFLAGS)),
3921 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003922def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003923 (implicit EFLAGS)),
3924 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003925def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003926 (implicit EFLAGS)),
3927 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003928def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003929 (implicit EFLAGS)),
3930 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003931def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003932 (implicit EFLAGS)),
3933 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3934
Dan Gohman99a12192009-03-04 19:44:21 +00003935// Memory-Register Addition with EFLAGS result
3936def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003937 addr:$dst),
3938 (implicit EFLAGS)),
3939 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003940def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003941 addr:$dst),
3942 (implicit EFLAGS)),
3943 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003944def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003945 addr:$dst),
3946 (implicit EFLAGS)),
3947 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003948
3949// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003950def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003951 addr:$dst),
3952 (implicit EFLAGS)),
3953 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003954def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003955 addr:$dst),
3956 (implicit EFLAGS)),
3957 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003958def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003959 addr:$dst),
3960 (implicit EFLAGS)),
3961 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003962def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003963 addr:$dst),
3964 (implicit EFLAGS)),
3965 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003966def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003967 addr:$dst),
3968 (implicit EFLAGS)),
3969 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3970
Dan Gohman99a12192009-03-04 19:44:21 +00003971// Register-Register Subtraction with EFLAGS result
3972def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003973 (implicit EFLAGS)),
3974 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003975def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003976 (implicit EFLAGS)),
3977 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003978def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003979 (implicit EFLAGS)),
3980 (SUB32rr GR32:$src1, GR32:$src2)>;
3981
Dan Gohman99a12192009-03-04 19:44:21 +00003982// Register-Memory Subtraction with EFLAGS result
3983def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003984 (implicit EFLAGS)),
3985 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003986def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003987 (implicit EFLAGS)),
3988 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003989def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003990 (implicit EFLAGS)),
3991 (SUB32rm GR32:$src1, addr:$src2)>;
3992
Dan Gohman99a12192009-03-04 19:44:21 +00003993// Register-Integer Subtraction with EFLAGS result
3994def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003995 (implicit EFLAGS)),
3996 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003997def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003998 (implicit EFLAGS)),
3999 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004000def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004001 (implicit EFLAGS)),
4002 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004003def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004004 (implicit EFLAGS)),
4005 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004006def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004007 (implicit EFLAGS)),
4008 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4009
Dan Gohman99a12192009-03-04 19:44:21 +00004010// Memory-Register Subtraction with EFLAGS result
4011def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004012 addr:$dst),
4013 (implicit EFLAGS)),
4014 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004015def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004016 addr:$dst),
4017 (implicit EFLAGS)),
4018 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004019def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004020 addr:$dst),
4021 (implicit EFLAGS)),
4022 (SUB32mr addr:$dst, GR32:$src2)>;
4023
Dan Gohman99a12192009-03-04 19:44:21 +00004024// Memory-Integer Subtraction with EFLAGS result
4025def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004026 addr:$dst),
4027 (implicit EFLAGS)),
4028 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004029def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004030 addr:$dst),
4031 (implicit EFLAGS)),
4032 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004033def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004034 addr:$dst),
4035 (implicit EFLAGS)),
4036 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004037def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004038 addr:$dst),
4039 (implicit EFLAGS)),
4040 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004041def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004042 addr:$dst),
4043 (implicit EFLAGS)),
4044 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4045
4046
Dan Gohman99a12192009-03-04 19:44:21 +00004047// Register-Register Signed Integer Multiply with EFLAGS result
4048def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004049 (implicit EFLAGS)),
4050 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004051def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004052 (implicit EFLAGS)),
4053 (IMUL32rr GR32:$src1, GR32:$src2)>;
4054
Dan Gohman99a12192009-03-04 19:44:21 +00004055// Register-Memory Signed Integer Multiply with EFLAGS result
4056def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004057 (implicit EFLAGS)),
4058 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004059def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004060 (implicit EFLAGS)),
4061 (IMUL32rm GR32:$src1, addr:$src2)>;
4062
Dan Gohman99a12192009-03-04 19:44:21 +00004063// Register-Integer Signed Integer Multiply with EFLAGS result
4064def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004065 (implicit EFLAGS)),
4066 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004067def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004068 (implicit EFLAGS)),
4069 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004070def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004071 (implicit EFLAGS)),
4072 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004073def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004074 (implicit EFLAGS)),
4075 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4076
Dan Gohman99a12192009-03-04 19:44:21 +00004077// Memory-Integer Signed Integer Multiply with EFLAGS result
4078def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004079 (implicit EFLAGS)),
4080 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004081def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004082 (implicit EFLAGS)),
4083 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004084def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004085 (implicit EFLAGS)),
4086 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004087def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004088 (implicit EFLAGS)),
4089 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4090
Dan Gohman99a12192009-03-04 19:44:21 +00004091// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004092let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004093def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004094 (implicit EFLAGS)),
4095 (ADD16rr GR16:$src1, GR16:$src1)>;
4096
Dan Gohman99a12192009-03-04 19:44:21 +00004097def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004098 (implicit EFLAGS)),
4099 (ADD32rr GR32:$src1, GR32:$src1)>;
4100}
4101
Dan Gohman99a12192009-03-04 19:44:21 +00004102// INC and DEC with EFLAGS result. Note that these do not set CF.
4103def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4104 (INC8r GR8:$src)>;
4105def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4106 (implicit EFLAGS)),
4107 (INC8m addr:$dst)>;
4108def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4109 (DEC8r GR8:$src)>;
4110def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4111 (implicit EFLAGS)),
4112 (DEC8m addr:$dst)>;
4113
4114def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004115 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004116def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4117 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004118 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004119def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004120 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004121def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4122 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004123 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004124
4125def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004126 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004127def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4128 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004129 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004130def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004131 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004132def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4133 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004134 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004135
Bill Wendlingf5399032008-12-12 21:15:41 +00004136//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004137// Floating Point Stack Support
4138//===----------------------------------------------------------------------===//
4139
4140include "X86InstrFPStack.td"
4141
4142//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00004143// X86-64 Support
4144//===----------------------------------------------------------------------===//
4145
Chris Lattner2de8d2b2008-01-10 05:50:42 +00004146include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00004147
4148//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004149// XMM Floating point support (requires SSE / SSE2)
4150//===----------------------------------------------------------------------===//
4151
4152include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00004153
4154//===----------------------------------------------------------------------===//
4155// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4156//===----------------------------------------------------------------------===//
4157
4158include "X86InstrMMX.td"