blob: f5661272f998ca892d3dcbd60597e52935774a75 [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 Gohmanf17a25c2007-07-18 16:29:46 +00001038def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001039 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001040 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001042 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001045 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001046 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001048 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050def CMOVAE16rr: I<0x43, 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 "cmovae\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_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056def CMOVAE32rr: I<0x43, 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 "cmovae\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_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, 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 "cmove\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_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, 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 "cmove\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_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074def CMOVNE16rr: I<0x45, 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 "cmovne\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_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001080def CMOVNE32rr: I<0x45, 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 "cmovne\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_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, 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 "cmovbe\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_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001092def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, 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 "cmovbe\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_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098def CMOVA16rr : I<0x47, 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 "cmova\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_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001103 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104def CMOVA32rr : I<0x47, 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 "cmova\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_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001110def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, 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 "cmovl\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_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001116def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, 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 "cmovl\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_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122def CMOVGE16rr: I<0x4D, 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 "cmovge\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_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001127 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001128def CMOVGE32rr: I<0x4D, 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 "cmovge\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_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001134def CMOVLE16rr: I<0x4E, 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 "cmovle\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_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140def CMOVLE32rr: I<0x4E, 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 "cmovle\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_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146def CMOVG16rr : I<0x4F, 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 "cmovg\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_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152def CMOVG32rr : I<0x4F, 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 "cmovg\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_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001157 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, 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 "cmovs\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_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001163 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, 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 "cmovs\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_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170def CMOVNS16rr: I<0x49, 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 "cmovns\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_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001176def CMOVNS32rr: I<0x49, 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 "cmovns\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_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, 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 "cmovp\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_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001187 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, 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 "cmovp\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_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194def CMOVNP16rr : I<0x4B, 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 "cmovnp\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_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001199 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200def CMOVNP32rr : I<0x4B, 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 "cmovnp\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_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001206def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1207 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1208 "cmovo\t{$src2, $dst|$dst, $src2}",
1209 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1210 X86_COND_O, EFLAGS))]>,
1211 TB, OpSize;
1212def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1213 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1214 "cmovo\t{$src2, $dst|$dst, $src2}",
1215 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1216 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001217 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001218def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1219 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1220 "cmovno\t{$src2, $dst|$dst, $src2}",
1221 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1222 X86_COND_NO, EFLAGS))]>,
1223 TB, OpSize;
1224def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1225 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1226 "cmovno\t{$src2, $dst|$dst, $src2}",
1227 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1228 X86_COND_NO, EFLAGS))]>,
1229 TB;
1230} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001231
1232def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1233 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1234 "cmovb\t{$src2, $dst|$dst, $src2}",
1235 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1236 X86_COND_B, EFLAGS))]>,
1237 TB, OpSize;
1238def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1239 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1240 "cmovb\t{$src2, $dst|$dst, $src2}",
1241 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1242 X86_COND_B, EFLAGS))]>,
1243 TB;
1244def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1245 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1246 "cmovae\t{$src2, $dst|$dst, $src2}",
1247 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1248 X86_COND_AE, EFLAGS))]>,
1249 TB, OpSize;
1250def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1251 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1252 "cmovae\t{$src2, $dst|$dst, $src2}",
1253 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1254 X86_COND_AE, EFLAGS))]>,
1255 TB;
1256def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1257 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1258 "cmove\t{$src2, $dst|$dst, $src2}",
1259 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1260 X86_COND_E, EFLAGS))]>,
1261 TB, OpSize;
1262def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1263 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1264 "cmove\t{$src2, $dst|$dst, $src2}",
1265 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1266 X86_COND_E, EFLAGS))]>,
1267 TB;
1268def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1269 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1270 "cmovne\t{$src2, $dst|$dst, $src2}",
1271 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1272 X86_COND_NE, EFLAGS))]>,
1273 TB, OpSize;
1274def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1275 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1276 "cmovne\t{$src2, $dst|$dst, $src2}",
1277 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1278 X86_COND_NE, EFLAGS))]>,
1279 TB;
1280def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1281 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1282 "cmovbe\t{$src2, $dst|$dst, $src2}",
1283 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1284 X86_COND_BE, EFLAGS))]>,
1285 TB, OpSize;
1286def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1287 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1288 "cmovbe\t{$src2, $dst|$dst, $src2}",
1289 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1290 X86_COND_BE, EFLAGS))]>,
1291 TB;
1292def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1293 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1294 "cmova\t{$src2, $dst|$dst, $src2}",
1295 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1296 X86_COND_A, EFLAGS))]>,
1297 TB, OpSize;
1298def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1299 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1300 "cmova\t{$src2, $dst|$dst, $src2}",
1301 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1302 X86_COND_A, EFLAGS))]>,
1303 TB;
1304def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1305 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1306 "cmovl\t{$src2, $dst|$dst, $src2}",
1307 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1308 X86_COND_L, EFLAGS))]>,
1309 TB, OpSize;
1310def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1311 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1312 "cmovl\t{$src2, $dst|$dst, $src2}",
1313 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1314 X86_COND_L, EFLAGS))]>,
1315 TB;
1316def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1317 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1318 "cmovge\t{$src2, $dst|$dst, $src2}",
1319 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1320 X86_COND_GE, EFLAGS))]>,
1321 TB, OpSize;
1322def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1323 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1324 "cmovge\t{$src2, $dst|$dst, $src2}",
1325 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1326 X86_COND_GE, EFLAGS))]>,
1327 TB;
1328def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1329 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1330 "cmovle\t{$src2, $dst|$dst, $src2}",
1331 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1332 X86_COND_LE, EFLAGS))]>,
1333 TB, OpSize;
1334def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1335 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1336 "cmovle\t{$src2, $dst|$dst, $src2}",
1337 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1338 X86_COND_LE, EFLAGS))]>,
1339 TB;
1340def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1341 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1342 "cmovg\t{$src2, $dst|$dst, $src2}",
1343 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1344 X86_COND_G, EFLAGS))]>,
1345 TB, OpSize;
1346def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1347 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1348 "cmovg\t{$src2, $dst|$dst, $src2}",
1349 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1350 X86_COND_G, EFLAGS))]>,
1351 TB;
1352def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1353 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1354 "cmovs\t{$src2, $dst|$dst, $src2}",
1355 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1356 X86_COND_S, EFLAGS))]>,
1357 TB, OpSize;
1358def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1359 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1360 "cmovs\t{$src2, $dst|$dst, $src2}",
1361 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1362 X86_COND_S, EFLAGS))]>,
1363 TB;
1364def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1365 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1366 "cmovns\t{$src2, $dst|$dst, $src2}",
1367 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1368 X86_COND_NS, EFLAGS))]>,
1369 TB, OpSize;
1370def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1371 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1372 "cmovns\t{$src2, $dst|$dst, $src2}",
1373 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1374 X86_COND_NS, EFLAGS))]>,
1375 TB;
1376def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1377 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1378 "cmovp\t{$src2, $dst|$dst, $src2}",
1379 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1380 X86_COND_P, EFLAGS))]>,
1381 TB, OpSize;
1382def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1383 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1384 "cmovp\t{$src2, $dst|$dst, $src2}",
1385 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1386 X86_COND_P, EFLAGS))]>,
1387 TB;
1388def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1389 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1390 "cmovnp\t{$src2, $dst|$dst, $src2}",
1391 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1392 X86_COND_NP, EFLAGS))]>,
1393 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001394def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1395 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1396 "cmovnp\t{$src2, $dst|$dst, $src2}",
1397 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1398 X86_COND_NP, EFLAGS))]>,
1399 TB;
1400def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1401 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1402 "cmovo\t{$src2, $dst|$dst, $src2}",
1403 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1404 X86_COND_O, EFLAGS))]>,
1405 TB, OpSize;
1406def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1407 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1408 "cmovo\t{$src2, $dst|$dst, $src2}",
1409 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1410 X86_COND_O, EFLAGS))]>,
1411 TB;
1412def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1413 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1414 "cmovno\t{$src2, $dst|$dst, $src2}",
1415 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1416 X86_COND_NO, EFLAGS))]>,
1417 TB, OpSize;
1418def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1419 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1420 "cmovno\t{$src2, $dst|$dst, $src2}",
1421 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1422 X86_COND_NO, EFLAGS))]>,
1423 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001424} // Uses = [EFLAGS]
1425
1426
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001427// unary instructions
1428let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001429let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001430def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001431 [(set GR8:$dst, (ineg GR8:$src)),
1432 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001433def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001434 [(set GR16:$dst, (ineg GR16:$src)),
1435 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001436def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001437 [(set GR32:$dst, (ineg GR32:$src)),
1438 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001439let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001440 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001441 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1442 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001443 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001444 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1445 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001446 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001447 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1448 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001449}
Evan Cheng55687072007-09-14 21:48:26 +00001450} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451
Evan Chengc6cee682009-01-21 02:09:05 +00001452// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1453let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001454def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001456def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001457 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001458def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001459 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001460}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001461let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001462 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001463 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001464 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001465 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001466 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1468}
1469} // CodeSize
1470
1471// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001472let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001474def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001475 [(set GR8:$dst, (add GR8:$src, 1)),
1476 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001477let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001478def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001479 [(set GR16:$dst, (add GR16:$src, 1)),
1480 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001481 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001482def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001483 [(set GR32:$dst, (add GR32:$src, 1)),
1484 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001485}
1486let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001487 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001488 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1489 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001490 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001491 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1492 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001493 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001494 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001495 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1496 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001497 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001498}
1499
1500let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001501def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001502 [(set GR8:$dst, (add GR8:$src, -1)),
1503 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001504let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001505def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001506 [(set GR16:$dst, (add GR16:$src, -1)),
1507 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001508 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001509def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001510 [(set GR32:$dst, (add GR32:$src, -1)),
1511 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001512}
1513
1514let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001515 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001516 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1517 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001518 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001519 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1520 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001521 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001522 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001523 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1524 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001525 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001526}
Evan Cheng55687072007-09-14 21:48:26 +00001527} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528
1529// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001530let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001531let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1532def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001533 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001534 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001535 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1536 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001538 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001539 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001540 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1541 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001542def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001543 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001544 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001545 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1546 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001547}
1548
1549def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001550 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001552 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001553 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001555 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001557 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001558 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001559def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001560 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001561 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001562 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001563 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564
1565def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001566 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001568 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1569 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001570def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001571 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001572 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001573 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1574 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001576 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001577 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001578 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1579 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001580def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001581 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001582 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001583 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1584 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001585 OpSize;
1586def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001587 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001588 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001589 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1590 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001591
1592let isTwoAddress = 0 in {
1593 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001594 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001595 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001596 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1597 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001598 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001599 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001600 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001601 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1602 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603 OpSize;
1604 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001605 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001607 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1608 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001610 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001611 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001612 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1613 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001615 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001616 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001617 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1618 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001619 OpSize;
1620 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001621 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001622 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001623 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1624 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001626 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001627 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001628 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1629 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001630 OpSize;
1631 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001632 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001633 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001634 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1635 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636}
1637
1638
1639let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001640def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001642 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1643 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001644def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001645 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001646 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1647 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001648def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001649 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001650 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1651 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001652}
Evan Chengb783fa32007-07-19 01:14:50 +00001653def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001654 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001655 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1656 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001657def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001659 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1660 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001661def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001662 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001663 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1664 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665
Evan Chengb783fa32007-07-19 01:14:50 +00001666def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001667 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001668 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1669 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001670def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001672 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1673 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001674def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001675 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001676 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1677 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678
Evan Chengb783fa32007-07-19 01:14:50 +00001679def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001681 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1682 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001683def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001685 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1686 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001688 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001690 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1691 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001692 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001693 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001694 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1695 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001696 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001698 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1699 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001700 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$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 (loadi8 addr:$dst), imm:$src), addr:$dst),
1703 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001704 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$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 (loadi16 addr:$dst), imm:$src), addr:$dst),
1707 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001708 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001709 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001710 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001711 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1712 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001713 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001715 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1716 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001718 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001720 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1721 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001722} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001723
1724
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001725let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001726 def XOR8rr : I<0x30, MRMDestReg,
1727 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1728 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001729 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1730 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001731 def XOR16rr : I<0x31, MRMDestReg,
1732 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1733 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001734 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1735 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001736 def XOR32rr : I<0x31, MRMDestReg,
1737 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1738 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001739 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1740 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001741} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742
1743def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001744 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001745 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001746 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1747 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001748def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001749 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001750 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001751 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1752 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001753 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001754def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001755 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001757 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1758 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001759
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001760def XOR8ri : Ii8<0x80, MRM6r,
1761 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1762 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001763 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1764 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001765def XOR16ri : Ii16<0x81, MRM6r,
1766 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1767 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001768 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1769 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001770def XOR32ri : Ii32<0x81, MRM6r,
1771 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1772 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001773 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1774 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001775def XOR16ri8 : Ii8<0x83, MRM6r,
1776 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1777 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001778 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1779 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001780 OpSize;
1781def XOR32ri8 : Ii8<0x83, MRM6r,
1782 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1783 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001784 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1785 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001786
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787let isTwoAddress = 0 in {
1788 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001789 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001790 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001791 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1792 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001794 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001796 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1797 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798 OpSize;
1799 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001800 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001801 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001802 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1803 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001804 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001805 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001807 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1808 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001809 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001810 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001811 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001812 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1813 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001814 OpSize;
1815 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001816 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001817 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001818 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1819 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001820 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001821 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001822 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001823 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1824 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001825 OpSize;
1826 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001827 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001829 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1830 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001831} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001832} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833
1834// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001835let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001836let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001837def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001838 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001839 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001840def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001841 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001842 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001843def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001844 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001845 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001846} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001847
Evan Chengb783fa32007-07-19 01:14:50 +00001848def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001849 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001850 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1851let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001852def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001853 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001855def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001856 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001858// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1859// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001860} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001861
1862let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001863 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001864 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001865 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001866 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001867 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001868 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001869 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001870 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001871 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001872 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1873 }
Evan Chengb783fa32007-07-19 01:14:50 +00001874 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001876 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001877 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1880 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001881 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001882 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001883 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1884
1885 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001886 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001889 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1892 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001893 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1896}
1897
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001898let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001899def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001900 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001901 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001902def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001903 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001904 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001905def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001906 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001907 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1908}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909
Evan Chengb783fa32007-07-19 01:14:50 +00001910def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001911 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001912 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001913def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001914 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001916def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001917 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001918 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1919
1920// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001921def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001924def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001927def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1930
1931let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001932 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001933 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001934 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001935 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001936 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001937 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001938 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001939 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001940 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001941 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001942 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1943 }
Evan Chengb783fa32007-07-19 01:14:50 +00001944 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001945 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001946 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001947 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001948 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001949 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1950 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001951 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001953 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1954
1955 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001956 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001959 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001960 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001962 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001963 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1965}
1966
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001967let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001968def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001969 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001970 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001971def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001972 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001973 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001974def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001975 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001976 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1977}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978
Evan Chengb783fa32007-07-19 01:14:50 +00001979def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001980 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001981 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001982def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1985 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001986def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001987 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001988 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1989
1990// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001991def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001992 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001994def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001997def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001998 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001999 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
2000
2001let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002002 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002003 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002004 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002005 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002006 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002007 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002008 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002009 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002010 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002011 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
2012 }
Evan Chengb783fa32007-07-19 01:14:50 +00002013 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002016 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002017 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002018 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2019 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002020 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002021 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002022 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2023
2024 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002025 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002026 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002028 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002029 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2031 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002032 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2035}
2036
2037// Rotate instructions
2038// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002039let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002040def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002041 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002042 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002043def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002044 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002045 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002046def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002047 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002048 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2049}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050
Evan Chengb783fa32007-07-19 01:14:50 +00002051def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002054def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002055 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002056 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002057def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002058 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002059 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2060
2061// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002062def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002063 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002064 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002065def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002068def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2071
2072let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002073 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002074 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002075 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002076 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002077 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002078 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002079 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002080 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002081 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002082 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2083 }
Evan Chengb783fa32007-07-19 01:14:50 +00002084 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002086 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002087 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002088 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2090 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002091 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002092 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002093 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2094
2095 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002096 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002097 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002099 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002100 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002101 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2102 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002103 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002104 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002105 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2106}
2107
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002108let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002109def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002110 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002111 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002112def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002113 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002114 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002115def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002116 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002117 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2118}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119
Evan Chengb783fa32007-07-19 01:14:50 +00002120def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002121 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002122 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002123def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002124 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002125 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002126def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002127 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2129
2130// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002131def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002132 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002134def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002135 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002136 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002137def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002138 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2140
2141let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002142 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002143 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002144 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002145 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002146 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002147 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002148 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002149 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002150 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002151 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2152 }
Evan Chengb783fa32007-07-19 01:14:50 +00002153 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002156 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2159 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002160 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002161 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002162 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2163
2164 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002165 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002166 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002168 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002169 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002170 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2171 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002172 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002173 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2175}
2176
2177
2178
2179// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002180let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002181def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002182 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002183 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002184def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002185 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002186 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002187def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002188 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002189 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002190 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002191def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002192 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002194 TB, OpSize;
2195}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196
2197let isCommutable = 1 in { // These instructions commute to each other.
2198def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002199 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002200 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002201 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2202 (i8 imm:$src3)))]>,
2203 TB;
2204def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002205 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002206 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002207 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2208 (i8 imm:$src3)))]>,
2209 TB;
2210def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002211 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002212 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002213 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2214 (i8 imm:$src3)))]>,
2215 TB, OpSize;
2216def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002217 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002219 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2220 (i8 imm:$src3)))]>,
2221 TB, OpSize;
2222}
2223
2224let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002225 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002226 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002227 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002228 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002229 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002230 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002231 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002232 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002233 addr:$dst)]>, TB;
2234 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002235 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002236 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002237 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002238 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2239 (i8 imm:$src3)), addr:$dst)]>,
2240 TB;
2241 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002242 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002243 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002244 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2245 (i8 imm:$src3)), addr:$dst)]>,
2246 TB;
2247
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002248 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002249 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002250 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002252 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002253 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002254 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002255 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002256 addr:$dst)]>, TB, OpSize;
2257 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002258 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002259 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2262 (i8 imm:$src3)), addr:$dst)]>,
2263 TB, OpSize;
2264 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002265 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002266 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2268 (i8 imm:$src3)), addr:$dst)]>,
2269 TB, OpSize;
2270}
Evan Cheng55687072007-09-14 21:48:26 +00002271} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002272
2273
2274// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002275let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002276let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002277// Register-Register Addition
2278def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2279 (ins GR8 :$src1, GR8 :$src2),
2280 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002281 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002282 (implicit EFLAGS)]>;
2283
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002284let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002285// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002286def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2287 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002288 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002289 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2290 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002291def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2292 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002293 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002294 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2295 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002296} // end isConvertibleToThreeAddress
2297} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002298
2299// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002300def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2301 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002302 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002303 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2304 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002305def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2306 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002307 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002308 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2309 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002310def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2311 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002312 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002313 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2314 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002315
Bill Wendlingae034ed2008-12-12 00:56:36 +00002316// Register-Integer Addition
2317def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2318 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002319 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2320 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002321
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002323// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002324def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2325 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002326 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002327 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2328 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002329def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2330 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002331 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002332 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2333 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002334def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2335 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002336 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002337 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2338 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002339def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2340 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002341 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002342 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2343 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002344}
2345
2346let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002347 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002348 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002350 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2351 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002352 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002353 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002354 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2355 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002356 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002358 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2359 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002360 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$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 (loadi8 addr:$dst), imm:$src2), addr:$dst),
2363 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002364 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$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 (loadi16 addr:$dst), imm:$src2), addr:$dst),
2367 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002368 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$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 (loadi32 addr:$dst), imm:$src2), addr:$dst),
2371 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002372 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002373 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002374 [(store (add (load addr:$dst), i16immSExt8:$src2),
2375 addr:$dst),
2376 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002377 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002378 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002379 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002380 addr:$dst),
2381 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002382
2383 // addition to rAX
2384 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2385 "add\t{$src, %al|%al, $src}", []>;
2386 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2387 "add\t{$src, %ax|%ax, $src}", []>, OpSize;
2388 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2389 "add\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002390}
2391
Evan Cheng259471d2007-10-05 17:59:57 +00002392let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002393let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002394def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002395 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002396 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002397def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2398 (ins GR16:$src1, GR16:$src2),
2399 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002400 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002401def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2402 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002403 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002404 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002405}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002406def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2407 (ins GR8:$src1, i8mem:$src2),
2408 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002409 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002410def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2411 (ins GR16:$src1, i16mem:$src2),
2412 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002413 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002414 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002415def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2416 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002417 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002418 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2419def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002420 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002421 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002422def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2423 (ins GR16:$src1, i16imm:$src2),
2424 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002425 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002426def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2427 (ins GR16:$src1, i16i8imm:$src2),
2428 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002429 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2430 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002431def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2432 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002433 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002434 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002435def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2436 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002437 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002438 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002439
2440let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002441 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002442 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002443 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2444 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002445 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002446 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2447 OpSize;
2448 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002449 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002450 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2451 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002452 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002453 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2454 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002455 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002456 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2457 OpSize;
2458 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002459 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002460 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2461 OpSize;
2462 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002463 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002464 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2465 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002466 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002467 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2468}
Evan Cheng259471d2007-10-05 17:59:57 +00002469} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002470
Bill Wendlingae034ed2008-12-12 00:56:36 +00002471// Register-Register Subtraction
2472def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2473 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002474 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2475 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002476def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2477 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002478 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2479 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002480def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2481 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002482 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2483 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002484
2485// Register-Memory Subtraction
2486def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2487 (ins GR8 :$src1, i8mem :$src2),
2488 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002489 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2490 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002491def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2492 (ins GR16:$src1, i16mem:$src2),
2493 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002494 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2495 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002496def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2497 (ins GR32:$src1, i32mem:$src2),
2498 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002499 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2500 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002501
2502// Register-Integer Subtraction
2503def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2504 (ins GR8:$src1, i8imm:$src2),
2505 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002506 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2507 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002508def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2509 (ins GR16:$src1, i16imm:$src2),
2510 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002511 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2512 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002513def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2514 (ins GR32:$src1, i32imm:$src2),
2515 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002516 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2517 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002518def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2519 (ins GR16:$src1, i16i8imm:$src2),
2520 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002521 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2522 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002523def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2524 (ins GR32:$src1, i32i8imm:$src2),
2525 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002526 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2527 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002528
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002529let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002530 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002531 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002532 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002533 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2534 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002535 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002536 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002537 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2538 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002539 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002540 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002541 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2542 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002543
2544 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002545 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002546 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002547 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2548 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002549 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002550 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002551 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2552 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002553 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002554 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002555 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2556 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002557 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002558 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002559 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002560 addr:$dst),
2561 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002562 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002563 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002564 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002565 addr:$dst),
2566 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002567}
2568
Evan Cheng259471d2007-10-05 17:59:57 +00002569let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002570def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2571 (ins GR8:$src1, GR8:$src2),
2572 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002573 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002574def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2575 (ins GR16:$src1, GR16:$src2),
2576 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002577 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002578def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2579 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002580 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002581 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002582
2583let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002584 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2585 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002586 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002587 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2588 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002589 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002590 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002591 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, 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 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002594 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002595 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002596 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002597 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2598 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002599 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002600 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002601 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2602 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002603 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002604 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002605 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002606 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002607 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002608 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002609 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002610 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002611}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002612def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2613 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002614 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002615def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2616 (ins GR16:$src1, i16mem:$src2),
2617 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002618 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002619 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002620def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2621 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002622 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002623 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002624def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2625 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002626 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002627def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2628 (ins GR16:$src1, i16imm:$src2),
2629 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002630 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002631def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2632 (ins GR16:$src1, i16i8imm:$src2),
2633 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002634 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2635 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002636def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2637 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002638 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002639 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002640def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2641 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002642 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002643 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002644} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002645} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002646
Evan Cheng55687072007-09-14 21:48:26 +00002647let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002648let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002649// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002650def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002651 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002652 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2653 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002654def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002655 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002656 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2657 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002658}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002659
Bill Wendlingf5399032008-12-12 21:15:41 +00002660// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002661def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2662 (ins GR16:$src1, i16mem:$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, (load addr:$src2))),
2665 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002666def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$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, (load addr:$src2))),
2669 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002670} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002671} // end Two Address instructions
2672
2673// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002674let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002675// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002676def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002677 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002678 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002679 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2680 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002681def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002682 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002683 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002684 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2685 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002686def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002687 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002688 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002689 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2690 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002691def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002692 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002693 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002694 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2695 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002696
Bill Wendlingf5399032008-12-12 21:15:41 +00002697// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002698def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002699 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$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 (load addr:$src1), imm:$src2)),
2702 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002703def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002704 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$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 (load addr:$src1), imm:$src2)),
2707 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002708def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002709 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002710 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002711 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002712 i16immSExt8:$src2)),
2713 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002714def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002715 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002716 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002717 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002718 i32immSExt8:$src2)),
2719 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002720} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002721
2722//===----------------------------------------------------------------------===//
2723// Test instructions are just like AND, except they don't generate a result.
2724//
Evan Cheng950aac02007-09-25 01:57:46 +00002725let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002726let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002727def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002728 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002729 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002730 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002731def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002732 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002733 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002734 (implicit EFLAGS)]>,
2735 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002736def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002737 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002738 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002739 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002740}
2741
Evan Chengb783fa32007-07-19 01:14:50 +00002742def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002743 "test{b}\t{$src2, $src1|$src1, $src2}",
2744 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2745 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002746def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002747 "test{w}\t{$src2, $src1|$src1, $src2}",
2748 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2749 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002750def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002751 "test{l}\t{$src2, $src1|$src1, $src2}",
2752 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2753 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002754
2755def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002756 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002757 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002758 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002759 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002760def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002761 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002762 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002763 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002764 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002765def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002766 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002767 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002768 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002769 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002770
Evan Cheng621216e2007-09-29 00:00:36 +00002771def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002772 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002773 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002774 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2775 (implicit EFLAGS)]>;
2776def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002777 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002778 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002779 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2780 (implicit EFLAGS)]>, OpSize;
2781def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002782 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002783 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002784 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002785 (implicit EFLAGS)]>;
2786} // Defs = [EFLAGS]
2787
2788
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002789// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002790let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002791def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002792let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002793def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002794
Evan Cheng950aac02007-09-25 01:57:46 +00002795let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002796def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002797 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002798 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002799 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002800 TB; // GR8 = ==
2801def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002802 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002803 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002804 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002805 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002806
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002807def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002808 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002809 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002810 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002811 TB; // GR8 = !=
2812def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002813 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002814 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002815 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002816 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002817
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002818def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002819 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002820 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002821 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002822 TB; // GR8 = < signed
2823def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002824 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002825 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002826 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002827 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002828
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002829def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002830 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002831 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002832 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002833 TB; // GR8 = >= signed
2834def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002835 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002836 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002837 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002838 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002839
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002840def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002841 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002842 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002843 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002844 TB; // GR8 = <= signed
2845def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002846 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002847 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002848 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002849 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002850
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002851def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002852 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002853 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002854 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002855 TB; // GR8 = > signed
2856def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002857 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002858 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002859 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002860 TB; // [mem8] = > signed
2861
2862def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002863 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002864 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002865 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002866 TB; // GR8 = < unsign
2867def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002868 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002869 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002870 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002871 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002872
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002873def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002874 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002875 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002876 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002877 TB; // GR8 = >= unsign
2878def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002879 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002880 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002881 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002882 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002883
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002884def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002885 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002886 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002887 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002888 TB; // GR8 = <= unsign
2889def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002890 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002891 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002892 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002893 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002894
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002895def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002896 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002897 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002898 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002899 TB; // GR8 = > signed
2900def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002901 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002902 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002903 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002904 TB; // [mem8] = > signed
2905
2906def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002907 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002908 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002909 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002910 TB; // GR8 = <sign bit>
2911def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002912 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002913 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002914 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002915 TB; // [mem8] = <sign bit>
2916def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002917 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002918 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002919 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002920 TB; // GR8 = !<sign bit>
2921def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002922 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002923 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002924 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002925 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002926
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002927def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002928 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002929 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002930 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002931 TB; // GR8 = parity
2932def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002933 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002934 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002935 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002936 TB; // [mem8] = parity
2937def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002938 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002939 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002940 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002941 TB; // GR8 = not parity
2942def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002943 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002944 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002945 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002946 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002947
2948def SETOr : I<0x90, MRM0r,
2949 (outs GR8 :$dst), (ins),
2950 "seto\t$dst",
2951 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2952 TB; // GR8 = overflow
2953def SETOm : I<0x90, MRM0m,
2954 (outs), (ins i8mem:$dst),
2955 "seto\t$dst",
2956 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2957 TB; // [mem8] = overflow
2958def SETNOr : I<0x91, MRM0r,
2959 (outs GR8 :$dst), (ins),
2960 "setno\t$dst",
2961 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2962 TB; // GR8 = not overflow
2963def SETNOm : I<0x91, MRM0m,
2964 (outs), (ins i8mem:$dst),
2965 "setno\t$dst",
2966 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2967 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002968} // Uses = [EFLAGS]
2969
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002970
2971// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002972let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002973def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002974 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002975 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002976 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002977def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002978 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002979 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002980 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002981def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002982 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002983 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002984 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002985def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002986 (outs), (ins i8mem :$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 (loadi8 addr:$src1), GR8:$src2),
2989 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002990def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002991 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002992 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002993 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2994 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002995def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002996 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002997 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002998 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2999 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003000def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003001 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003002 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003003 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
3004 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003005def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003006 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003007 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003008 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
3009 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003010def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00003011 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003012 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003013 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
3014 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003015def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003016 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003017 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003018 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003019def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003020 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003021 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003022 [(X86cmp GR16:$src1, imm:$src2),
3023 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003024def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003025 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003026 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003027 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003028def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003029 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003030 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003031 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3032 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003033def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003034 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003035 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003036 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3037 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003038def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003039 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003040 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003041 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3042 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003043def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003044 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003045 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003046 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3047 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003048def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003049 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003050 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003051 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3052 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003053def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003054 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003055 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003056 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3057 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003058def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003059 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003060 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003061 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003062 (implicit EFLAGS)]>;
3063} // Defs = [EFLAGS]
3064
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003065// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003066// TODO: BTC, BTR, and BTS
3067let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003068def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003069 "bt{w}\t{$src2, $src1|$src1, $src2}",
3070 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003071 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003072def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003073 "bt{l}\t{$src2, $src1|$src1, $src2}",
3074 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003075 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003076
3077// Unlike with the register+register form, the memory+register form of the
3078// bt instruction does not ignore the high bits of the index. From ISel's
3079// perspective, this is pretty bizarre. Disable these instructions for now.
3080//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3081// "bt{w}\t{$src2, $src1|$src1, $src2}",
3082// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3083// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3084//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3085// "bt{l}\t{$src2, $src1|$src1, $src2}",
3086// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3087// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003088
3089def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3090 "bt{w}\t{$src2, $src1|$src1, $src2}",
3091 [(X86bt GR16:$src1, i16immSExt8:$src2),
3092 (implicit EFLAGS)]>, OpSize, TB;
3093def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3094 "bt{l}\t{$src2, $src1|$src1, $src2}",
3095 [(X86bt GR32:$src1, i32immSExt8:$src2),
3096 (implicit EFLAGS)]>, TB;
3097// Note that these instructions don't need FastBTMem because that
3098// only applies when the other operand is in a register. When it's
3099// an immediate, bt is still fast.
3100def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3101 "bt{w}\t{$src2, $src1|$src1, $src2}",
3102 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3103 (implicit EFLAGS)]>, OpSize, TB;
3104def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3105 "bt{l}\t{$src2, $src1|$src1, $src2}",
3106 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3107 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003108} // Defs = [EFLAGS]
3109
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003110// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003111// Use movsbl intead of movsbw; we don't care about the high 16 bits
3112// of the register here. This has a smaller encoding and avoids a
3113// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003114def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003115 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3116 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003117def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003118 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3119 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003120def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003121 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003122 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003123def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003124 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003125 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003126def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003127 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003128 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003129def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003130 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003131 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3132
Dan Gohman9203ab42008-07-30 18:09:17 +00003133// Use movzbl intead of movzbw; we don't care about the high 16 bits
3134// of the register here. This has a smaller encoding and avoids a
3135// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003136def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003137 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3138 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003139def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003140 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3141 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003142def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003143 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003144 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003145def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003146 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003147 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003148def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003149 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003150 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003151def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003152 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003153 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3154
Dan Gohman744d4622009-04-13 16:09:41 +00003155// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3156// except that they use GR32_NOREX for the output operand register class
3157// instead of GR32. This allows them to operate on h registers on x86-64.
3158def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3159 (outs GR32_NOREX:$dst), (ins GR8:$src),
3160 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3161 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003162let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003163def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3164 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3165 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3166 []>, TB;
3167
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003168let neverHasSideEffects = 1 in {
3169 let Defs = [AX], Uses = [AL] in
3170 def CBW : I<0x98, RawFrm, (outs), (ins),
3171 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3172 let Defs = [EAX], Uses = [AX] in
3173 def CWDE : I<0x98, RawFrm, (outs), (ins),
3174 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003175
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003176 let Defs = [AX,DX], Uses = [AX] in
3177 def CWD : I<0x99, RawFrm, (outs), (ins),
3178 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3179 let Defs = [EAX,EDX], Uses = [EAX] in
3180 def CDQ : I<0x99, RawFrm, (outs), (ins),
3181 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3182}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003183
3184//===----------------------------------------------------------------------===//
3185// Alias Instructions
3186//===----------------------------------------------------------------------===//
3187
3188// Alias instructions that map movr0 to xor.
3189// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003190let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3191 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003192def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003193 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003194 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003195// Use xorl instead of xorw since we don't care about the high 16 bits,
3196// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003197def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003198 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3199 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003200def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003201 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003202 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003203}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003204
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003205//===----------------------------------------------------------------------===//
3206// Thread Local Storage Instructions
3207//
3208
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003209// All calls clobber the non-callee saved registers. ESP is marked as
3210// a use to prevent stack-pointer assignments that appear immediately
3211// before calls from potentially appearing dead.
3212let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3213 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3214 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3215 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003216 Uses = [ESP] in
3217def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3218 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003219 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003220 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003221 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003222
Daniel Dunbar75a07302009-08-11 22:24:40 +00003223let AddedComplexity = 5, isCodeGenOnly = 1 in
sampo9cc09a32009-01-26 01:24:32 +00003224def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3225 "movl\t%gs:$src, $dst",
3226 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3227
Daniel Dunbar75a07302009-08-11 22:24:40 +00003228let AddedComplexity = 5, isCodeGenOnly = 1 in
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003229def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3230 "movl\t%fs:$src, $dst",
3231 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3232
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003233//===----------------------------------------------------------------------===//
3234// DWARF Pseudo Instructions
3235//
3236
Evan Chengb783fa32007-07-19 01:14:50 +00003237def DWARF_LOC : I<0, Pseudo, (outs),
3238 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Chris Lattner64b54552009-07-10 22:34:11 +00003239 ".loc\t$file $line $col",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003240 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3241 (i32 imm:$file))]>;
3242
3243//===----------------------------------------------------------------------===//
3244// EH Pseudo Instructions
3245//
3246let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003247 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003248def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003249 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003250 [(X86ehret GR32:$addr)]>;
3251
3252}
3253
3254//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003255// Atomic support
3256//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003257
Evan Cheng3e171562008-04-19 01:20:30 +00003258// Atomic swap. These are just normal xchg instructions. But since a memory
3259// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003260let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003261def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3262 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3263 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3264def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3265 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3266 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3267 OpSize;
3268def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3269 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3270 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3271}
3272
Evan Chengd49dbb82008-04-18 20:55:36 +00003273// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003274let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003275def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003276 "lock\n\t"
3277 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003278 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003279}
Dale Johannesenf160d802008-10-02 18:53:47 +00003280let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003281def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003282 "lock\n\t"
3283 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003284 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3285}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003286
3287let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003288def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003289 "lock\n\t"
3290 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003291 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003292}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003293let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003294def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003295 "lock\n\t"
3296 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003297 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003298}
3299
Evan Chengd49dbb82008-04-18 20:55:36 +00003300// Atomic exchange and add
3301let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3302def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003303 "lock\n\t"
3304 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003305 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003306 TB, LOCK;
3307def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003308 "lock\n\t"
3309 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003310 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003311 TB, OpSize, LOCK;
3312def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003313 "lock\n\t"
3314 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003315 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003316 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003317}
3318
Evan Chengb723fb52009-07-30 08:33:02 +00003319// Optimized codegen when the non-memory output is not used.
3320// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3321def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3322 "lock\n\t"
3323 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3324def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3325 "lock\n\t"
3326 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3327def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3328 "lock\n\t"
3329 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3330def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3331 "lock\n\t"
3332 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3333def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3334 "lock\n\t"
3335 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3336def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3337 "lock\n\t"
3338 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3339def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3340 "lock\n\t"
3341 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3342def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3343 "lock\n\t"
3344 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3345
3346def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3347 "lock\n\t"
3348 "inc{b}\t$dst", []>, LOCK;
3349def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3350 "lock\n\t"
3351 "inc{w}\t$dst", []>, OpSize, LOCK;
3352def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3353 "lock\n\t"
3354 "inc{l}\t$dst", []>, LOCK;
3355
3356def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3357 "lock\n\t"
3358 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3359def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3360 "lock\n\t"
3361 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3362def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3363 "lock\n\t"
3364 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3365def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3366 "lock\n\t"
3367 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3368def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3369 "lock\n\t"
3370 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3371def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3372 "lock\n\t"
3373 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3374def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3375 "lock\n\t"
3376 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3377def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3378 "lock\n\t"
3379 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3380
3381def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3382 "lock\n\t"
3383 "dec{b}\t$dst", []>, LOCK;
3384def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3385 "lock\n\t"
3386 "dec{w}\t$dst", []>, OpSize, LOCK;
3387def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3388 "lock\n\t"
3389 "dec{l}\t$dst", []>, LOCK;
3390
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003391// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003392let Constraints = "$val = $dst", Defs = [EFLAGS],
3393 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003394def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003395 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003396 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003397def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003398 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003399 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003400def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003401 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003402 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003403def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003404 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003405 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003406def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003407 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003408 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003409def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003410 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003411 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003412def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003413 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003414 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003415def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003416 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003417 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003418
3419def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003420 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003421 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003422def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003423 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003424 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003425def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003426 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003427 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003428def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003429 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003430 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003431def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003432 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003433 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003434def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003435 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003436 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003437def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003438 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003439 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003440def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003441 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003442 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003443
3444def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003445 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003446 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003447def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003448 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003449 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003450def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003451 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003452 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003453def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003454 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003455 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003456}
3457
Dale Johannesenf160d802008-10-02 18:53:47 +00003458let Constraints = "$val1 = $dst1, $val2 = $dst2",
3459 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3460 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003461 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003462 usesCustomDAGSchedInserter = 1 in {
3463def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3464 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003465 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003466def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3467 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003468 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003469def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3470 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003471 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003472def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3473 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003474 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003475def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3476 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003477 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003478def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3479 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003480 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003481def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3482 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003483 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003484}
3485
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003486//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003487// Non-Instruction Patterns
3488//===----------------------------------------------------------------------===//
3489
Bill Wendlingfef06052008-09-16 21:48:12 +00003490// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003491def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3492def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003493def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003494def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3495def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3496
3497def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3498 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3499def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3500 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3501def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3502 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3503def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3504 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3505
3506def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3507 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3508def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3509 (MOV32mi addr:$dst, texternalsym:$src)>;
3510
3511// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003512// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003513def : Pat<(X86tcret GR32:$dst, imm:$off),
3514 (TCRETURNri GR32:$dst, imm:$off)>;
3515
3516def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3517 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3518
3519def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3520 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003521
Dan Gohmance5dbff2009-08-02 16:10:01 +00003522// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003523def : Pat<(X86call (i32 tglobaladdr:$dst)),
3524 (CALLpcrel32 tglobaladdr:$dst)>;
3525def : Pat<(X86call (i32 texternalsym:$dst)),
3526 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003527def : Pat<(X86call (i32 imm:$dst)),
3528 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003529
3530// X86 specific add which produces a flag.
3531def : Pat<(addc GR32:$src1, GR32:$src2),
3532 (ADD32rr GR32:$src1, GR32:$src2)>;
3533def : Pat<(addc GR32:$src1, (load addr:$src2)),
3534 (ADD32rm GR32:$src1, addr:$src2)>;
3535def : Pat<(addc GR32:$src1, imm:$src2),
3536 (ADD32ri GR32:$src1, imm:$src2)>;
3537def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3538 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3539
3540def : Pat<(subc GR32:$src1, GR32:$src2),
3541 (SUB32rr GR32:$src1, GR32:$src2)>;
3542def : Pat<(subc GR32:$src1, (load addr:$src2)),
3543 (SUB32rm GR32:$src1, addr:$src2)>;
3544def : Pat<(subc GR32:$src1, imm:$src2),
3545 (SUB32ri GR32:$src1, imm:$src2)>;
3546def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3547 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3548
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003549// Comparisons.
3550
3551// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003552def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003553 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003554def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003555 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003556def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003557 (TEST32rr GR32:$src1, GR32:$src1)>;
3558
Dan Gohman0a3c5222009-01-07 01:00:24 +00003559// Conditional moves with folded loads with operands swapped and conditions
3560// inverted.
3561def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3562 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3563def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3564 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3565def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3566 (CMOVB16rm GR16:$src2, addr:$src1)>;
3567def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3568 (CMOVB32rm GR32:$src2, addr:$src1)>;
3569def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3570 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3571def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3572 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3573def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3574 (CMOVE16rm GR16:$src2, addr:$src1)>;
3575def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3576 (CMOVE32rm GR32:$src2, addr:$src1)>;
3577def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3578 (CMOVA16rm GR16:$src2, addr:$src1)>;
3579def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3580 (CMOVA32rm GR32:$src2, addr:$src1)>;
3581def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3582 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3583def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3584 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3585def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3586 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3587def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3588 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3589def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3590 (CMOVL16rm GR16:$src2, addr:$src1)>;
3591def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3592 (CMOVL32rm GR32:$src2, addr:$src1)>;
3593def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3594 (CMOVG16rm GR16:$src2, addr:$src1)>;
3595def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3596 (CMOVG32rm GR32:$src2, addr:$src1)>;
3597def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3598 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3599def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3600 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3601def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3602 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3603def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3604 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3605def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3606 (CMOVP16rm GR16:$src2, addr:$src1)>;
3607def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3608 (CMOVP32rm GR32:$src2, addr:$src1)>;
3609def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3610 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3611def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3612 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3613def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3614 (CMOVS16rm GR16:$src2, addr:$src1)>;
3615def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3616 (CMOVS32rm GR32:$src2, addr:$src1)>;
3617def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3618 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3619def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3620 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3621def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3622 (CMOVO16rm GR16:$src2, addr:$src1)>;
3623def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3624 (CMOVO32rm GR32:$src2, addr:$src1)>;
3625
Duncan Sands082524c2008-01-23 20:39:46 +00003626// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003627def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3628def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3629def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3630
3631// extload bool -> extload byte
3632def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003633def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003634def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Dan Gohman9959b052009-08-26 14:59:13 +00003635def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003636def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3637def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3638
Dan Gohman9959b052009-08-26 14:59:13 +00003639// anyext. Define these to do an explicit zero-extend to
3640// avoid partial-register updates.
3641def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
3642def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
3643def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003644
Evan Chengf2abee72007-12-13 00:43:27 +00003645// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003646def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3647 (MOVZX32rm8 addr:$src)>;
3648def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3649 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003650
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003651//===----------------------------------------------------------------------===//
3652// Some peepholes
3653//===----------------------------------------------------------------------===//
3654
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003655// Odd encoding trick: -128 fits into an 8-bit immediate field while
3656// +128 doesn't, so in this special case use a sub instead of an add.
3657def : Pat<(add GR16:$src1, 128),
3658 (SUB16ri8 GR16:$src1, -128)>;
3659def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3660 (SUB16mi8 addr:$dst, -128)>;
3661def : Pat<(add GR32:$src1, 128),
3662 (SUB32ri8 GR32:$src1, -128)>;
3663def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3664 (SUB32mi8 addr:$dst, -128)>;
3665
Dan Gohman9203ab42008-07-30 18:09:17 +00003666// r & (2^16-1) ==> movz
3667def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003668 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003669// r & (2^8-1) ==> movz
3670def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003671 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003672 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003673 Requires<[In32BitMode]>;
3674// r & (2^8-1) ==> movz
3675def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003676 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003677 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003678 Requires<[In32BitMode]>;
3679
3680// sext_inreg patterns
3681def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003682 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003683def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003684 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003685 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003686 Requires<[In32BitMode]>;
3687def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003688 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, 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// trunc patterns
3693def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003694 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003695def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003696 (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<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003700 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003701 x86_subreg_8bit)>,
3702 Requires<[In32BitMode]>;
3703
3704// h-register tricks
3705def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003706 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003707 x86_subreg_8bit_hi)>,
3708 Requires<[In32BitMode]>;
3709def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003710 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003711 x86_subreg_8bit_hi)>,
3712 Requires<[In32BitMode]>;
3713def : Pat<(srl_su GR16:$src, (i8 8)),
3714 (EXTRACT_SUBREG
3715 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003716 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003717 x86_subreg_8bit_hi)),
3718 x86_subreg_16bit)>,
3719 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003720def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3721 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3722 x86_subreg_8bit_hi))>,
3723 Requires<[In32BitMode]>;
Dan Gohman9959b052009-08-26 14:59:13 +00003724def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))),
3725 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3726 x86_subreg_8bit_hi))>,
3727 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003728def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003729 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003730 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003731 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003732
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003733// (shl x, 1) ==> (add x, x)
3734def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3735def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3736def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3737
Evan Cheng76a64c72008-08-30 02:03:58 +00003738// (shl x (and y, 31)) ==> (shl x, y)
3739def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3740 (SHL8rCL GR8:$src1)>;
3741def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3742 (SHL16rCL GR16:$src1)>;
3743def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3744 (SHL32rCL GR32:$src1)>;
3745def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3746 (SHL8mCL addr:$dst)>;
3747def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3748 (SHL16mCL addr:$dst)>;
3749def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3750 (SHL32mCL addr:$dst)>;
3751
3752def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3753 (SHR8rCL GR8:$src1)>;
3754def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3755 (SHR16rCL GR16:$src1)>;
3756def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3757 (SHR32rCL GR32:$src1)>;
3758def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3759 (SHR8mCL addr:$dst)>;
3760def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3761 (SHR16mCL addr:$dst)>;
3762def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3763 (SHR32mCL addr:$dst)>;
3764
3765def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3766 (SAR8rCL GR8:$src1)>;
3767def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3768 (SAR16rCL GR16:$src1)>;
3769def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3770 (SAR32rCL GR32:$src1)>;
3771def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3772 (SAR8mCL addr:$dst)>;
3773def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3774 (SAR16mCL addr:$dst)>;
3775def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3776 (SAR32mCL addr:$dst)>;
3777
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003778// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3779def : Pat<(or (srl GR32:$src1, CL:$amt),
3780 (shl GR32:$src2, (sub 32, CL:$amt))),
3781 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3782
3783def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3784 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3785 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3786
Dan Gohman921581d2008-10-17 01:23:35 +00003787def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3788 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3789 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3790
3791def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3792 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3793 addr:$dst),
3794 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3795
3796def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3797 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3798
3799def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3800 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3801 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3802
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003803// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3804def : Pat<(or (shl GR32:$src1, CL:$amt),
3805 (srl GR32:$src2, (sub 32, CL:$amt))),
3806 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3807
3808def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3809 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3810 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3811
Dan Gohman921581d2008-10-17 01:23:35 +00003812def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3813 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3814 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3815
3816def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3817 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3818 addr:$dst),
3819 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3820
3821def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3822 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3823
3824def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3825 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3826 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3827
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003828// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3829def : Pat<(or (srl GR16:$src1, CL:$amt),
3830 (shl GR16:$src2, (sub 16, CL:$amt))),
3831 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3832
3833def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3834 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3835 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3836
Dan Gohman921581d2008-10-17 01:23:35 +00003837def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3838 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3839 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3840
3841def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3842 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3843 addr:$dst),
3844 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3845
3846def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3847 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3848
3849def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3850 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3851 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3852
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003853// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3854def : Pat<(or (shl GR16:$src1, CL:$amt),
3855 (srl GR16:$src2, (sub 16, CL:$amt))),
3856 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3857
3858def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3859 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3860 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3861
Dan Gohman921581d2008-10-17 01:23:35 +00003862def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3863 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3864 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3865
3866def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3867 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3868 addr:$dst),
3869 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3870
3871def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3872 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3873
3874def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3875 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3876 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3877
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003878//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003879// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003880//===----------------------------------------------------------------------===//
3881
Dan Gohman99a12192009-03-04 19:44:21 +00003882// Register-Register Addition with EFLAGS result
3883def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003884 (implicit EFLAGS)),
3885 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003886def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003887 (implicit EFLAGS)),
3888 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003889def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003890 (implicit EFLAGS)),
3891 (ADD32rr GR32:$src1, GR32:$src2)>;
3892
Dan Gohman99a12192009-03-04 19:44:21 +00003893// Register-Memory Addition with EFLAGS result
3894def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003895 (implicit EFLAGS)),
3896 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003897def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003898 (implicit EFLAGS)),
3899 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003900def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003901 (implicit EFLAGS)),
3902 (ADD32rm GR32:$src1, addr:$src2)>;
3903
Dan Gohman99a12192009-03-04 19:44:21 +00003904// Register-Integer Addition with EFLAGS result
3905def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003906 (implicit EFLAGS)),
3907 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003908def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003909 (implicit EFLAGS)),
3910 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003911def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003912 (implicit EFLAGS)),
3913 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003914def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003915 (implicit EFLAGS)),
3916 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003917def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003918 (implicit EFLAGS)),
3919 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3920
Dan Gohman99a12192009-03-04 19:44:21 +00003921// Memory-Register Addition with EFLAGS result
3922def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003923 addr:$dst),
3924 (implicit EFLAGS)),
3925 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003926def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003927 addr:$dst),
3928 (implicit EFLAGS)),
3929 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003930def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003931 addr:$dst),
3932 (implicit EFLAGS)),
3933 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003934
3935// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003936def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003937 addr:$dst),
3938 (implicit EFLAGS)),
3939 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003940def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003941 addr:$dst),
3942 (implicit EFLAGS)),
3943 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003944def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003945 addr:$dst),
3946 (implicit EFLAGS)),
3947 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003948def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003949 addr:$dst),
3950 (implicit EFLAGS)),
3951 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003952def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003953 addr:$dst),
3954 (implicit EFLAGS)),
3955 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3956
Dan Gohman99a12192009-03-04 19:44:21 +00003957// Register-Register Subtraction with EFLAGS result
3958def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003959 (implicit EFLAGS)),
3960 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003961def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003962 (implicit EFLAGS)),
3963 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003964def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003965 (implicit EFLAGS)),
3966 (SUB32rr GR32:$src1, GR32:$src2)>;
3967
Dan Gohman99a12192009-03-04 19:44:21 +00003968// Register-Memory Subtraction with EFLAGS result
3969def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003970 (implicit EFLAGS)),
3971 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003972def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003973 (implicit EFLAGS)),
3974 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003975def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003976 (implicit EFLAGS)),
3977 (SUB32rm GR32:$src1, addr:$src2)>;
3978
Dan Gohman99a12192009-03-04 19:44:21 +00003979// Register-Integer Subtraction with EFLAGS result
3980def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003981 (implicit EFLAGS)),
3982 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003983def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003984 (implicit EFLAGS)),
3985 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003986def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003987 (implicit EFLAGS)),
3988 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003989def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003990 (implicit EFLAGS)),
3991 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003992def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003993 (implicit EFLAGS)),
3994 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3995
Dan Gohman99a12192009-03-04 19:44:21 +00003996// Memory-Register Subtraction with EFLAGS result
3997def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003998 addr:$dst),
3999 (implicit EFLAGS)),
4000 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004001def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004002 addr:$dst),
4003 (implicit EFLAGS)),
4004 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004005def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004006 addr:$dst),
4007 (implicit EFLAGS)),
4008 (SUB32mr addr:$dst, GR32:$src2)>;
4009
Dan Gohman99a12192009-03-04 19:44:21 +00004010// Memory-Integer Subtraction with EFLAGS result
4011def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004012 addr:$dst),
4013 (implicit EFLAGS)),
4014 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004015def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004016 addr:$dst),
4017 (implicit EFLAGS)),
4018 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004019def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004020 addr:$dst),
4021 (implicit EFLAGS)),
4022 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004023def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004024 addr:$dst),
4025 (implicit EFLAGS)),
4026 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004027def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004028 addr:$dst),
4029 (implicit EFLAGS)),
4030 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4031
4032
Dan Gohman99a12192009-03-04 19:44:21 +00004033// Register-Register Signed Integer Multiply with EFLAGS result
4034def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004035 (implicit EFLAGS)),
4036 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004037def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004038 (implicit EFLAGS)),
4039 (IMUL32rr GR32:$src1, GR32:$src2)>;
4040
Dan Gohman99a12192009-03-04 19:44:21 +00004041// Register-Memory Signed Integer Multiply with EFLAGS result
4042def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004043 (implicit EFLAGS)),
4044 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004045def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004046 (implicit EFLAGS)),
4047 (IMUL32rm GR32:$src1, addr:$src2)>;
4048
Dan Gohman99a12192009-03-04 19:44:21 +00004049// Register-Integer Signed Integer Multiply with EFLAGS result
4050def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004051 (implicit EFLAGS)),
4052 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004053def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004054 (implicit EFLAGS)),
4055 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004056def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004057 (implicit EFLAGS)),
4058 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004059def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004060 (implicit EFLAGS)),
4061 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4062
Dan Gohman99a12192009-03-04 19:44:21 +00004063// Memory-Integer Signed Integer Multiply with EFLAGS result
4064def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004065 (implicit EFLAGS)),
4066 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004067def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004068 (implicit EFLAGS)),
4069 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004070def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004071 (implicit EFLAGS)),
4072 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004073def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004074 (implicit EFLAGS)),
4075 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4076
Dan Gohman99a12192009-03-04 19:44:21 +00004077// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004078let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004079def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004080 (implicit EFLAGS)),
4081 (ADD16rr GR16:$src1, GR16:$src1)>;
4082
Dan Gohman99a12192009-03-04 19:44:21 +00004083def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004084 (implicit EFLAGS)),
4085 (ADD32rr GR32:$src1, GR32:$src1)>;
4086}
4087
Dan Gohman99a12192009-03-04 19:44:21 +00004088// INC and DEC with EFLAGS result. Note that these do not set CF.
4089def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4090 (INC8r GR8:$src)>;
4091def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4092 (implicit EFLAGS)),
4093 (INC8m addr:$dst)>;
4094def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4095 (DEC8r GR8:$src)>;
4096def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4097 (implicit EFLAGS)),
4098 (DEC8m addr:$dst)>;
4099
4100def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004101 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004102def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4103 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004104 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004105def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004106 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004107def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4108 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004109 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004110
4111def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004112 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004113def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4114 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004115 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004116def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004117 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004118def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4119 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004120 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004121
Bill Wendlingf5399032008-12-12 21:15:41 +00004122//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004123// Floating Point Stack Support
4124//===----------------------------------------------------------------------===//
4125
4126include "X86InstrFPStack.td"
4127
4128//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00004129// X86-64 Support
4130//===----------------------------------------------------------------------===//
4131
Chris Lattner2de8d2b2008-01-10 05:50:42 +00004132include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00004133
4134//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004135// XMM Floating point support (requires SSE / SSE2)
4136//===----------------------------------------------------------------------===//
4137
4138include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00004139
4140//===----------------------------------------------------------------------===//
4141// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4142//===----------------------------------------------------------------------===//
4143
4144include "X86InstrMMX.td"