blob: 15235d086bb51bf643f2055559dea6fe5ec6b723 [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 {
Evan Cheng926658c2007-10-05 23:13:21 +00001037let isCommutable = 1 in {
Dan Gohman29b998f2009-08-27 00:14:12 +00001038
1039// X86 doesn't have 8-bit conditional moves. Use a customDAGSchedInserter to
1040// emit control flow. An alternative to this is to mark i8 SELECT as Promote,
1041// however that requires promoting the operands, and can induce additional
1042// i8 register pressure.
1043let usesCustomDAGSchedInserter = 1 in
1044def CMOV_GR8 : I<0, Pseudo,
1045 (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond),
1046 "#CMOV_GR8 PSEUDO!",
1047 [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2,
1048 imm:$cond, EFLAGS))]>;
1049
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001051 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001052 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001054 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001057 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001058 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001060 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001063 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001064 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001066 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001069 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001070 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001072 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001075 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001076 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001078 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001080def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001081 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001082 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001084 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001087 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001088 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001090 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001092def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001093 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001094 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001096 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001099 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001100 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001101 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001102 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001103 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001105 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001106 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001107 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001108 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001110def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001111 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001112 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001114 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001116def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001117 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001118 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001120 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001123 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001124 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001125 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001126 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001127 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001128def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001129 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001130 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001131 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001132 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001134def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001135 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001136 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001138 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001141 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001142 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001144 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001147 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001148 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001149 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001150 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001153 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001154 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001155 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001156 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001157 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001159 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001160 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001162 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001163 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001165 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001166 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001167 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001168 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001171 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001172 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001173 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001174 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001176def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001177 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001178 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001180 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001183 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001184 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001186 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001187 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001189 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001190 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001191 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001192 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001195 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001196 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001197 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001198 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001199 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001201 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001202 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001203 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001204 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001207 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001208 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001209 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001210 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001212def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001213 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001214 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001216 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001217 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001218def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1219 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1220 "cmovo\t{$src2, $dst|$dst, $src2}",
1221 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1222 X86_COND_O, EFLAGS))]>,
1223 TB, OpSize;
1224def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1225 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1226 "cmovo\t{$src2, $dst|$dst, $src2}",
1227 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1228 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001229 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001230def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1231 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1232 "cmovno\t{$src2, $dst|$dst, $src2}",
1233 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1234 X86_COND_NO, EFLAGS))]>,
1235 TB, OpSize;
1236def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1237 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1238 "cmovno\t{$src2, $dst|$dst, $src2}",
1239 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1240 X86_COND_NO, EFLAGS))]>,
1241 TB;
1242} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001243
1244def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1245 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1246 "cmovb\t{$src2, $dst|$dst, $src2}",
1247 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1248 X86_COND_B, EFLAGS))]>,
1249 TB, OpSize;
1250def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1251 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1252 "cmovb\t{$src2, $dst|$dst, $src2}",
1253 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1254 X86_COND_B, EFLAGS))]>,
1255 TB;
1256def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1257 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1258 "cmovae\t{$src2, $dst|$dst, $src2}",
1259 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1260 X86_COND_AE, EFLAGS))]>,
1261 TB, OpSize;
1262def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1263 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1264 "cmovae\t{$src2, $dst|$dst, $src2}",
1265 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1266 X86_COND_AE, EFLAGS))]>,
1267 TB;
1268def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1269 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1270 "cmove\t{$src2, $dst|$dst, $src2}",
1271 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1272 X86_COND_E, EFLAGS))]>,
1273 TB, OpSize;
1274def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1275 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1276 "cmove\t{$src2, $dst|$dst, $src2}",
1277 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1278 X86_COND_E, EFLAGS))]>,
1279 TB;
1280def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1281 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1282 "cmovne\t{$src2, $dst|$dst, $src2}",
1283 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1284 X86_COND_NE, EFLAGS))]>,
1285 TB, OpSize;
1286def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1287 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1288 "cmovne\t{$src2, $dst|$dst, $src2}",
1289 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1290 X86_COND_NE, EFLAGS))]>,
1291 TB;
1292def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1293 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1294 "cmovbe\t{$src2, $dst|$dst, $src2}",
1295 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1296 X86_COND_BE, EFLAGS))]>,
1297 TB, OpSize;
1298def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1299 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1300 "cmovbe\t{$src2, $dst|$dst, $src2}",
1301 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1302 X86_COND_BE, EFLAGS))]>,
1303 TB;
1304def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1305 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1306 "cmova\t{$src2, $dst|$dst, $src2}",
1307 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1308 X86_COND_A, EFLAGS))]>,
1309 TB, OpSize;
1310def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1311 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1312 "cmova\t{$src2, $dst|$dst, $src2}",
1313 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1314 X86_COND_A, EFLAGS))]>,
1315 TB;
1316def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1317 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1318 "cmovl\t{$src2, $dst|$dst, $src2}",
1319 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1320 X86_COND_L, EFLAGS))]>,
1321 TB, OpSize;
1322def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1323 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1324 "cmovl\t{$src2, $dst|$dst, $src2}",
1325 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1326 X86_COND_L, EFLAGS))]>,
1327 TB;
1328def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1329 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1330 "cmovge\t{$src2, $dst|$dst, $src2}",
1331 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1332 X86_COND_GE, EFLAGS))]>,
1333 TB, OpSize;
1334def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1335 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1336 "cmovge\t{$src2, $dst|$dst, $src2}",
1337 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1338 X86_COND_GE, EFLAGS))]>,
1339 TB;
1340def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1341 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1342 "cmovle\t{$src2, $dst|$dst, $src2}",
1343 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1344 X86_COND_LE, EFLAGS))]>,
1345 TB, OpSize;
1346def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1347 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1348 "cmovle\t{$src2, $dst|$dst, $src2}",
1349 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1350 X86_COND_LE, EFLAGS))]>,
1351 TB;
1352def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1353 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1354 "cmovg\t{$src2, $dst|$dst, $src2}",
1355 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1356 X86_COND_G, EFLAGS))]>,
1357 TB, OpSize;
1358def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1359 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1360 "cmovg\t{$src2, $dst|$dst, $src2}",
1361 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1362 X86_COND_G, EFLAGS))]>,
1363 TB;
1364def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1365 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1366 "cmovs\t{$src2, $dst|$dst, $src2}",
1367 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1368 X86_COND_S, EFLAGS))]>,
1369 TB, OpSize;
1370def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1371 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1372 "cmovs\t{$src2, $dst|$dst, $src2}",
1373 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1374 X86_COND_S, EFLAGS))]>,
1375 TB;
1376def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1377 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1378 "cmovns\t{$src2, $dst|$dst, $src2}",
1379 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1380 X86_COND_NS, EFLAGS))]>,
1381 TB, OpSize;
1382def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1383 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1384 "cmovns\t{$src2, $dst|$dst, $src2}",
1385 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1386 X86_COND_NS, EFLAGS))]>,
1387 TB;
1388def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1389 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1390 "cmovp\t{$src2, $dst|$dst, $src2}",
1391 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1392 X86_COND_P, EFLAGS))]>,
1393 TB, OpSize;
1394def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1395 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1396 "cmovp\t{$src2, $dst|$dst, $src2}",
1397 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1398 X86_COND_P, EFLAGS))]>,
1399 TB;
1400def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1401 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1402 "cmovnp\t{$src2, $dst|$dst, $src2}",
1403 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1404 X86_COND_NP, EFLAGS))]>,
1405 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001406def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1407 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1408 "cmovnp\t{$src2, $dst|$dst, $src2}",
1409 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1410 X86_COND_NP, EFLAGS))]>,
1411 TB;
1412def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1413 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1414 "cmovo\t{$src2, $dst|$dst, $src2}",
1415 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1416 X86_COND_O, EFLAGS))]>,
1417 TB, OpSize;
1418def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1419 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1420 "cmovo\t{$src2, $dst|$dst, $src2}",
1421 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1422 X86_COND_O, EFLAGS))]>,
1423 TB;
1424def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1425 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1426 "cmovno\t{$src2, $dst|$dst, $src2}",
1427 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1428 X86_COND_NO, EFLAGS))]>,
1429 TB, OpSize;
1430def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1431 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1432 "cmovno\t{$src2, $dst|$dst, $src2}",
1433 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1434 X86_COND_NO, EFLAGS))]>,
1435 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001436} // Uses = [EFLAGS]
1437
1438
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001439// unary instructions
1440let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001441let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001442def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001443 [(set GR8:$dst, (ineg GR8:$src)),
1444 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001445def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001446 [(set GR16:$dst, (ineg GR16:$src)),
1447 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001448def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001449 [(set GR32:$dst, (ineg GR32:$src)),
1450 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001452 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001453 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1454 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001455 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001456 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1457 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001458 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001459 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1460 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001461}
Evan Cheng55687072007-09-14 21:48:26 +00001462} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001463
Evan Chengc6cee682009-01-21 02:09:05 +00001464// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1465let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001466def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001468def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001469 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001470def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001472}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001474 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001475 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001476 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001477 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001478 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001479 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1480}
1481} // CodeSize
1482
1483// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001484let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001485let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001486def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001487 [(set GR8:$dst, (add GR8:$src, 1)),
1488 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001490def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001491 [(set GR16:$dst, (add GR16:$src, 1)),
1492 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001493 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001494def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001495 [(set GR32:$dst, (add GR32:$src, 1)),
1496 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001497}
1498let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001499 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001500 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1501 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001502 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001503 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1504 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001505 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001506 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001507 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1508 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001509 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001510}
1511
1512let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001513def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001514 [(set GR8:$dst, (add GR8:$src, -1)),
1515 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001517def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001518 [(set GR16:$dst, (add GR16:$src, -1)),
1519 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001520 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001521def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001522 [(set GR32:$dst, (add GR32:$src, -1)),
1523 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524}
1525
1526let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001527 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001528 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1529 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001530 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001531 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1532 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001533 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001534 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001535 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1536 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001537 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001538}
Evan Cheng55687072007-09-14 21:48:26 +00001539} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540
1541// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001542let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1544def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001545 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001546 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001547 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1548 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001549def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001550 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001552 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1553 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001555 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001557 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1558 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001559}
1560
1561def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001562 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001563 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001564 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001565 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001566def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001567 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001568 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001569 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001570 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001571def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001572 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001573 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001574 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001575 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001576
1577def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001578 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001579 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001580 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1581 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001582def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001583 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001584 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001585 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1586 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001587def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001588 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001589 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001590 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1591 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001592def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001593 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001594 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001595 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1596 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001597 OpSize;
1598def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001599 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001600 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001601 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1602 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603
1604let isTwoAddress = 0 in {
1605 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001606 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001607 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001608 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1609 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001610 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001611 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001612 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001613 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1614 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615 OpSize;
1616 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001617 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001618 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001619 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1620 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001621 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001622 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001623 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001624 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1625 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001626 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001627 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001629 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1630 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631 OpSize;
1632 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001633 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001634 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001635 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1636 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001637 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001638 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001639 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001640 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1641 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642 OpSize;
1643 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001644 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001645 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001646 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1647 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648}
1649
1650
1651let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001652def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001653 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001654 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1655 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001656def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001657 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001658 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1659 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001660def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001661 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001662 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1663 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001664}
Evan Chengb783fa32007-07-19 01:14:50 +00001665def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001666 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001667 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1668 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001669def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001670 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001671 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1672 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001673def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001675 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1676 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677
Evan Chengb783fa32007-07-19 01:14:50 +00001678def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001679 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001680 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1681 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001682def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001684 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1685 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001686def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001687 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001688 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1689 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001690
Evan Chengb783fa32007-07-19 01:14:50 +00001691def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001692 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001693 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1694 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001695def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001696 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001697 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1698 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001700 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001701 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001702 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1703 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001704 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001705 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001706 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1707 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001708 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001710 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1711 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001712 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001713 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001714 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1715 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001716 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001717 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001718 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1719 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001720 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001721 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001722 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001723 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1724 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001725 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001726 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001727 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1728 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001729 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001730 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001731 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001732 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1733 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001734} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001735
1736
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001737let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001738 def XOR8rr : I<0x30, MRMDestReg,
1739 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1740 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001741 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1742 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001743 def XOR16rr : I<0x31, MRMDestReg,
1744 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1745 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001746 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1747 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001748 def XOR32rr : I<0x31, MRMDestReg,
1749 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1750 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001751 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1752 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001753} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001754
1755def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001756 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001757 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001758 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1759 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001760def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001761 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001762 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001763 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1764 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001765 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001767 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001769 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1770 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001771
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001772def XOR8ri : Ii8<0x80, MRM6r,
1773 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1774 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001775 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1776 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001777def XOR16ri : Ii16<0x81, MRM6r,
1778 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1779 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001780 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1781 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001782def XOR32ri : Ii32<0x81, MRM6r,
1783 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1784 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001785 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1786 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001787def XOR16ri8 : Ii8<0x83, MRM6r,
1788 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1789 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001790 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1791 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001792 OpSize;
1793def XOR32ri8 : Ii8<0x83, MRM6r,
1794 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1795 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001796 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1797 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001798
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799let isTwoAddress = 0 in {
1800 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001801 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001802 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001803 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1804 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001805 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001806 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001808 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1809 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810 OpSize;
1811 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001812 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001814 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1815 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001817 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001818 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001819 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1820 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001822 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001823 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001824 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1825 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826 OpSize;
1827 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001828 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001830 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1831 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001833 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001834 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001835 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1836 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 OpSize;
1838 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001839 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001840 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001841 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1842 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001843} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001844} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845
1846// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001847let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001848let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001849def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001850 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001851 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001852def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001853 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001854 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001855def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001856 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001857 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001858} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001859
Evan Chengb783fa32007-07-19 01:14:50 +00001860def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1863let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001864def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001865 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001867def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001868 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001870// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1871// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001872} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001873
1874let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001875 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001876 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001877 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001878 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001879 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001880 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001881 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001882 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001883 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001884 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1885 }
Evan Chengb783fa32007-07-19 01:14:50 +00001886 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001889 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1892 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001893 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1896
1897 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001898 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001900 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001901 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1904 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001905 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1908}
1909
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001910let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001911def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001912 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001913 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001914def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001915 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001916 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001917def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001918 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001919 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1920}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001921
Evan Chengb783fa32007-07-19 01:14:50 +00001922def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001923 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001924 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001925def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001926 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001928def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001930 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1931
1932// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001933def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001935 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001936def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001937 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001938 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001939def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001941 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1942
1943let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001944 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001945 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001946 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001947 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001948 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001949 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001951 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001952 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001953 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001954 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1955 }
Evan Chengb783fa32007-07-19 01:14:50 +00001956 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001959 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001960 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1962 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001963 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001964 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001965 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1966
1967 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001968 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001969 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001971 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001972 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001974 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1977}
1978
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001979let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001980def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001981 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001982 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001983def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001984 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001985 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001986def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001987 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001988 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1989}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001990
Evan Chengb783fa32007-07-19 01:14:50 +00001991def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001992 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001994def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1997 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001998def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001999 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002000 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
2001
2002// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002003def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002006def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002007 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002008 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002009def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002010 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2012
2013let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002014 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002015 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002016 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002017 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002018 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002019 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002020 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002021 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002022 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002023 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2024 }
Evan Chengb783fa32007-07-19 01:14:50 +00002025 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002026 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002028 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002029 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2031 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002032 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2035
2036 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002037 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002040 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002041 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002042 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2043 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002044 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2047}
2048
2049// Rotate instructions
2050// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002051let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002052def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002053 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002054 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002055def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002056 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002057 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002058def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002059 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002060 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2061}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002062
Evan Chengb783fa32007-07-19 01:14:50 +00002063def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002066def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002067 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002068 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002069def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002070 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2072
2073// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002074def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002075 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002076 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002077def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002079 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002080def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002081 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2083
2084let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002085 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002086 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002087 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002088 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002089 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002090 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002091 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002092 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002093 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002094 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2095 }
Evan Chengb783fa32007-07-19 01:14:50 +00002096 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002097 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002099 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002100 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002101 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2102 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002103 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002104 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002105 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2106
2107 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002108 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002109 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002110 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002111 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002112 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2114 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002115 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002116 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002117 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2118}
2119
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002120let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002121def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002122 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002123 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002124def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002125 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002126 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002127def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002128 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002129 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2130}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002131
Evan Chengb783fa32007-07-19 01:14:50 +00002132def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002135def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002136 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002138def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002139 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002140 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2141
2142// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002143def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002144 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002145 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002146def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002149def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002150 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2152
2153let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002154 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002155 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002156 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002157 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002158 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002159 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002160 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002161 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002162 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002163 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2164 }
Evan Chengb783fa32007-07-19 01:14:50 +00002165 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002166 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002168 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002169 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002170 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2171 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002172 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002173 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2175
2176 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002177 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002178 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002180 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002181 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2183 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002184 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2187}
2188
2189
2190
2191// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002192let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002193def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002194 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002195 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002196def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002197 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002198 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002199def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002200 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002201 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002202 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002203def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002204 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002205 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002206 TB, OpSize;
2207}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002208
2209let isCommutable = 1 in { // These instructions commute to each other.
2210def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002211 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002212 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002213 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2214 (i8 imm:$src3)))]>,
2215 TB;
2216def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002217 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002219 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2220 (i8 imm:$src3)))]>,
2221 TB;
2222def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002223 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002224 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002225 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2226 (i8 imm:$src3)))]>,
2227 TB, OpSize;
2228def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002229 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002231 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2232 (i8 imm:$src3)))]>,
2233 TB, OpSize;
2234}
2235
2236let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002237 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002238 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002239 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002240 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002241 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002242 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002243 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002244 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002245 addr:$dst)]>, TB;
2246 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002247 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002248 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002249 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002250 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2251 (i8 imm:$src3)), addr:$dst)]>,
2252 TB;
2253 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002254 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002255 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002256 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2257 (i8 imm:$src3)), addr:$dst)]>,
2258 TB;
2259
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002260 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002261 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002262 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002264 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002265 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002266 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002268 addr:$dst)]>, TB, OpSize;
2269 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002270 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002271 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002272 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2274 (i8 imm:$src3)), addr:$dst)]>,
2275 TB, OpSize;
2276 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002277 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002278 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002279 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2280 (i8 imm:$src3)), addr:$dst)]>,
2281 TB, OpSize;
2282}
Evan Cheng55687072007-09-14 21:48:26 +00002283} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002284
2285
2286// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002287let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002288let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002289// Register-Register Addition
2290def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2291 (ins GR8 :$src1, GR8 :$src2),
2292 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002293 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002294 (implicit EFLAGS)]>;
2295
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002296let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002297// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002298def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2299 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002300 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002301 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2302 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002303def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2304 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002305 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002306 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2307 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002308} // end isConvertibleToThreeAddress
2309} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002310
2311// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002312def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2313 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002314 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002315 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2316 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002317def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2318 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002319 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002320 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2321 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002322def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2323 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002324 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002325 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2326 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327
Bill Wendlingae034ed2008-12-12 00:56:36 +00002328// Register-Integer Addition
2329def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2330 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002331 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2332 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002333
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002334let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002335// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002336def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2337 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002338 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002339 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2340 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002341def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2342 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002343 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002344 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2345 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002346def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2347 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002348 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002349 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2350 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002351def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2352 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002353 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002354 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2355 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356}
2357
2358let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002359 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002360 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002361 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002362 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2363 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002364 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002365 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002366 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2367 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002368 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002369 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002370 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2371 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002372 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002373 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002374 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2375 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002376 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002377 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002378 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2379 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002380 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002381 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002382 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2383 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002384 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002385 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002386 [(store (add (load addr:$dst), i16immSExt8:$src2),
2387 addr:$dst),
2388 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002389 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002390 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002391 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002392 addr:$dst),
2393 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002394
2395 // addition to rAX
2396 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2397 "add\t{$src, %al|%al, $src}", []>;
2398 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2399 "add\t{$src, %ax|%ax, $src}", []>, OpSize;
2400 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2401 "add\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002402}
2403
Evan Cheng259471d2007-10-05 17:59:57 +00002404let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002405let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002406def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002407 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002408 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002409def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2410 (ins GR16:$src1, GR16:$src2),
2411 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002412 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002413def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2414 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002415 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002416 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002417}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002418def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2419 (ins GR8:$src1, i8mem:$src2),
2420 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002421 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002422def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2423 (ins GR16:$src1, i16mem:$src2),
2424 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002425 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002426 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002427def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2428 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002429 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002430 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2431def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002432 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002433 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002434def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2435 (ins GR16:$src1, i16imm:$src2),
2436 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002437 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002438def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2439 (ins GR16:$src1, i16i8imm:$src2),
2440 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002441 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2442 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002443def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2444 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002445 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002446 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002447def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2448 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002449 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002450 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002451
2452let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002453 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002454 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002455 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2456 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002457 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002458 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2459 OpSize;
2460 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002461 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002462 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2463 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002464 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002465 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2466 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002467 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002468 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2469 OpSize;
2470 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002471 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002472 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2473 OpSize;
2474 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002475 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002476 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2477 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002478 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002479 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2480}
Evan Cheng259471d2007-10-05 17:59:57 +00002481} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002482
Bill Wendlingae034ed2008-12-12 00:56:36 +00002483// Register-Register Subtraction
2484def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2485 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002486 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2487 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002488def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2489 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002490 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2491 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002492def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2493 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002494 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2495 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002496
2497// Register-Memory Subtraction
2498def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2499 (ins GR8 :$src1, i8mem :$src2),
2500 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002501 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2502 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002503def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2504 (ins GR16:$src1, i16mem:$src2),
2505 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002506 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2507 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002508def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2509 (ins GR32:$src1, i32mem:$src2),
2510 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002511 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2512 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002513
2514// Register-Integer Subtraction
2515def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2516 (ins GR8:$src1, i8imm:$src2),
2517 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002518 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2519 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002520def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2521 (ins GR16:$src1, i16imm:$src2),
2522 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002523 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2524 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002525def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2526 (ins GR32:$src1, i32imm:$src2),
2527 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002528 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2529 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002530def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2531 (ins GR16:$src1, i16i8imm:$src2),
2532 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002533 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2534 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002535def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2536 (ins GR32:$src1, i32i8imm:$src2),
2537 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002538 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2539 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002540
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002541let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002542 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002543 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002544 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002545 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2546 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002547 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002548 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002549 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2550 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002551 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002552 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002553 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2554 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002555
2556 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002557 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002558 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002559 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2560 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002561 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002562 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002563 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2564 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002565 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002566 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002567 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2568 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002569 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002570 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002571 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002572 addr:$dst),
2573 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002574 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002575 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002576 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002577 addr:$dst),
2578 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002579}
2580
Evan Cheng259471d2007-10-05 17:59:57 +00002581let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002582def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2583 (ins GR8:$src1, GR8:$src2),
2584 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002585 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002586def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2587 (ins GR16:$src1, GR16:$src2),
2588 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002589 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002590def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2591 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002592 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002593 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002594
2595let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002596 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2597 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002598 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002599 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2600 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002601 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002602 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002603 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002604 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002605 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002606 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002607 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002608 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002609 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2610 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002611 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002612 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002613 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2614 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002615 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002616 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002617 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002618 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002619 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002620 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002621 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002622 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002623}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002624def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2625 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002626 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002627def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2628 (ins GR16:$src1, i16mem:$src2),
2629 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002630 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002631 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002632def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2633 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002634 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002635 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002636def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2637 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002638 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002639def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2640 (ins GR16:$src1, i16imm:$src2),
2641 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002642 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002643def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2644 (ins GR16:$src1, i16i8imm:$src2),
2645 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002646 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2647 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002648def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2649 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002650 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002651 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002652def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2653 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002654 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002655 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002656} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002657} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002658
Evan Cheng55687072007-09-14 21:48:26 +00002659let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002660let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002661// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002662def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002663 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002664 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2665 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002666def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002667 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002668 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2669 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002670}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002671
Bill Wendlingf5399032008-12-12 21:15:41 +00002672// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002673def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2674 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002675 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002676 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2677 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002678def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002679 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002680 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2681 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002682} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002683} // end Two Address instructions
2684
2685// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002686let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002687// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002688def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002689 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002690 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002691 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2692 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002693def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002694 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002695 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002696 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2697 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002698def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002699 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002700 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002701 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2702 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002703def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002704 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002705 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002706 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2707 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002708
Bill Wendlingf5399032008-12-12 21:15:41 +00002709// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002710def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002711 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002712 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002713 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2714 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002715def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002716 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002717 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002718 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2719 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002720def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002721 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002722 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002723 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002724 i16immSExt8:$src2)),
2725 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002726def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002727 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002728 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002729 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002730 i32immSExt8:$src2)),
2731 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002732} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002733
2734//===----------------------------------------------------------------------===//
2735// Test instructions are just like AND, except they don't generate a result.
2736//
Evan Cheng950aac02007-09-25 01:57:46 +00002737let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002738let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002739def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002740 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002741 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002742 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002743def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002744 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002745 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002746 (implicit EFLAGS)]>,
2747 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002748def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002749 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002750 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002751 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002752}
2753
Evan Chengb783fa32007-07-19 01:14:50 +00002754def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002755 "test{b}\t{$src2, $src1|$src1, $src2}",
2756 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2757 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002758def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002759 "test{w}\t{$src2, $src1|$src1, $src2}",
2760 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2761 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002762def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002763 "test{l}\t{$src2, $src1|$src1, $src2}",
2764 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2765 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002766
2767def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002768 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002769 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002770 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002771 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002772def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002773 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002774 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002775 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002776 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002777def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002778 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002779 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002780 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002781 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002782
Evan Cheng621216e2007-09-29 00:00:36 +00002783def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002784 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002785 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002786 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2787 (implicit EFLAGS)]>;
2788def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002789 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002790 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002791 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2792 (implicit EFLAGS)]>, OpSize;
2793def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002794 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002795 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002796 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002797 (implicit EFLAGS)]>;
2798} // Defs = [EFLAGS]
2799
2800
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002801// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002802let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002803def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002804let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002805def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002806
Evan Cheng950aac02007-09-25 01:57:46 +00002807let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002808def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002809 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002810 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002811 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002812 TB; // GR8 = ==
2813def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002814 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002815 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002816 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002817 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002818
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002819def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002820 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002821 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002822 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002823 TB; // GR8 = !=
2824def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002825 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002826 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002827 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002828 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002829
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002830def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002831 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002832 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002833 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002834 TB; // GR8 = < signed
2835def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002836 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002837 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002838 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002839 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002840
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002841def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002842 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002843 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002844 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002845 TB; // GR8 = >= signed
2846def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002847 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002848 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002849 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002850 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002851
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002852def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002853 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002854 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002855 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002856 TB; // GR8 = <= signed
2857def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002858 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002859 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002860 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002861 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002862
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002863def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002864 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002865 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002866 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002867 TB; // GR8 = > signed
2868def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002869 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002870 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002871 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002872 TB; // [mem8] = > signed
2873
2874def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002875 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002876 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002877 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002878 TB; // GR8 = < unsign
2879def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002880 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002881 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002882 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002884
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002885def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002886 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002887 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002888 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002889 TB; // GR8 = >= unsign
2890def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002891 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002892 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002893 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002894 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002895
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002896def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002897 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002898 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002899 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002900 TB; // GR8 = <= unsign
2901def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002902 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002903 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002904 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002905 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002906
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002907def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002908 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002909 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002910 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002911 TB; // GR8 = > signed
2912def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002913 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002914 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002915 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002916 TB; // [mem8] = > signed
2917
2918def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002919 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002920 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002921 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002922 TB; // GR8 = <sign bit>
2923def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002924 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002925 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002926 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002927 TB; // [mem8] = <sign bit>
2928def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002929 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002930 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002931 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002932 TB; // GR8 = !<sign bit>
2933def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002934 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002935 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002936 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002937 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002938
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002939def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002940 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002941 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002942 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002943 TB; // GR8 = parity
2944def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002945 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002946 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002947 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002948 TB; // [mem8] = parity
2949def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002950 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002951 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002952 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002953 TB; // GR8 = not parity
2954def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002955 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002956 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002957 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002958 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002959
2960def SETOr : I<0x90, MRM0r,
2961 (outs GR8 :$dst), (ins),
2962 "seto\t$dst",
2963 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2964 TB; // GR8 = overflow
2965def SETOm : I<0x90, MRM0m,
2966 (outs), (ins i8mem:$dst),
2967 "seto\t$dst",
2968 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2969 TB; // [mem8] = overflow
2970def SETNOr : I<0x91, MRM0r,
2971 (outs GR8 :$dst), (ins),
2972 "setno\t$dst",
2973 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2974 TB; // GR8 = not overflow
2975def SETNOm : I<0x91, MRM0m,
2976 (outs), (ins i8mem:$dst),
2977 "setno\t$dst",
2978 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2979 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002980} // Uses = [EFLAGS]
2981
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002982
2983// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002984let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002985def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002986 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002987 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002988 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002989def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002990 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002991 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002992 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002993def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002994 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002995 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002996 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002997def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002998 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002999 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003000 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
3001 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003002def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003003 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003004 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003005 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
3006 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003007def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003008 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003009 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003010 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
3011 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003012def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003013 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003014 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003015 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3016 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003017def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003018 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003019 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003020 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3021 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003022def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003023 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003024 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003025 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3026 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003027def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003028 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003029 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003030 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003031def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003032 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003033 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003034 [(X86cmp GR16:$src1, imm:$src2),
3035 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003036def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003037 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003038 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003039 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003040def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003041 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003042 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003043 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3044 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003045def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003046 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003047 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003048 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3049 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003050def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003051 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003052 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003053 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3054 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003055def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003056 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003057 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003058 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3059 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003060def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003061 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003062 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003063 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3064 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003065def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003066 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003067 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003068 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3069 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003070def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003071 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003072 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003073 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003074 (implicit EFLAGS)]>;
3075} // Defs = [EFLAGS]
3076
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003077// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003078// TODO: BTC, BTR, and BTS
3079let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003080def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003081 "bt{w}\t{$src2, $src1|$src1, $src2}",
3082 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003083 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003084def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003085 "bt{l}\t{$src2, $src1|$src1, $src2}",
3086 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003087 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003088
3089// Unlike with the register+register form, the memory+register form of the
3090// bt instruction does not ignore the high bits of the index. From ISel's
3091// perspective, this is pretty bizarre. Disable these instructions for now.
3092//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3093// "bt{w}\t{$src2, $src1|$src1, $src2}",
3094// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3095// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3096//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3097// "bt{l}\t{$src2, $src1|$src1, $src2}",
3098// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3099// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003100
3101def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3102 "bt{w}\t{$src2, $src1|$src1, $src2}",
3103 [(X86bt GR16:$src1, i16immSExt8:$src2),
3104 (implicit EFLAGS)]>, OpSize, TB;
3105def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3106 "bt{l}\t{$src2, $src1|$src1, $src2}",
3107 [(X86bt GR32:$src1, i32immSExt8:$src2),
3108 (implicit EFLAGS)]>, TB;
3109// Note that these instructions don't need FastBTMem because that
3110// only applies when the other operand is in a register. When it's
3111// an immediate, bt is still fast.
3112def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3113 "bt{w}\t{$src2, $src1|$src1, $src2}",
3114 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3115 (implicit EFLAGS)]>, OpSize, TB;
3116def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3117 "bt{l}\t{$src2, $src1|$src1, $src2}",
3118 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3119 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003120} // Defs = [EFLAGS]
3121
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003122// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003123// Use movsbl intead of movsbw; we don't care about the high 16 bits
3124// of the register here. This has a smaller encoding and avoids a
3125// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003126def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003127 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3128 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003129def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003130 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3131 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003132def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003133 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003134 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003135def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003136 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003137 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003138def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003139 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003140 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003141def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003142 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003143 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3144
Dan Gohman9203ab42008-07-30 18:09:17 +00003145// Use movzbl intead of movzbw; we don't care about the high 16 bits
3146// of the register here. This has a smaller encoding and avoids a
3147// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003148def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003149 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3150 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003151def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003152 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3153 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003154def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003155 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003156 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003157def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003158 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003159 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003160def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003161 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003162 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003163def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003164 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003165 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3166
Dan Gohman744d4622009-04-13 16:09:41 +00003167// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3168// except that they use GR32_NOREX for the output operand register class
3169// instead of GR32. This allows them to operate on h registers on x86-64.
3170def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3171 (outs GR32_NOREX:$dst), (ins GR8:$src),
3172 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3173 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003174let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003175def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3176 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3177 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3178 []>, TB;
3179
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003180let neverHasSideEffects = 1 in {
3181 let Defs = [AX], Uses = [AL] in
3182 def CBW : I<0x98, RawFrm, (outs), (ins),
3183 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3184 let Defs = [EAX], Uses = [AX] in
3185 def CWDE : I<0x98, RawFrm, (outs), (ins),
3186 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003187
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003188 let Defs = [AX,DX], Uses = [AX] in
3189 def CWD : I<0x99, RawFrm, (outs), (ins),
3190 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3191 let Defs = [EAX,EDX], Uses = [EAX] in
3192 def CDQ : I<0x99, RawFrm, (outs), (ins),
3193 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3194}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003195
3196//===----------------------------------------------------------------------===//
3197// Alias Instructions
3198//===----------------------------------------------------------------------===//
3199
3200// Alias instructions that map movr0 to xor.
3201// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003202let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3203 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003204def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003205 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003206 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003207// Use xorl instead of xorw since we don't care about the high 16 bits,
3208// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003209def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003210 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3211 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003212def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003213 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003214 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003215}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003216
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003217//===----------------------------------------------------------------------===//
3218// Thread Local Storage Instructions
3219//
3220
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003221// All calls clobber the non-callee saved registers. ESP is marked as
3222// a use to prevent stack-pointer assignments that appear immediately
3223// before calls from potentially appearing dead.
3224let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3225 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3226 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3227 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003228 Uses = [ESP] in
3229def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3230 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003231 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003232 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003233 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003234
Daniel Dunbar75a07302009-08-11 22:24:40 +00003235let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003236def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3237 "movl\t%gs:$src, $dst",
3238 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3239
Daniel Dunbar75a07302009-08-11 22:24:40 +00003240let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003241def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3242 "movl\t%fs:$src, $dst",
3243 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3244
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003245//===----------------------------------------------------------------------===//
3246// DWARF Pseudo Instructions
3247//
3248
Evan Chengb783fa32007-07-19 01:14:50 +00003249def DWARF_LOC : I<0, Pseudo, (outs),
3250 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Chris Lattner64b54552009-07-10 22:34:11 +00003251 ".loc\t$file $line $col",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003252 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3253 (i32 imm:$file))]>;
3254
3255//===----------------------------------------------------------------------===//
3256// EH Pseudo Instructions
3257//
3258let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003259 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003260def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003261 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003262 [(X86ehret GR32:$addr)]>;
3263
3264}
3265
3266//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003267// Atomic support
3268//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003269
Evan Cheng3e171562008-04-19 01:20:30 +00003270// Atomic swap. These are just normal xchg instructions. But since a memory
3271// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003272let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003273def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3274 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3275 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3276def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3277 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3278 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3279 OpSize;
3280def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3281 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3282 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3283}
3284
Evan Chengd49dbb82008-04-18 20:55:36 +00003285// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003286let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003287def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003288 "lock\n\t"
3289 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003290 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003291}
Dale Johannesenf160d802008-10-02 18:53:47 +00003292let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003293def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003294 "lock\n\t"
3295 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003296 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3297}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003298
3299let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003300def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003301 "lock\n\t"
3302 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003303 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003304}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003305let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003306def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003307 "lock\n\t"
3308 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003309 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003310}
3311
Evan Chengd49dbb82008-04-18 20:55:36 +00003312// Atomic exchange and add
3313let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3314def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003315 "lock\n\t"
3316 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003317 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003318 TB, LOCK;
3319def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003320 "lock\n\t"
3321 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003322 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003323 TB, OpSize, LOCK;
3324def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003325 "lock\n\t"
3326 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003327 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003328 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003329}
3330
Evan Chengb723fb52009-07-30 08:33:02 +00003331// Optimized codegen when the non-memory output is not used.
3332// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3333def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3334 "lock\n\t"
3335 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3336def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3337 "lock\n\t"
3338 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3339def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3340 "lock\n\t"
3341 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3342def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3343 "lock\n\t"
3344 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3345def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3346 "lock\n\t"
3347 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3348def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3349 "lock\n\t"
3350 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3351def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3352 "lock\n\t"
3353 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3354def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3355 "lock\n\t"
3356 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3357
3358def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3359 "lock\n\t"
3360 "inc{b}\t$dst", []>, LOCK;
3361def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3362 "lock\n\t"
3363 "inc{w}\t$dst", []>, OpSize, LOCK;
3364def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3365 "lock\n\t"
3366 "inc{l}\t$dst", []>, LOCK;
3367
3368def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3369 "lock\n\t"
3370 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3371def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3372 "lock\n\t"
3373 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3374def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3375 "lock\n\t"
3376 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3377def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3378 "lock\n\t"
3379 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3380def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3381 "lock\n\t"
3382 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3383def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3384 "lock\n\t"
3385 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3386def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3387 "lock\n\t"
3388 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3389def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3390 "lock\n\t"
3391 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3392
3393def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3394 "lock\n\t"
3395 "dec{b}\t$dst", []>, LOCK;
3396def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3397 "lock\n\t"
3398 "dec{w}\t$dst", []>, OpSize, LOCK;
3399def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3400 "lock\n\t"
3401 "dec{l}\t$dst", []>, LOCK;
3402
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003403// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003404let Constraints = "$val = $dst", Defs = [EFLAGS],
3405 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003406def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003407 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003408 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003409def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003410 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003411 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003412def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003413 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003414 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003415def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003416 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003417 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003418def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003419 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003420 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003421def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003422 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003423 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003424def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003425 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003426 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003427def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003428 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003429 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003430
3431def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003432 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003433 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003434def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003435 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003436 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003437def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003438 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003439 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003440def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003441 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003442 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003443def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003444 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003445 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003446def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003447 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003448 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003449def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003450 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003451 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003452def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003453 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003454 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003455
3456def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003457 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003458 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003459def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003460 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003461 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003462def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003463 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003464 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003465def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003466 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003467 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003468}
3469
Dale Johannesenf160d802008-10-02 18:53:47 +00003470let Constraints = "$val1 = $dst1, $val2 = $dst2",
3471 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3472 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003473 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003474 usesCustomDAGSchedInserter = 1 in {
3475def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3476 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003477 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003478def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3479 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003480 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003481def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3482 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003483 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003484def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3485 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003486 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003487def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3488 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003489 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003490def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3491 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003492 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003493def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3494 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003495 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003496}
3497
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003498//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003499// Non-Instruction Patterns
3500//===----------------------------------------------------------------------===//
3501
Bill Wendlingfef06052008-09-16 21:48:12 +00003502// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003503def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3504def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003505def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003506def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3507def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3508
3509def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3510 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3511def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3512 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3513def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3514 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3515def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3516 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3517
3518def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3519 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3520def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3521 (MOV32mi addr:$dst, texternalsym:$src)>;
3522
3523// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003524// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003525def : Pat<(X86tcret GR32:$dst, imm:$off),
3526 (TCRETURNri GR32:$dst, imm:$off)>;
3527
3528def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3529 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3530
3531def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3532 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003533
Dan Gohmance5dbff2009-08-02 16:10:01 +00003534// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003535def : Pat<(X86call (i32 tglobaladdr:$dst)),
3536 (CALLpcrel32 tglobaladdr:$dst)>;
3537def : Pat<(X86call (i32 texternalsym:$dst)),
3538 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003539def : Pat<(X86call (i32 imm:$dst)),
3540 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003541
3542// X86 specific add which produces a flag.
3543def : Pat<(addc GR32:$src1, GR32:$src2),
3544 (ADD32rr GR32:$src1, GR32:$src2)>;
3545def : Pat<(addc GR32:$src1, (load addr:$src2)),
3546 (ADD32rm GR32:$src1, addr:$src2)>;
3547def : Pat<(addc GR32:$src1, imm:$src2),
3548 (ADD32ri GR32:$src1, imm:$src2)>;
3549def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3550 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3551
3552def : Pat<(subc GR32:$src1, GR32:$src2),
3553 (SUB32rr GR32:$src1, GR32:$src2)>;
3554def : Pat<(subc GR32:$src1, (load addr:$src2)),
3555 (SUB32rm GR32:$src1, addr:$src2)>;
3556def : Pat<(subc GR32:$src1, imm:$src2),
3557 (SUB32ri GR32:$src1, imm:$src2)>;
3558def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3559 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3560
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003561// Comparisons.
3562
3563// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003564def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003565 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003566def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003567 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003568def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003569 (TEST32rr GR32:$src1, GR32:$src1)>;
3570
Dan Gohman0a3c5222009-01-07 01:00:24 +00003571// Conditional moves with folded loads with operands swapped and conditions
3572// inverted.
3573def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3574 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3575def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3576 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3577def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3578 (CMOVB16rm GR16:$src2, addr:$src1)>;
3579def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3580 (CMOVB32rm GR32:$src2, addr:$src1)>;
3581def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3582 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3583def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3584 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3585def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3586 (CMOVE16rm GR16:$src2, addr:$src1)>;
3587def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3588 (CMOVE32rm GR32:$src2, addr:$src1)>;
3589def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3590 (CMOVA16rm GR16:$src2, addr:$src1)>;
3591def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3592 (CMOVA32rm GR32:$src2, addr:$src1)>;
3593def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3594 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3595def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3596 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3597def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3598 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3599def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3600 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3601def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3602 (CMOVL16rm GR16:$src2, addr:$src1)>;
3603def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3604 (CMOVL32rm GR32:$src2, addr:$src1)>;
3605def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3606 (CMOVG16rm GR16:$src2, addr:$src1)>;
3607def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3608 (CMOVG32rm GR32:$src2, addr:$src1)>;
3609def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3610 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3611def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3612 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3613def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3614 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3615def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3616 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3617def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3618 (CMOVP16rm GR16:$src2, addr:$src1)>;
3619def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3620 (CMOVP32rm GR32:$src2, addr:$src1)>;
3621def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3622 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3623def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3624 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3625def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3626 (CMOVS16rm GR16:$src2, addr:$src1)>;
3627def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3628 (CMOVS32rm GR32:$src2, addr:$src1)>;
3629def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3630 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3631def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3632 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3633def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3634 (CMOVO16rm GR16:$src2, addr:$src1)>;
3635def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3636 (CMOVO32rm GR32:$src2, addr:$src1)>;
3637
Duncan Sands082524c2008-01-23 20:39:46 +00003638// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003639def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3640def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3641def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3642
3643// extload bool -> extload byte
3644def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003645def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003646def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003647def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003648def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3649def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3650
Dan Gohman9959b052009-08-26 14:59:13 +00003651// anyext. Define these to do an explicit zero-extend to
3652// avoid partial-register updates.
3653def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3654def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3655def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003656
Evan Chengf2abee72007-12-13 00:43:27 +00003657// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003658def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3659 (MOVZX32rm8 addr:$src)>;
3660def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3661 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003662
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003663//===----------------------------------------------------------------------===//
3664// Some peepholes
3665//===----------------------------------------------------------------------===//
3666
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003667// Odd encoding trick: -128 fits into an 8-bit immediate field while
3668// +128 doesn't, so in this special case use a sub instead of an add.
3669def : Pat<(add GR16:$src1, 128),
3670 (SUB16ri8 GR16:$src1, -128)>;
3671def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3672 (SUB16mi8 addr:$dst, -128)>;
3673def : Pat<(add GR32:$src1, 128),
3674 (SUB32ri8 GR32:$src1, -128)>;
3675def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3676 (SUB32mi8 addr:$dst, -128)>;
3677
Dan Gohman9203ab42008-07-30 18:09:17 +00003678// r & (2^16-1) ==> movz
3679def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003680 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003681// r & (2^8-1) ==> movz
3682def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003683 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003684 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003685 Requires<[In32BitMode]>;
3686// r & (2^8-1) ==> movz
3687def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003688 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003689 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003690 Requires<[In32BitMode]>;
3691
3692// sext_inreg patterns
3693def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003694 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003695def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003696 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003697 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003698 Requires<[In32BitMode]>;
3699def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003700 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003701 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003702 Requires<[In32BitMode]>;
3703
3704// trunc patterns
3705def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003706 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003707def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003708 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003709 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003710 Requires<[In32BitMode]>;
3711def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003712 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003713 x86_subreg_8bit)>,
3714 Requires<[In32BitMode]>;
3715
3716// h-register tricks
3717def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003718 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003719 x86_subreg_8bit_hi)>,
3720 Requires<[In32BitMode]>;
3721def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003722 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003723 x86_subreg_8bit_hi)>,
3724 Requires<[In32BitMode]>;
3725def : Pat<(srl_su GR16:$src, (i8 8)),
3726 (EXTRACT_SUBREG
3727 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003728 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003729 x86_subreg_8bit_hi)),
3730 x86_subreg_16bit)>,
3731 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003732def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3733 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3734 x86_subreg_8bit_hi))>,
3735 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00003736def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
3737 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3738 x86_subreg_8bit_hi))>,
3739 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003740def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003741 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003742 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003743 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003744
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003745// (shl x, 1) ==> (add x, x)
3746def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3747def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3748def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3749
Evan Cheng76a64c72008-08-30 02:03:58 +00003750// (shl x (and y, 31)) ==> (shl x, y)
3751def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3752 (SHL8rCL GR8:$src1)>;
3753def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3754 (SHL16rCL GR16:$src1)>;
3755def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3756 (SHL32rCL GR32:$src1)>;
3757def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3758 (SHL8mCL addr:$dst)>;
3759def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3760 (SHL16mCL addr:$dst)>;
3761def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3762 (SHL32mCL addr:$dst)>;
3763
3764def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3765 (SHR8rCL GR8:$src1)>;
3766def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3767 (SHR16rCL GR16:$src1)>;
3768def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3769 (SHR32rCL GR32:$src1)>;
3770def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3771 (SHR8mCL addr:$dst)>;
3772def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3773 (SHR16mCL addr:$dst)>;
3774def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3775 (SHR32mCL addr:$dst)>;
3776
3777def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3778 (SAR8rCL GR8:$src1)>;
3779def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3780 (SAR16rCL GR16:$src1)>;
3781def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3782 (SAR32rCL GR32:$src1)>;
3783def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3784 (SAR8mCL addr:$dst)>;
3785def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3786 (SAR16mCL addr:$dst)>;
3787def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3788 (SAR32mCL addr:$dst)>;
3789
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003790// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3791def : Pat<(or (srl GR32:$src1, CL:$amt),
3792 (shl GR32:$src2, (sub 32, CL:$amt))),
3793 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3794
3795def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3796 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3797 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3798
Dan Gohman921581d2008-10-17 01:23:35 +00003799def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3800 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3801 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3802
3803def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3804 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3805 addr:$dst),
3806 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3807
3808def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3809 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3810
3811def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3812 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3813 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3814
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003815// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3816def : Pat<(or (shl GR32:$src1, CL:$amt),
3817 (srl GR32:$src2, (sub 32, CL:$amt))),
3818 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3819
3820def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3821 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3822 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3823
Dan Gohman921581d2008-10-17 01:23:35 +00003824def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3825 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3826 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3827
3828def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3829 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3830 addr:$dst),
3831 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3832
3833def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3834 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3835
3836def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3837 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3838 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3839
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003840// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3841def : Pat<(or (srl GR16:$src1, CL:$amt),
3842 (shl GR16:$src2, (sub 16, CL:$amt))),
3843 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3844
3845def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3846 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3847 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3848
Dan Gohman921581d2008-10-17 01:23:35 +00003849def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3850 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3851 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3852
3853def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3854 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3855 addr:$dst),
3856 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3857
3858def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3859 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3860
3861def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3862 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3863 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3864
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003865// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3866def : Pat<(or (shl GR16:$src1, CL:$amt),
3867 (srl GR16:$src2, (sub 16, CL:$amt))),
3868 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3869
3870def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3871 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3872 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3873
Dan Gohman921581d2008-10-17 01:23:35 +00003874def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3875 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3876 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3877
3878def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3879 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3880 addr:$dst),
3881 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3882
3883def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3884 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3885
3886def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3887 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3888 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3889
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003890//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003891// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003892//===----------------------------------------------------------------------===//
3893
Dan Gohman99a12192009-03-04 19:44:21 +00003894// Register-Register Addition with EFLAGS result
3895def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003896 (implicit EFLAGS)),
3897 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003898def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003899 (implicit EFLAGS)),
3900 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003901def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003902 (implicit EFLAGS)),
3903 (ADD32rr GR32:$src1, GR32:$src2)>;
3904
Dan Gohman99a12192009-03-04 19:44:21 +00003905// Register-Memory Addition with EFLAGS result
3906def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003907 (implicit EFLAGS)),
3908 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003909def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003910 (implicit EFLAGS)),
3911 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003912def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003913 (implicit EFLAGS)),
3914 (ADD32rm GR32:$src1, addr:$src2)>;
3915
Dan Gohman99a12192009-03-04 19:44:21 +00003916// Register-Integer Addition with EFLAGS result
3917def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003918 (implicit EFLAGS)),
3919 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003920def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003921 (implicit EFLAGS)),
3922 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003923def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003924 (implicit EFLAGS)),
3925 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003926def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003927 (implicit EFLAGS)),
3928 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003929def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003930 (implicit EFLAGS)),
3931 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3932
Dan Gohman99a12192009-03-04 19:44:21 +00003933// Memory-Register Addition with EFLAGS result
3934def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003935 addr:$dst),
3936 (implicit EFLAGS)),
3937 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003938def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003939 addr:$dst),
3940 (implicit EFLAGS)),
3941 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003942def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003943 addr:$dst),
3944 (implicit EFLAGS)),
3945 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003946
3947// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003948def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003949 addr:$dst),
3950 (implicit EFLAGS)),
3951 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003952def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003953 addr:$dst),
3954 (implicit EFLAGS)),
3955 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003956def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003957 addr:$dst),
3958 (implicit EFLAGS)),
3959 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003960def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003961 addr:$dst),
3962 (implicit EFLAGS)),
3963 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003964def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003965 addr:$dst),
3966 (implicit EFLAGS)),
3967 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3968
Dan Gohman99a12192009-03-04 19:44:21 +00003969// Register-Register Subtraction with EFLAGS result
3970def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003971 (implicit EFLAGS)),
3972 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003973def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003974 (implicit EFLAGS)),
3975 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003976def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003977 (implicit EFLAGS)),
3978 (SUB32rr GR32:$src1, GR32:$src2)>;
3979
Dan Gohman99a12192009-03-04 19:44:21 +00003980// Register-Memory Subtraction with EFLAGS result
3981def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003982 (implicit EFLAGS)),
3983 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003984def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003985 (implicit EFLAGS)),
3986 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003987def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003988 (implicit EFLAGS)),
3989 (SUB32rm GR32:$src1, addr:$src2)>;
3990
Dan Gohman99a12192009-03-04 19:44:21 +00003991// Register-Integer Subtraction with EFLAGS result
3992def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003993 (implicit EFLAGS)),
3994 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003995def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003996 (implicit EFLAGS)),
3997 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003998def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003999 (implicit EFLAGS)),
4000 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004001def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004002 (implicit EFLAGS)),
4003 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004004def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004005 (implicit EFLAGS)),
4006 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
4007
Dan Gohman99a12192009-03-04 19:44:21 +00004008// Memory-Register Subtraction with EFLAGS result
4009def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004010 addr:$dst),
4011 (implicit EFLAGS)),
4012 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004013def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004014 addr:$dst),
4015 (implicit EFLAGS)),
4016 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004017def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004018 addr:$dst),
4019 (implicit EFLAGS)),
4020 (SUB32mr addr:$dst, GR32:$src2)>;
4021
Dan Gohman99a12192009-03-04 19:44:21 +00004022// Memory-Integer Subtraction with EFLAGS result
4023def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004024 addr:$dst),
4025 (implicit EFLAGS)),
4026 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004027def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004028 addr:$dst),
4029 (implicit EFLAGS)),
4030 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004031def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004032 addr:$dst),
4033 (implicit EFLAGS)),
4034 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004035def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004036 addr:$dst),
4037 (implicit EFLAGS)),
4038 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004039def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004040 addr:$dst),
4041 (implicit EFLAGS)),
4042 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4043
4044
Dan Gohman99a12192009-03-04 19:44:21 +00004045// Register-Register Signed Integer Multiply with EFLAGS result
4046def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004047 (implicit EFLAGS)),
4048 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004049def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004050 (implicit EFLAGS)),
4051 (IMUL32rr GR32:$src1, GR32:$src2)>;
4052
Dan Gohman99a12192009-03-04 19:44:21 +00004053// Register-Memory Signed Integer Multiply with EFLAGS result
4054def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004055 (implicit EFLAGS)),
4056 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004057def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004058 (implicit EFLAGS)),
4059 (IMUL32rm GR32:$src1, addr:$src2)>;
4060
Dan Gohman99a12192009-03-04 19:44:21 +00004061// Register-Integer Signed Integer Multiply with EFLAGS result
4062def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004063 (implicit EFLAGS)),
4064 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004065def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004066 (implicit EFLAGS)),
4067 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004068def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004069 (implicit EFLAGS)),
4070 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004071def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004072 (implicit EFLAGS)),
4073 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4074
Dan Gohman99a12192009-03-04 19:44:21 +00004075// Memory-Integer Signed Integer Multiply with EFLAGS result
4076def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004077 (implicit EFLAGS)),
4078 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004079def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004080 (implicit EFLAGS)),
4081 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004082def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004083 (implicit EFLAGS)),
4084 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004085def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004086 (implicit EFLAGS)),
4087 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4088
Dan Gohman99a12192009-03-04 19:44:21 +00004089// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004090let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004091def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004092 (implicit EFLAGS)),
4093 (ADD16rr GR16:$src1, GR16:$src1)>;
4094
Dan Gohman99a12192009-03-04 19:44:21 +00004095def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004096 (implicit EFLAGS)),
4097 (ADD32rr GR32:$src1, GR32:$src1)>;
4098}
4099
Dan Gohman99a12192009-03-04 19:44:21 +00004100// INC and DEC with EFLAGS result. Note that these do not set CF.
4101def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4102 (INC8r GR8:$src)>;
4103def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4104 (implicit EFLAGS)),
4105 (INC8m addr:$dst)>;
4106def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4107 (DEC8r GR8:$src)>;
4108def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4109 (implicit EFLAGS)),
4110 (DEC8m addr:$dst)>;
4111
4112def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004113 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004114def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4115 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004116 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004117def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004118 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004119def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4120 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004121 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004122
4123def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004124 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004125def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4126 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004127 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004128def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004129 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004130def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4131 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004132 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004133
Bill Wendlingf5399032008-12-12 21:15:41 +00004134//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004135// Floating Point Stack Support
4136//===----------------------------------------------------------------------===//
4137
4138include "X86InstrFPStack.td"
4139
4140//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00004141// X86-64 Support
4142//===----------------------------------------------------------------------===//
4143
Chris Lattner2de8d2b2008-01-10 05:50:42 +00004144include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00004145
4146//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004147// XMM Floating point support (requires SSE / SSE2)
4148//===----------------------------------------------------------------------===//
4149
4150include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00004151
4152//===----------------------------------------------------------------------===//
4153// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4154//===----------------------------------------------------------------------===//
4155
4156include "X86InstrMMX.td"