blob: 8c80811835818f8ea1c69839ba140b552bafec22 [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
59def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
60
61def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
62
63def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
64
Rafael Espindolaaf759ab2009-04-17 14:35:58 +000065def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066
Rafael Espindolabca99f72009-04-08 21:14:34 +000067def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068
69def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
70
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000071def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
72
Evan Cheng48679f42007-12-14 02:13:44 +000073def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
74def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000075def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
76def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
77
Evan Cheng621216e2007-09-29 00:00:36 +000078def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000080def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
81
Evan Cheng621216e2007-09-29 00:00:36 +000082def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000084 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000085def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000087def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
89 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000090def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
91 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
92 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000093def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
94 [SDNPHasChain, SDNPMayStore,
95 SDNPMayLoad, SDNPMemOperand]>;
96def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
97 [SDNPHasChain, SDNPMayStore,
98 SDNPMayLoad, SDNPMemOperand]>;
99def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
100 [SDNPHasChain, SDNPMayStore,
101 SDNPMayLoad, SDNPMemOperand]>;
102def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
103 [SDNPHasChain, SDNPMayStore,
104 SDNPMayLoad, SDNPMemOperand]>;
105def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
106 [SDNPHasChain, SDNPMayStore,
107 SDNPMayLoad, SDNPMemOperand]>;
108def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
109 [SDNPHasChain, SDNPMayStore,
110 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000111def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
112 [SDNPHasChain, SDNPMayStore,
113 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000114def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
115 [SDNPHasChain, SDNPOptInFlag]>;
116
117def X86callseq_start :
118 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
119 [SDNPHasChain, SDNPOutFlag]>;
120def X86callseq_end :
121 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000122 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123
124def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
125 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
126
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000127def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000128 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000129def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000130 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
131 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132
133def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000134 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135
136def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
137def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
138
139def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000140 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000141def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
142 SDT_X86SegmentBaseAddress, []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000143
144def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
145 [SDNPHasChain]>;
146
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000147def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
148 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000149
Dan Gohman99a12192009-03-04 19:44:21 +0000150def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
151def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
152def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
153def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
154def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
155def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000156
Evan Chengc3495762009-03-30 21:36:47 +0000157def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
158
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000159//===----------------------------------------------------------------------===//
160// X86 Operand Definitions.
161//
162
Chris Lattner357a0ca2009-06-20 19:34:09 +0000163def i32imm_pcrel : Operand<i32> {
164 let PrintMethod = "print_pcrel_imm";
165}
166
Dan Gohmanfe606822009-07-30 01:56:29 +0000167// A version of ptr_rc which excludes SP, ESP, and RSP. This is used for
168// the index operand of an address, to conform to x86 encoding restrictions.
169def ptr_rc_nosp : PointerLikeRegClass<1>;
Chris Lattner357a0ca2009-06-20 19:34:09 +0000170
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171// *mem - Operand definitions for the funky X86 addressing mode operands.
172//
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000173def X86MemAsmOperand : AsmOperandClass {
174 let Name = "Mem";
Daniel Dunbar6e9ee792009-08-10 19:08:02 +0000175 let SuperClass = ?;
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000176}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177class X86MemOperand<string printMethod> : Operand<iPTR> {
178 let PrintMethod = printMethod;
Dan Gohmanfe606822009-07-30 01:56:29 +0000179 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000180 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181}
182
183def i8mem : X86MemOperand<"printi8mem">;
184def i16mem : X86MemOperand<"printi16mem">;
185def i32mem : X86MemOperand<"printi32mem">;
186def i64mem : X86MemOperand<"printi64mem">;
187def i128mem : X86MemOperand<"printi128mem">;
David Greene6b75fca2009-06-30 19:24:59 +0000188def i256mem : X86MemOperand<"printi256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000189def f32mem : X86MemOperand<"printf32mem">;
190def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000191def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192def f128mem : X86MemOperand<"printf128mem">;
David Greene6b75fca2009-06-30 19:24:59 +0000193def f256mem : X86MemOperand<"printf256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000194
Dan Gohman744d4622009-04-13 16:09:41 +0000195// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
196// plain GR64, so that it doesn't potentially require a REX prefix.
197def i8mem_NOREX : Operand<i64> {
198 let PrintMethod = "printi8mem";
Dan Gohmanfe606822009-07-30 01:56:29 +0000199 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX_NOSP, i32imm, i8imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000200 let ParserMatchClass = X86MemAsmOperand;
Dan Gohman744d4622009-04-13 16:09:41 +0000201}
202
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000203def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000204 let PrintMethod = "printlea32mem";
Dan Gohmanefbd3bc2009-08-05 17:40:24 +0000205 let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm);
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000206 let ParserMatchClass = X86MemAsmOperand;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000207}
208
209def SSECC : Operand<i8> {
210 let PrintMethod = "printSSECC";
211}
212
213def piclabel: Operand<i32> {
214 let PrintMethod = "printPICLabel";
215}
216
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000217def ImmSExt8AsmOperand : AsmOperandClass {
218 let Name = "ImmSExt8";
219 let SuperClass = ImmAsmOperand;
220}
221
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000222// A couple of more descriptive operand definitions.
223// 16-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000224def i16i8imm : Operand<i16> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000225 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000226}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000227// 32-bits but only 8 bits are significant.
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000228def i32i8imm : Operand<i32> {
Daniel Dunbar0f10cbf2009-08-10 18:41:10 +0000229 let ParserMatchClass = ImmSExt8AsmOperand;
Daniel Dunbar06d5cb62009-08-09 07:20:21 +0000230}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231
Chris Lattner357a0ca2009-06-20 19:34:09 +0000232// Branch targets have OtherVT type and print as pc-relative values.
233def brtarget : Operand<OtherVT> {
234 let PrintMethod = "print_pcrel_imm";
235}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000236
Evan Chengd11052b2009-07-21 06:00:18 +0000237def brtarget8 : Operand<OtherVT> {
238 let PrintMethod = "print_pcrel_imm";
239}
240
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000241//===----------------------------------------------------------------------===//
242// X86 Complex Pattern Definitions.
243//
244
245// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000246def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman0c0d7412009-08-02 16:09:17 +0000248 [add, sub, mul, X86mul_imm, shl, or, frameindex],
249 []>;
Chris Lattnerf1940742009-06-20 20:38:48 +0000250def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
251 [tglobaltlsaddr], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000252
253//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000254// X86 Instruction Predicate Definitions.
255def HasMMX : Predicate<"Subtarget->hasMMX()">;
256def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
257def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
258def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
259def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000260def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
261def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene8bf22bc2009-06-26 22:46:54 +0000262def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
263def HasAVX : Predicate<"Subtarget->hasAVX()">;
264def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
265def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000266def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
267def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000268def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
269def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Anton Korobeynikov2cbcdb72009-08-03 08:12:53 +0000270def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
271def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000272def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
273def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
274def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
Anton Korobeynikov7e1178f2009-08-06 09:11:19 +0000275 "TM.getCodeModel() != CodeModel::Kernel">;
Anton Korobeynikov68d4eca2009-08-06 11:23:24 +0000276def NearData : Predicate<"TM.getCodeModel() == CodeModel::Small ||"
277 "TM.getCodeModel() == CodeModel::Kernel">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000278def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000279def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000280def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000281def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282
283//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000284// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000285//
286
Evan Cheng86ab7d32007-07-31 08:04:03 +0000287include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000288
289//===----------------------------------------------------------------------===//
290// Pattern fragments...
291//
292
293// X86 specific condition code. These correspond to CondCode in
294// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000295def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
296def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
297def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
298def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
299def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
300def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
301def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
302def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
303def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
304def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000306def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000308def X86_COND_O : PatLeaf<(i8 13)>;
309def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
310def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311
312def i16immSExt8 : PatLeaf<(i16 imm), [{
313 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
314 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000315 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316}]>;
317
318def i32immSExt8 : PatLeaf<(i32 imm), [{
319 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
320 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000321 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322}]>;
323
324// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000325// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
326// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000327def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000328 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000329 if (const Value *Src = LD->getSrcValue())
330 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000331 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000332 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000333 ISD::LoadExtType ExtType = LD->getExtensionType();
334 if (ExtType == ISD::NON_EXTLOAD)
335 return true;
336 if (ExtType == ISD::EXTLOAD)
337 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000338 return false;
339}]>;
340
Dan Gohman2a174122008-10-15 06:50:19 +0000341def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000342 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000343 if (const Value *Src = LD->getSrcValue())
344 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000345 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000346 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000347 ISD::LoadExtType ExtType = LD->getExtensionType();
348 if (ExtType == ISD::EXTLOAD)
349 return LD->getAlignment() >= 2 && !LD->isVolatile();
350 return false;
351}]>;
352
Dan Gohman2a174122008-10-15 06:50:19 +0000353def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000354 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000355 if (const Value *Src = LD->getSrcValue())
356 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000357 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000358 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000359 ISD::LoadExtType ExtType = LD->getExtensionType();
360 if (ExtType == ISD::NON_EXTLOAD)
361 return true;
362 if (ExtType == ISD::EXTLOAD)
363 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000364 return false;
365}]>;
366
Dan Gohman2a174122008-10-15 06:50:19 +0000367def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000368 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000369 if (const Value *Src = LD->getSrcValue())
370 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000371 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000372 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000373 if (LD->isVolatile())
374 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000375 ISD::LoadExtType ExtType = LD->getExtensionType();
376 if (ExtType == ISD::NON_EXTLOAD)
377 return true;
378 if (ExtType == ISD::EXTLOAD)
379 return LD->getAlignment() >= 4;
380 return false;
381}]>;
382
sampo9cc09a32009-01-26 01:24:32 +0000383def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000384 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
385 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
386 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000387 return false;
388}]>;
389
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000390def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
391 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
392 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
393 return PT->getAddressSpace() == 257;
394 return false;
395}]>;
396
Chris Lattner12208612009-04-10 00:16:23 +0000397def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
398 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
399 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000400 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000401 return false;
402 return true;
403}]>;
404def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
405 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
406 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000407 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000408 return false;
409 return true;
410}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411
Chris Lattner12208612009-04-10 00:16:23 +0000412def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
413 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
414 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000415 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000416 return false;
417 return true;
418}]>;
419def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
420 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
421 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000422 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000423 return false;
424 return true;
425}]>;
426def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
427 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
428 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000429 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000430 return false;
431 return true;
432}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000433
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
435def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
436def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
437
438def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
439def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
440def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
441def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
442def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
443def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
444
445def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
446def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
447def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
448def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
449def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
450def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
451
Chris Lattner21da6382008-02-19 17:37:35 +0000452
453// An 'and' node with a single use.
454def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000455 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000456}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000457// An 'srl' node with a single use.
458def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
459 return N->hasOneUse();
460}]>;
461// An 'trunc' node with a single use.
462def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
463 return N->hasOneUse();
464}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000465
Dan Gohman921581d2008-10-17 01:23:35 +0000466// 'shld' and 'shrd' instruction patterns. Note that even though these have
467// the srl and shl in their patterns, the C++ code must still check for them,
468// because predicates are tested before children nodes are explored.
469
470def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
471 (or (srl node:$src1, node:$amt1),
472 (shl node:$src2, node:$amt2)), [{
473 assert(N->getOpcode() == ISD::OR);
474 return N->getOperand(0).getOpcode() == ISD::SRL &&
475 N->getOperand(1).getOpcode() == ISD::SHL &&
476 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
477 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
478 N->getOperand(0).getConstantOperandVal(1) ==
479 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
480}]>;
481
482def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
483 (or (shl node:$src1, node:$amt1),
484 (srl node:$src2, node:$amt2)), [{
485 assert(N->getOpcode() == ISD::OR);
486 return N->getOperand(0).getOpcode() == ISD::SHL &&
487 N->getOperand(1).getOpcode() == ISD::SRL &&
488 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
489 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
490 N->getOperand(0).getConstantOperandVal(1) ==
491 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
492}]>;
493
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000495// Instruction list...
496//
497
498// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
499// a stack adjustment and the codegen must know that they may modify the stack
500// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000501// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
502// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000503let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000504def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
505 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000506 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000507 Requires<[In32BitMode]>;
508def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
509 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000510 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000511 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000512}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000513
514// Nop
Sean Callananf94a0542009-07-23 23:39:34 +0000515let neverHasSideEffects = 1 in {
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000516 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callananf94a0542009-07-23 23:39:34 +0000517 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
518 "nopl\t$zero", []>, TB;
519}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000520
Sean Callanan9b195f82009-08-11 01:09:06 +0000521// Trap
522def INT3 : I<0xcc, RawFrm, (outs), (ins), "int 3", []>;
523def INT : I<0xcd, RawFrm, (outs), (ins i8imm:$trap), "int\t$trap", []>;
524
Evan Cheng0729ccf2008-01-05 00:41:47 +0000525// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000526let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000527 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman70a8a112009-04-27 15:13:28 +0000528 "call\t$label\n\t"
529 "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530
531//===----------------------------------------------------------------------===//
532// Control Flow Instructions...
533//
534
535// Return instructions.
536let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000537 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000538 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000539 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000540 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000541 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
542 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543 [(X86retflag imm:$amt)]>;
544}
545
546// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000547let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000548 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
549 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550
Sean Callananc0608152009-07-22 01:05:20 +0000551let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000552 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000553 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
554}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000555
Owen Andersonf8053082007-11-12 07:39:39 +0000556// Indirect branches
557let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000558 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000560 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561 [(brind (loadi32 addr:$dst))]>;
562}
563
564// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000565let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000566// Short conditional jumps
567def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
568def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
569def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
570def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
571def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
572def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
573def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
574def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
575def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
576def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
577def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
578def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
579def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
580def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
581def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
582def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
583
584def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
585
Dan Gohman91888f02007-07-31 20:11:57 +0000586def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000587 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000588def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000589 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000590def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000591 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000592def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000593 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000594def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000595 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000596def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000597 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598
Dan Gohman91888f02007-07-31 20:11:57 +0000599def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000600 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000601def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000602 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000603def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000604 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000605def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000606 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607
Dan Gohman91888f02007-07-31 20:11:57 +0000608def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000609 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000610def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000611 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000612def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000613 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000614def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000615 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000616def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000617 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000618def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000619 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000620} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621
622//===----------------------------------------------------------------------===//
623// Call Instructions...
624//
Evan Cheng37e7c752007-07-21 00:34:19 +0000625let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000626 // All calls clobber the non-callee saved registers. ESP is marked as
627 // a use to prevent stack-pointer assignments that appear immediately
628 // before calls from potentially appearing dead. Uses for argument
629 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
631 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000632 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
633 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000634 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000635 def CALLpcrel32 : Ii32<0xE8, RawFrm,
636 (outs), (ins i32imm_pcrel:$dst,variable_ops),
637 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000638 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000639 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000640 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000641 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642 }
643
644// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000645
Evan Cheng37e7c752007-07-21 00:34:19 +0000646let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000647def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000648 "#TC_RETURN $dst $offset",
649 []>;
650
651let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000652def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000653 "#TC_RETURN $dst $offset",
654 []>;
655
656let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000657
Chris Lattner357a0ca2009-06-20 19:34:09 +0000658 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000660let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000661 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
662 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000663let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000664 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000665 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666
667//===----------------------------------------------------------------------===//
668// Miscellaneous Instructions...
669//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000670let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000671def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000672 (outs), (ins), "leave", []>;
673
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000674let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
675let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000676def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000678let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000679def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000680}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000681
Bill Wendling4c2638c2009-06-15 19:39:04 +0000682let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
683def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000684 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000685def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000686 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000687def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000688 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000689}
690
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000691let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000692def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000693let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000694def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000695
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696let isTwoAddress = 1 in // GR32 = bswap GR32
697 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000698 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000699 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
701
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702
Evan Cheng48679f42007-12-14 02:13:44 +0000703// Bit scan instructions.
704let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000705def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000706 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000707 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000708def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000709 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000710 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
711 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000712def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000713 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000714 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000715def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000716 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000717 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
718 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000719
Evan Cheng4e33de92007-12-14 18:49:43 +0000720def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000721 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000722 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000723def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000724 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000725 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
726 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000727def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000728 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000729 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000730def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000731 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000732 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
733 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000734} // Defs = [EFLAGS]
735
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000736let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000738 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000739 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000740let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000742 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000743 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000744 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
745
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000746let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000747def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000748 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000749def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000750 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000751def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000752 [(X86rep_movs i32)]>, REP;
753}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000755let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000756def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000757 [(X86rep_stos i8)]>, REP;
758let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000759def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000760 [(X86rep_stos i16)]>, REP, OpSize;
761let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000762def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000763 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000765let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000766def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000767 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000769let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000770def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000771}
772
Chris Lattnerc96e27c2009-08-11 16:58:39 +0000773def SYSCALL : I<0x05, RawFrm,
774 (outs), (ins), "syscall", []>, TB;
775def SYSRET : I<0x07, RawFrm,
776 (outs), (ins), "sysret", []>, TB;
777def SYSENTER : I<0x34, RawFrm,
778 (outs), (ins), "sysenter", []>, TB;
779def SYSEXIT : I<0x35, RawFrm,
780 (outs), (ins), "sysexit", []>, TB;
781
782
783
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784//===----------------------------------------------------------------------===//
785// Input/Output Instructions...
786//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000787let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000788def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000789 "in{b}\t{%dx, %al|%AL, %DX}", []>;
790let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000791def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000792 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
793let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000794def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000795 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000797let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000798def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000799 "in{b}\t{$port, %al|%AL, $port}", []>;
800let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000801def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000802 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
803let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000804def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000805 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000807let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000808def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000809 "out{b}\t{%al, %dx|%DX, %AL}", []>;
810let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000811def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000812 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
813let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000814def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000815 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000817let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000818def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000819 "out{b}\t{%al, $port|$port, %AL}", []>;
820let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000821def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000822 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
823let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000824def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000825 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826
827//===----------------------------------------------------------------------===//
828// Move Instructions...
829//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000830let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000831def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000832 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000833def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000834 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000835def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000836 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000837}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000838let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000839def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000840 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000842def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000843 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000845def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000846 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000847 [(set GR32:$dst, imm:$src)]>;
848}
Evan Chengb783fa32007-07-19 01:14:50 +0000849def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000850 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000852def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000853 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000855def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000856 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 [(store (i32 imm:$src), addr:$dst)]>;
858
Dan Gohman5574cc72008-12-03 18:15:48 +0000859let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000860def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000862 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000863def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000864 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000865 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000866def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000867 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000868 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000869}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870
Evan Chengb783fa32007-07-19 01:14:50 +0000871def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000872 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000874def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000875 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000877def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000878 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000880
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000881// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
882// that they can be used for copying and storing h registers, which can't be
883// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000884let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000885def MOV8rr_NOREX : I<0x88, MRMDestReg,
886 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000887 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000888let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000889def MOV8mr_NOREX : I<0x88, MRMDestMem,
890 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
891 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000892let mayLoad = 1,
893 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000894def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
895 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
896 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000897
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898//===----------------------------------------------------------------------===//
899// Fixed-Register Multiplication and Division Instructions...
900//
901
902// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000903let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000904def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
906 // This probably ought to be moved to a def : Pat<> if the
907 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000908 [(set AL, (mul AL, GR8:$src)),
909 (implicit EFLAGS)]>; // AL,AH = AL*GR8
910
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000911let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000912def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
913 "mul{w}\t$src",
914 []>, OpSize; // AX,DX = AX*GR16
915
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000916let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000917def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
918 "mul{l}\t$src",
919 []>; // EAX,EDX = EAX*GR32
920
Evan Cheng55687072007-09-14 21:48:26 +0000921let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000922def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000923 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000924 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
925 // This probably ought to be moved to a def : Pat<> if the
926 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000927 [(set AL, (mul AL, (loadi8 addr:$src))),
928 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
929
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000930let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000931let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000932def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000933 "mul{w}\t$src",
934 []>, OpSize; // AX,DX = AX*[mem16]
935
Evan Cheng55687072007-09-14 21:48:26 +0000936let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000937def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000938 "mul{l}\t$src",
939 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000940}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000942let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000943let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000944def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
945 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000946let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000947def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000948 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000949let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000950def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
951 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000952let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000953let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000954def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000955 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000956let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000957def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000958 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
959let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000960def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000961 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000962}
Dan Gohmand44572d2008-11-18 21:29:14 +0000963} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964
965// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000966let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000967def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000968 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000969let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000970def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000971 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000972let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000973def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000974 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000975let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000976let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000977def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000978 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000979let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000980def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000981 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000982let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000983def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000984 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000985}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986
987// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000988let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000989def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000990 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000991let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000992def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000993 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000994let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000995def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000996 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000997let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000998let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000999def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001000 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +00001001let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001002def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001003 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +00001004let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +00001005def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001006 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001007}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008
1009//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00001010// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011//
1012let isTwoAddress = 1 in {
1013
1014// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +00001015let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +00001016let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001017def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001018 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001019 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001021 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001024 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001025 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001027 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001030 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001031 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001033 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001036 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001037 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001038 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001039 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001042 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001043 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001045 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001048 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001049 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001051 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001054 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001055 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001057 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001060 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001061 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001063 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001066 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001067 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001069 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001072 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001073 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001075 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001078 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001079 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001080 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001081 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001084 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001085 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001087 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001088 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001090 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001091 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001092 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001093 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001096 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001097 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001099 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001101def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001102 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001103 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001105 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001107def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001108 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001109 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001110 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001111 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001114 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001115 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001116 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001117 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001120 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001121 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001123 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001125def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001126 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001127 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001128 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001129 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001131def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001132 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001133 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001134 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001135 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001138 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001139 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001141 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001142 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001144 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001145 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001147 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001149def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001150 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001151 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001153 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001155def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001156 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001157 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001159 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001162 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001163 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001165 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001167def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001168 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001169 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001171 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001172 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001173def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001174 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001175 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001176 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001177 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001178 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001180 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001181 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001183 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001185def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1186 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1187 "cmovo\t{$src2, $dst|$dst, $src2}",
1188 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1189 X86_COND_O, EFLAGS))]>,
1190 TB, OpSize;
1191def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1192 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1193 "cmovo\t{$src2, $dst|$dst, $src2}",
1194 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1195 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001196 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001197def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1198 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1199 "cmovno\t{$src2, $dst|$dst, $src2}",
1200 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1201 X86_COND_NO, EFLAGS))]>,
1202 TB, OpSize;
1203def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1204 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1205 "cmovno\t{$src2, $dst|$dst, $src2}",
1206 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1207 X86_COND_NO, EFLAGS))]>,
1208 TB;
1209} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001210
1211def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1212 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1213 "cmovb\t{$src2, $dst|$dst, $src2}",
1214 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1215 X86_COND_B, EFLAGS))]>,
1216 TB, OpSize;
1217def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1218 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1219 "cmovb\t{$src2, $dst|$dst, $src2}",
1220 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1221 X86_COND_B, EFLAGS))]>,
1222 TB;
1223def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1224 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1225 "cmovae\t{$src2, $dst|$dst, $src2}",
1226 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1227 X86_COND_AE, EFLAGS))]>,
1228 TB, OpSize;
1229def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1230 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1231 "cmovae\t{$src2, $dst|$dst, $src2}",
1232 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1233 X86_COND_AE, EFLAGS))]>,
1234 TB;
1235def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1236 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1237 "cmove\t{$src2, $dst|$dst, $src2}",
1238 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1239 X86_COND_E, EFLAGS))]>,
1240 TB, OpSize;
1241def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1242 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1243 "cmove\t{$src2, $dst|$dst, $src2}",
1244 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1245 X86_COND_E, EFLAGS))]>,
1246 TB;
1247def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1248 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1249 "cmovne\t{$src2, $dst|$dst, $src2}",
1250 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1251 X86_COND_NE, EFLAGS))]>,
1252 TB, OpSize;
1253def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1254 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1255 "cmovne\t{$src2, $dst|$dst, $src2}",
1256 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1257 X86_COND_NE, EFLAGS))]>,
1258 TB;
1259def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1260 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1261 "cmovbe\t{$src2, $dst|$dst, $src2}",
1262 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1263 X86_COND_BE, EFLAGS))]>,
1264 TB, OpSize;
1265def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1266 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1267 "cmovbe\t{$src2, $dst|$dst, $src2}",
1268 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1269 X86_COND_BE, EFLAGS))]>,
1270 TB;
1271def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1272 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1273 "cmova\t{$src2, $dst|$dst, $src2}",
1274 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1275 X86_COND_A, EFLAGS))]>,
1276 TB, OpSize;
1277def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1278 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1279 "cmova\t{$src2, $dst|$dst, $src2}",
1280 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1281 X86_COND_A, EFLAGS))]>,
1282 TB;
1283def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1284 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1285 "cmovl\t{$src2, $dst|$dst, $src2}",
1286 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1287 X86_COND_L, EFLAGS))]>,
1288 TB, OpSize;
1289def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1290 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1291 "cmovl\t{$src2, $dst|$dst, $src2}",
1292 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1293 X86_COND_L, EFLAGS))]>,
1294 TB;
1295def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1296 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1297 "cmovge\t{$src2, $dst|$dst, $src2}",
1298 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1299 X86_COND_GE, EFLAGS))]>,
1300 TB, OpSize;
1301def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1302 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1303 "cmovge\t{$src2, $dst|$dst, $src2}",
1304 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1305 X86_COND_GE, EFLAGS))]>,
1306 TB;
1307def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1308 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1309 "cmovle\t{$src2, $dst|$dst, $src2}",
1310 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1311 X86_COND_LE, EFLAGS))]>,
1312 TB, OpSize;
1313def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1314 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1315 "cmovle\t{$src2, $dst|$dst, $src2}",
1316 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1317 X86_COND_LE, EFLAGS))]>,
1318 TB;
1319def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1320 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1321 "cmovg\t{$src2, $dst|$dst, $src2}",
1322 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1323 X86_COND_G, EFLAGS))]>,
1324 TB, OpSize;
1325def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1326 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1327 "cmovg\t{$src2, $dst|$dst, $src2}",
1328 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1329 X86_COND_G, EFLAGS))]>,
1330 TB;
1331def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1332 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1333 "cmovs\t{$src2, $dst|$dst, $src2}",
1334 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1335 X86_COND_S, EFLAGS))]>,
1336 TB, OpSize;
1337def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1338 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1339 "cmovs\t{$src2, $dst|$dst, $src2}",
1340 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1341 X86_COND_S, EFLAGS))]>,
1342 TB;
1343def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1344 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1345 "cmovns\t{$src2, $dst|$dst, $src2}",
1346 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1347 X86_COND_NS, EFLAGS))]>,
1348 TB, OpSize;
1349def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1350 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1351 "cmovns\t{$src2, $dst|$dst, $src2}",
1352 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1353 X86_COND_NS, EFLAGS))]>,
1354 TB;
1355def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1356 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1357 "cmovp\t{$src2, $dst|$dst, $src2}",
1358 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1359 X86_COND_P, EFLAGS))]>,
1360 TB, OpSize;
1361def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1362 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1363 "cmovp\t{$src2, $dst|$dst, $src2}",
1364 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1365 X86_COND_P, EFLAGS))]>,
1366 TB;
1367def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1368 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1369 "cmovnp\t{$src2, $dst|$dst, $src2}",
1370 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1371 X86_COND_NP, EFLAGS))]>,
1372 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001373def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1374 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1375 "cmovnp\t{$src2, $dst|$dst, $src2}",
1376 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1377 X86_COND_NP, EFLAGS))]>,
1378 TB;
1379def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1380 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1381 "cmovo\t{$src2, $dst|$dst, $src2}",
1382 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1383 X86_COND_O, EFLAGS))]>,
1384 TB, OpSize;
1385def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1386 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1387 "cmovo\t{$src2, $dst|$dst, $src2}",
1388 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1389 X86_COND_O, EFLAGS))]>,
1390 TB;
1391def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1392 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1393 "cmovno\t{$src2, $dst|$dst, $src2}",
1394 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1395 X86_COND_NO, EFLAGS))]>,
1396 TB, OpSize;
1397def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1398 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1399 "cmovno\t{$src2, $dst|$dst, $src2}",
1400 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1401 X86_COND_NO, EFLAGS))]>,
1402 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001403} // Uses = [EFLAGS]
1404
1405
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406// unary instructions
1407let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001408let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001409def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001410 [(set GR8:$dst, (ineg GR8:$src)),
1411 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001412def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001413 [(set GR16:$dst, (ineg GR16:$src)),
1414 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001415def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001416 [(set GR32:$dst, (ineg GR32:$src)),
1417 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001419 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001420 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1421 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001422 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001423 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1424 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001425 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001426 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1427 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428}
Evan Cheng55687072007-09-14 21:48:26 +00001429} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001430
Evan Chengc6cee682009-01-21 02:09:05 +00001431// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1432let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001433def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001434 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001435def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001436 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001437def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001439}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001441 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001443 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001444 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001445 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001446 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1447}
1448} // CodeSize
1449
1450// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001451let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001452let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001453def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001454 [(set GR8:$dst, (add GR8:$src, 1)),
1455 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001456let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001457def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001458 [(set GR16:$dst, (add GR16:$src, 1)),
1459 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001460 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001461def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001462 [(set GR32:$dst, (add GR32:$src, 1)),
1463 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001464}
1465let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001466 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001467 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1468 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001469 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001470 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1471 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001472 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001473 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001474 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1475 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001476 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001477}
1478
1479let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001480def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001481 [(set GR8:$dst, (add GR8:$src, -1)),
1482 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001483let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001484def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001485 [(set GR16:$dst, (add GR16:$src, -1)),
1486 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001487 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001488def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001489 [(set GR32:$dst, (add GR32:$src, -1)),
1490 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001491}
1492
1493let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001494 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001495 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1496 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001497 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001498 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1499 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001500 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001501 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001502 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1503 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001504 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505}
Evan Cheng55687072007-09-14 21:48:26 +00001506} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001507
1508// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001509let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001510let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1511def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001512 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001513 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001514 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1515 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001517 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001518 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001519 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1520 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001521def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001522 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001523 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001524 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1525 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001526}
1527
1528def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001529 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001530 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001531 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001532 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001534 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001535 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001536 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001537 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001538def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001539 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001540 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001541 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001542 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543
1544def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001545 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001546 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001547 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1548 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001549def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001550 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001552 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1553 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001555 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001557 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1558 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001559def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001560 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001561 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001562 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1563 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564 OpSize;
1565def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001566 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001568 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1569 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001570
1571let isTwoAddress = 0 in {
1572 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001573 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001574 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001575 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1576 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001577 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001578 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001579 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001580 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1581 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001582 OpSize;
1583 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001584 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001585 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001586 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1587 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001588 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001589 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001590 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001591 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1592 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001593 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001594 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001595 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001596 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1597 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001598 OpSize;
1599 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001600 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001601 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001602 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1603 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001604 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001605 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001607 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1608 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609 OpSize;
1610 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001611 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001612 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001613 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1614 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615}
1616
1617
1618let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001619def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001620 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001621 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1622 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001623def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001624 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001625 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1626 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001627def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001629 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1630 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631}
Evan Chengb783fa32007-07-19 01:14:50 +00001632def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001633 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001634 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1635 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001636def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001637 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001638 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1639 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001640def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001642 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1643 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644
Evan Chengb783fa32007-07-19 01:14:50 +00001645def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001646 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001647 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1648 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001649def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001650 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001651 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1652 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001653def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001654 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001655 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1656 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001657
Evan Chengb783fa32007-07-19 01:14:50 +00001658def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001659 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001660 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1661 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001662def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001664 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1665 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001666let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001667 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001668 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001669 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1670 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001671 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001672 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001673 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1674 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001675 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001676 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001677 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1678 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001679 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001681 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1682 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001683 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001685 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1686 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001688 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001690 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1691 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001692 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$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), i16immSExt8:$src), addr:$dst),
1695 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001696 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001697 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001698 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001699 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1700 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001701} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001702
1703
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001704let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001705 def XOR8rr : I<0x30, MRMDestReg,
1706 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1707 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001708 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1709 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001710 def XOR16rr : I<0x31, MRMDestReg,
1711 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1712 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001713 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1714 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001715 def XOR32rr : I<0x31, MRMDestReg,
1716 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1717 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001718 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1719 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001720} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721
1722def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001723 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001725 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1726 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001728 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001730 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1731 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001732 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001734 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001736 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1737 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001739def XOR8ri : Ii8<0x80, MRM6r,
1740 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1741 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001742 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1743 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001744def XOR16ri : Ii16<0x81, MRM6r,
1745 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1746 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001747 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1748 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001749def XOR32ri : Ii32<0x81, MRM6r,
1750 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1751 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001752 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1753 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001754def XOR16ri8 : Ii8<0x83, MRM6r,
1755 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1756 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001757 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1758 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001759 OpSize;
1760def XOR32ri8 : Ii8<0x83, MRM6r,
1761 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1762 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001763 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1764 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001765
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766let isTwoAddress = 0 in {
1767 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001768 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001770 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1771 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001772 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001773 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001774 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001775 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1776 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001777 OpSize;
1778 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001779 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001780 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001781 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1782 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001783 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001784 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001785 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001786 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1787 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001789 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001790 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001791 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1792 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 OpSize;
1794 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001795 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001796 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001797 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1798 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001800 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001801 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001802 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1803 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001804 OpSize;
1805 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001806 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001808 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1809 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001810} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001811} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812
1813// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001814let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001815let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001816def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001817 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001818 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001819def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001820 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001821 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001822def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001823 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001824 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001825} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826
Evan Chengb783fa32007-07-19 01:14:50 +00001827def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1830let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001831def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001834def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001837// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1838// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001839} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840
1841let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001842 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001843 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001844 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001845 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001846 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001847 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001848 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001849 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001850 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001851 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1852 }
Evan Chengb783fa32007-07-19 01:14:50 +00001853 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001854 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001856 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001857 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001858 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1859 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001860 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1863
1864 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001865 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001866 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001867 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001868 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001869 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001870 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1871 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001872 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001873 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001874 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1875}
1876
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001877let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001878def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001879 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001880 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001881def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001882 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001883 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001884def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001885 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001886 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1887}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888
Evan Chengb783fa32007-07-19 01:14:50 +00001889def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001892def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001894 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001895def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001896 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001897 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1898
1899// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001900def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001903def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001905 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001906def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1909
1910let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001911 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001912 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001913 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001914 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001915 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001916 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001917 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001918 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001919 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001920 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001921 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1922 }
Evan Chengb783fa32007-07-19 01:14:50 +00001923 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001924 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001925 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001926 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001927 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001928 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1929 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001930 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001931 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1933
1934 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001935 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001936 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001937 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001938 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001939 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001940 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001941 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001942 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1944}
1945
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001946let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001947def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001948 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001949 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001950def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001951 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001952 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001953def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001954 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001955 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1956}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001957
Evan Chengb783fa32007-07-19 01:14:50 +00001958def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001961def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1964 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001965def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1968
1969// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001970def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001971 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001973def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001974 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001976def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001977 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1979
1980let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001981 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001982 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001983 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001984 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001985 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001986 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001987 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001988 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001989 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001990 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1991 }
Evan Chengb783fa32007-07-19 01:14:50 +00001992 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001993 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001994 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001995 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001996 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001997 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1998 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001999 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2002
2003 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002004 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002005 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002006 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002007 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2010 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002011 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002012 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002013 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2014}
2015
2016// Rotate instructions
2017// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002018let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002019def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002020 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002021 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002022def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002023 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002024 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002025def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002026 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002027 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
2028}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029
Evan Chengb783fa32007-07-19 01:14:50 +00002030def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002031 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002032 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002033def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002034 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002035 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002036def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002037 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002038 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2039
2040// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002041def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002042 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002043 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002044def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002047def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002048 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2050
2051let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002052 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002053 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002054 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002055 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002056 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002057 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002058 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002059 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002060 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002061 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2062 }
Evan Chengb783fa32007-07-19 01:14:50 +00002063 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002066 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002067 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002068 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2069 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002070 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002071 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2073
2074 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002075 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002076 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002078 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002080 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2081 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002082 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002083 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2085}
2086
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002087let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002088def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002089 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002090 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002091def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002092 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002093 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002094def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002095 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002096 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2097}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098
Evan Chengb783fa32007-07-19 01:14:50 +00002099def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002100 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002101 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002102def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002103 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002105def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002106 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2108
2109// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002110def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002113def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002114 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002115 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002116def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002117 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2119
2120let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002121 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002122 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002123 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002124 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002125 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002126 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002127 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002128 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002129 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002130 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2131 }
Evan Chengb783fa32007-07-19 01:14:50 +00002132 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002135 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002136 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2138 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002139 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002140 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002141 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2142
2143 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002144 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002145 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002146 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002147 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002148 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002149 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2150 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002151 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2154}
2155
2156
2157
2158// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002159let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002160def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002161 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002162 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002163def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002164 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002165 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002166def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002167 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002169 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002170def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002171 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002172 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002173 TB, OpSize;
2174}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002175
2176let isCommutable = 1 in { // These instructions commute to each other.
2177def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002178 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002179 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002180 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2181 (i8 imm:$src3)))]>,
2182 TB;
2183def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002184 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2187 (i8 imm:$src3)))]>,
2188 TB;
2189def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002190 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002191 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002192 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2193 (i8 imm:$src3)))]>,
2194 TB, OpSize;
2195def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002196 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002197 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002198 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2199 (i8 imm:$src3)))]>,
2200 TB, OpSize;
2201}
2202
2203let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002204 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002205 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002206 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002207 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002208 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002209 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002210 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002211 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002212 addr:$dst)]>, TB;
2213 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002215 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002216 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002217 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2218 (i8 imm:$src3)), addr:$dst)]>,
2219 TB;
2220 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002221 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002222 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002223 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2224 (i8 imm:$src3)), addr:$dst)]>,
2225 TB;
2226
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002227 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002228 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002229 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002231 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002232 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002233 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002235 addr:$dst)]>, TB, OpSize;
2236 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002237 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002238 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002239 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002240 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2241 (i8 imm:$src3)), addr:$dst)]>,
2242 TB, OpSize;
2243 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002244 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002245 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002246 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2247 (i8 imm:$src3)), addr:$dst)]>,
2248 TB, OpSize;
2249}
Evan Cheng55687072007-09-14 21:48:26 +00002250} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251
2252
2253// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002254let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002255let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002256// Register-Register Addition
2257def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2258 (ins GR8 :$src1, GR8 :$src2),
2259 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002260 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002261 (implicit EFLAGS)]>;
2262
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002264// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002265def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2266 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002267 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002268 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2269 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002270def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2271 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002272 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002273 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2274 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002275} // end isConvertibleToThreeAddress
2276} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002277
2278// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002279def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2280 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002281 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002282 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2283 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002284def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2285 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002287 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2288 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002289def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2290 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002291 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002292 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2293 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002294
Bill Wendlingae034ed2008-12-12 00:56:36 +00002295// Register-Integer Addition
2296def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2297 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002298 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2299 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002300
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002301let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002302// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002303def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2304 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002305 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002306 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2307 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002308def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2309 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002310 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002311 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2312 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002313def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2314 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002315 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002316 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2317 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002318def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2319 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002320 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002321 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2322 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323}
2324
2325let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002326 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002327 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002328 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002329 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2330 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002331 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002332 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002333 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2334 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002335 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002336 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002337 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2338 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002339 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002340 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002341 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2342 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002343 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002344 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002345 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2346 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002347 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002348 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002349 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2350 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002351 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002352 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002353 [(store (add (load addr:$dst), i16immSExt8:$src2),
2354 addr:$dst),
2355 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002356 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002358 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002359 addr:$dst),
2360 (implicit EFLAGS)]>;
Sean Callanan0316b342009-08-11 21:26:06 +00002361
2362 // addition to rAX
2363 def ADD8i8 : Ii8<0x04, RawFrm, (outs), (ins i8imm:$src),
2364 "add\t{$src, %al|%al, $src}", []>;
2365 def ADD16i16 : Ii16<0x05, RawFrm, (outs), (ins i16imm:$src),
2366 "add\t{$src, %ax|%ax, $src}", []>, OpSize;
2367 def ADD32i32 : Ii32<0x05, RawFrm, (outs), (ins i32imm:$src),
2368 "add\t{$src, %eax|%eax, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002369}
2370
Evan Cheng259471d2007-10-05 17:59:57 +00002371let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002372let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002373def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002374 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002375 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002376def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2377 (ins GR16:$src1, GR16:$src2),
2378 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002379 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002380def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2381 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002382 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002383 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002385def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2386 (ins GR8:$src1, i8mem:$src2),
2387 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002388 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002389def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2390 (ins GR16:$src1, i16mem:$src2),
2391 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002392 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002393 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002394def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2395 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002396 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002397 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2398def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002399 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002400 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002401def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2402 (ins GR16:$src1, i16imm:$src2),
2403 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002404 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002405def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2406 (ins GR16:$src1, i16i8imm:$src2),
2407 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002408 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2409 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002410def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2411 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002412 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002413 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002414def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2415 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002416 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002417 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418
2419let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002420 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002421 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002422 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2423 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002424 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002425 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2426 OpSize;
2427 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002428 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002429 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2430 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002431 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002432 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2433 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002434 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002435 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2436 OpSize;
2437 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002438 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002439 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2440 OpSize;
2441 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002442 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002443 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2444 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002445 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002446 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2447}
Evan Cheng259471d2007-10-05 17:59:57 +00002448} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002449
Bill Wendlingae034ed2008-12-12 00:56:36 +00002450// Register-Register Subtraction
2451def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2452 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002453 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2454 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002455def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2456 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002457 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2458 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002459def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2460 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002461 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2462 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002463
2464// Register-Memory Subtraction
2465def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2466 (ins GR8 :$src1, i8mem :$src2),
2467 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002468 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2469 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002470def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2471 (ins GR16:$src1, i16mem:$src2),
2472 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002473 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2474 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002475def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2476 (ins GR32:$src1, i32mem:$src2),
2477 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002478 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2479 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002480
2481// Register-Integer Subtraction
2482def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2483 (ins GR8:$src1, i8imm:$src2),
2484 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002485 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2486 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002487def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2488 (ins GR16:$src1, i16imm:$src2),
2489 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002490 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2491 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002492def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2493 (ins GR32:$src1, i32imm:$src2),
2494 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002495 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2496 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002497def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2498 (ins GR16:$src1, i16i8imm:$src2),
2499 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002500 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2501 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002502def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2503 (ins GR32:$src1, i32i8imm:$src2),
2504 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002505 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2506 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002507
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002508let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002509 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002510 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002511 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002512 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2513 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002514 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002515 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002516 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2517 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002518 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002519 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002520 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2521 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002522
2523 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002524 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002525 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002526 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2527 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002528 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002529 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002530 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2531 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002532 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002533 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002534 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2535 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002536 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002537 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002538 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002539 addr:$dst),
2540 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002541 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002542 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002543 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002544 addr:$dst),
2545 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002546}
2547
Evan Cheng259471d2007-10-05 17:59:57 +00002548let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002549def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2550 (ins GR8:$src1, GR8:$src2),
2551 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002552 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002553def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2554 (ins GR16:$src1, GR16:$src2),
2555 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002556 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002557def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2558 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002559 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002560 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002561
2562let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002563 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2564 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002565 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002566 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2567 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002568 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002569 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002570 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002571 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002572 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002573 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002574 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002575 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002576 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2577 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002578 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002579 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002580 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2581 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002582 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002583 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002584 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002585 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002586 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002587 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002588 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002589 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002590}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002591def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2592 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002593 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002594def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2595 (ins GR16:$src1, i16mem:$src2),
2596 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002597 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002598 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002599def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2600 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002601 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002602 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002603def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2604 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002605 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002606def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2607 (ins GR16:$src1, i16imm:$src2),
2608 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002609 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002610def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2611 (ins GR16:$src1, i16i8imm:$src2),
2612 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002613 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2614 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002615def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2616 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002617 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002618 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002619def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2620 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002621 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002622 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002623} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002624} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002625
Evan Cheng55687072007-09-14 21:48:26 +00002626let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002627let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002628// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002629def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002630 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002631 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2632 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002633def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002634 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002635 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2636 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002637}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002638
Bill Wendlingf5399032008-12-12 21:15:41 +00002639// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002640def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2641 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002642 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002643 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2644 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002645def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002646 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002647 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2648 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002649} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002650} // end Two Address instructions
2651
2652// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002653let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002654// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002655def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002656 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002657 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002658 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2659 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002660def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002661 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002662 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002663 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2664 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002665def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002666 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002667 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002668 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2669 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002670def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002671 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002672 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002673 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2674 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002675
Bill Wendlingf5399032008-12-12 21:15:41 +00002676// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002677def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002678 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002679 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002680 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2681 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002682def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002683 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002684 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002685 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2686 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002687def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002688 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002689 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002690 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002691 i16immSExt8:$src2)),
2692 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002693def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002694 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002695 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002696 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002697 i32immSExt8:$src2)),
2698 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002699} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002700
2701//===----------------------------------------------------------------------===//
2702// Test instructions are just like AND, except they don't generate a result.
2703//
Evan Cheng950aac02007-09-25 01:57:46 +00002704let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002705let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002706def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002707 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002708 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002709 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002710def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002711 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002712 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002713 (implicit EFLAGS)]>,
2714 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002715def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002716 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002717 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002718 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002719}
2720
Evan Chengb783fa32007-07-19 01:14:50 +00002721def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002722 "test{b}\t{$src2, $src1|$src1, $src2}",
2723 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2724 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002725def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002726 "test{w}\t{$src2, $src1|$src1, $src2}",
2727 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2728 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002729def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002730 "test{l}\t{$src2, $src1|$src1, $src2}",
2731 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2732 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002733
2734def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002735 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002736 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002737 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002738 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002739def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002740 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002741 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002742 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002743 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002744def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002745 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002746 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002747 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002748 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002749
Evan Cheng621216e2007-09-29 00:00:36 +00002750def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002751 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002752 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002753 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2754 (implicit EFLAGS)]>;
2755def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002756 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002757 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002758 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2759 (implicit EFLAGS)]>, OpSize;
2760def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002761 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002762 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002763 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002764 (implicit EFLAGS)]>;
2765} // Defs = [EFLAGS]
2766
2767
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002768// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002769let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002770def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002771let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002772def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002773
Evan Cheng950aac02007-09-25 01:57:46 +00002774let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002775def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002776 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002777 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002778 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002779 TB; // GR8 = ==
2780def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002781 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002782 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002783 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002784 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002785
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002786def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002787 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002788 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002789 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002790 TB; // GR8 = !=
2791def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002792 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002793 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002794 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002795 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002796
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002797def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002798 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002799 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002800 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002801 TB; // GR8 = < signed
2802def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002803 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002804 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002805 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002806 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002807
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002808def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002809 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002810 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002811 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002812 TB; // GR8 = >= signed
2813def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002814 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002815 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002816 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002817 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002818
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002819def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002820 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002821 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002822 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002823 TB; // GR8 = <= signed
2824def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002825 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002826 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002827 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002828 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002829
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002830def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002831 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002832 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002833 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002834 TB; // GR8 = > signed
2835def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002836 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002837 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002838 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002839 TB; // [mem8] = > signed
2840
2841def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002842 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002843 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002844 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002845 TB; // GR8 = < unsign
2846def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002847 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002848 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002849 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002850 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002851
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002852def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002853 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002854 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002855 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002856 TB; // GR8 = >= unsign
2857def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002858 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002859 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002860 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002861 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002862
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002863def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002864 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002865 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002866 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002867 TB; // GR8 = <= unsign
2868def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002869 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002870 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002871 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002872 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002873
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002874def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002875 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002876 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002877 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002878 TB; // GR8 = > signed
2879def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002880 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002881 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002882 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883 TB; // [mem8] = > signed
2884
2885def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002886 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002887 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002888 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002889 TB; // GR8 = <sign bit>
2890def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002891 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002892 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002893 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002894 TB; // [mem8] = <sign bit>
2895def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002896 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002897 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002898 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002899 TB; // GR8 = !<sign bit>
2900def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002901 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002902 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002903 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002904 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002905
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002906def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002907 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002908 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002909 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002910 TB; // GR8 = parity
2911def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002912 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002913 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002914 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002915 TB; // [mem8] = parity
2916def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002917 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002918 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002919 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002920 TB; // GR8 = not parity
2921def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002922 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002923 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002924 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002925 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002926
2927def SETOr : I<0x90, MRM0r,
2928 (outs GR8 :$dst), (ins),
2929 "seto\t$dst",
2930 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2931 TB; // GR8 = overflow
2932def SETOm : I<0x90, MRM0m,
2933 (outs), (ins i8mem:$dst),
2934 "seto\t$dst",
2935 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2936 TB; // [mem8] = overflow
2937def SETNOr : I<0x91, MRM0r,
2938 (outs GR8 :$dst), (ins),
2939 "setno\t$dst",
2940 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2941 TB; // GR8 = not overflow
2942def SETNOm : I<0x91, MRM0m,
2943 (outs), (ins i8mem:$dst),
2944 "setno\t$dst",
2945 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2946 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002947} // Uses = [EFLAGS]
2948
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002949
2950// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002951let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002952def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002953 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002954 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002955 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002956def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002957 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002958 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002959 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002960def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002961 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002962 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002963 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002964def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002965 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002966 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002967 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2968 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002969def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002970 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002971 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002972 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2973 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002974def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002975 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002976 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002977 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2978 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002979def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002980 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002981 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002982 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2983 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002984def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002985 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002986 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002987 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2988 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002989def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002990 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002991 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002992 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2993 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002994def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002995 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002996 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002997 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002998def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002999 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003000 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003001 [(X86cmp GR16:$src1, imm:$src2),
3002 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003003def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003004 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003005 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003006 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003007def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003008 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003009 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003010 [(X86cmp (loadi8 addr:$src1), imm:$src2),
3011 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003012def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003013 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003014 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003015 [(X86cmp (loadi16 addr:$src1), imm:$src2),
3016 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003017def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003018 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003019 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003020 [(X86cmp (loadi32 addr:$src1), imm:$src2),
3021 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003022def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003023 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003024 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003025 [(X86cmp GR16:$src1, i16immSExt8:$src2),
3026 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003027def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003028 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003029 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003030 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
3031 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003032def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00003033 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003034 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003035 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
3036 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003037def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00003038 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00003039 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00003040 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00003041 (implicit EFLAGS)]>;
3042} // Defs = [EFLAGS]
3043
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003044// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003045// TODO: BTC, BTR, and BTS
3046let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003047def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003048 "bt{w}\t{$src2, $src1|$src1, $src2}",
3049 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003050 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003051def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003052 "bt{l}\t{$src2, $src1|$src1, $src2}",
3053 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003054 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003055
3056// Unlike with the register+register form, the memory+register form of the
3057// bt instruction does not ignore the high bits of the index. From ISel's
3058// perspective, this is pretty bizarre. Disable these instructions for now.
3059//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3060// "bt{w}\t{$src2, $src1|$src1, $src2}",
3061// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3062// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3063//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3064// "bt{l}\t{$src2, $src1|$src1, $src2}",
3065// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3066// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003067
3068def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3069 "bt{w}\t{$src2, $src1|$src1, $src2}",
3070 [(X86bt GR16:$src1, i16immSExt8:$src2),
3071 (implicit EFLAGS)]>, OpSize, TB;
3072def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3073 "bt{l}\t{$src2, $src1|$src1, $src2}",
3074 [(X86bt GR32:$src1, i32immSExt8:$src2),
3075 (implicit EFLAGS)]>, TB;
3076// Note that these instructions don't need FastBTMem because that
3077// only applies when the other operand is in a register. When it's
3078// an immediate, bt is still fast.
3079def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3080 "bt{w}\t{$src2, $src1|$src1, $src2}",
3081 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3082 (implicit EFLAGS)]>, OpSize, TB;
3083def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3084 "bt{l}\t{$src2, $src1|$src1, $src2}",
3085 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3086 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003087} // Defs = [EFLAGS]
3088
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003089// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003090// Use movsbl intead of movsbw; we don't care about the high 16 bits
3091// of the register here. This has a smaller encoding and avoids a
3092// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003093def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003094 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3095 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003096def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003097 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3098 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003099def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003100 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003101 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003102def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003103 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003104 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003105def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003106 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003107 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003108def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003109 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003110 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3111
Dan Gohman9203ab42008-07-30 18:09:17 +00003112// Use movzbl intead of movzbw; we don't care about the high 16 bits
3113// of the register here. This has a smaller encoding and avoids a
3114// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003115def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003116 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3117 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003118def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003119 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3120 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003121def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003122 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003123 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003124def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003125 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003126 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003127def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003128 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003129 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003130def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003131 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003132 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3133
Dan Gohman744d4622009-04-13 16:09:41 +00003134// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3135// except that they use GR32_NOREX for the output operand register class
3136// instead of GR32. This allows them to operate on h registers on x86-64.
3137def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3138 (outs GR32_NOREX:$dst), (ins GR8:$src),
3139 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3140 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003141let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003142def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3143 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3144 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3145 []>, TB;
3146
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003147let neverHasSideEffects = 1 in {
3148 let Defs = [AX], Uses = [AL] in
3149 def CBW : I<0x98, RawFrm, (outs), (ins),
3150 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3151 let Defs = [EAX], Uses = [AX] in
3152 def CWDE : I<0x98, RawFrm, (outs), (ins),
3153 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003154
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003155 let Defs = [AX,DX], Uses = [AX] in
3156 def CWD : I<0x99, RawFrm, (outs), (ins),
3157 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3158 let Defs = [EAX,EDX], Uses = [EAX] in
3159 def CDQ : I<0x99, RawFrm, (outs), (ins),
3160 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3161}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003162
3163//===----------------------------------------------------------------------===//
3164// Alias Instructions
3165//===----------------------------------------------------------------------===//
3166
3167// Alias instructions that map movr0 to xor.
3168// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Daniel Dunbara0e62002009-08-11 22:17:52 +00003169let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1,
3170 isCodeGenOnly = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003171def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003172 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003173 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003174// Use xorl instead of xorw since we don't care about the high 16 bits,
3175// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003176def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003177 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3178 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003179def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003180 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003181 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003182}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003183
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003184//===----------------------------------------------------------------------===//
3185// Thread Local Storage Instructions
3186//
3187
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003188// All calls clobber the non-callee saved registers. ESP is marked as
3189// a use to prevent stack-pointer assignments that appear immediately
3190// before calls from potentially appearing dead.
3191let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3192 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3193 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3194 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003195 Uses = [ESP] in
3196def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3197 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003198 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003199 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003200 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003201
sampo9cc09a32009-01-26 01:24:32 +00003202let AddedComplexity = 5 in
3203def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3204 "movl\t%gs:$src, $dst",
3205 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3206
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003207let AddedComplexity = 5 in
3208def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3209 "movl\t%fs:$src, $dst",
3210 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3211
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003212//===----------------------------------------------------------------------===//
3213// DWARF Pseudo Instructions
3214//
3215
Evan Chengb783fa32007-07-19 01:14:50 +00003216def DWARF_LOC : I<0, Pseudo, (outs),
3217 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Chris Lattner64b54552009-07-10 22:34:11 +00003218 ".loc\t$file $line $col",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003219 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3220 (i32 imm:$file))]>;
3221
3222//===----------------------------------------------------------------------===//
3223// EH Pseudo Instructions
3224//
3225let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003226 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003227def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003228 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003229 [(X86ehret GR32:$addr)]>;
3230
3231}
3232
3233//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003234// Atomic support
3235//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003236
Evan Cheng3e171562008-04-19 01:20:30 +00003237// Atomic swap. These are just normal xchg instructions. But since a memory
3238// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003239let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003240def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3241 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3242 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3243def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3244 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3245 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3246 OpSize;
3247def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3248 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3249 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3250}
3251
Evan Chengd49dbb82008-04-18 20:55:36 +00003252// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003253let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003254def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003255 "lock\n\t"
3256 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003257 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003258}
Dale Johannesenf160d802008-10-02 18:53:47 +00003259let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003260def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003261 "lock\n\t"
3262 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003263 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3264}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003265
3266let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003267def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003268 "lock\n\t"
3269 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003270 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003271}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003272let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003273def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003274 "lock\n\t"
3275 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003276 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003277}
3278
Evan Chengd49dbb82008-04-18 20:55:36 +00003279// Atomic exchange and add
3280let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3281def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003282 "lock\n\t"
3283 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003284 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003285 TB, LOCK;
3286def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003287 "lock\n\t"
3288 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003289 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003290 TB, OpSize, LOCK;
3291def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003292 "lock\n\t"
3293 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003294 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003295 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003296}
3297
Evan Chengb723fb52009-07-30 08:33:02 +00003298// Optimized codegen when the non-memory output is not used.
3299// FIXME: Use normal add / sub instructions and add lock prefix dynamically.
3300def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
3301 "lock\n\t"
3302 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3303def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3304 "lock\n\t"
3305 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3306def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3307 "lock\n\t"
3308 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3309def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
3310 "lock\n\t"
3311 "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3312def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
3313 "lock\n\t"
3314 "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3315def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
3316 "lock\n\t"
3317 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3318def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3319 "lock\n\t"
3320 "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3321def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3322 "lock\n\t"
3323 "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3324
3325def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst),
3326 "lock\n\t"
3327 "inc{b}\t$dst", []>, LOCK;
3328def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst),
3329 "lock\n\t"
3330 "inc{w}\t$dst", []>, OpSize, LOCK;
3331def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst),
3332 "lock\n\t"
3333 "inc{l}\t$dst", []>, LOCK;
3334
3335def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
3336 "lock\n\t"
3337 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3338def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
3339 "lock\n\t"
3340 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3341def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
3342 "lock\n\t"
3343 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3344def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
3345 "lock\n\t"
3346 "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3347def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
3348 "lock\n\t"
3349 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3350def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
3351 "lock\n\t"
3352 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3353def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
3354 "lock\n\t"
3355 "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK;
3356def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
3357 "lock\n\t"
3358 "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK;
3359
3360def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst),
3361 "lock\n\t"
3362 "dec{b}\t$dst", []>, LOCK;
3363def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst),
3364 "lock\n\t"
3365 "dec{w}\t$dst", []>, OpSize, LOCK;
3366def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst),
3367 "lock\n\t"
3368 "dec{l}\t$dst", []>, LOCK;
3369
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003370// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003371let Constraints = "$val = $dst", Defs = [EFLAGS],
3372 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003373def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003374 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003375 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003376def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003377 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003378 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003379def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003380 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003381 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003382def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003383 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003384 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003385def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003386 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003387 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003388def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003389 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003390 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003391def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003392 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003393 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003394def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003395 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003396 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003397
3398def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003399 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003400 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003401def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003402 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003403 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003404def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003405 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003406 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003407def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003408 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003409 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003410def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003411 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003412 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003413def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003414 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003415 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003416def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003417 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003418 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003419def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003420 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003421 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003422
3423def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003424 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003425 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003426def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003427 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003428 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003429def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003430 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003431 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003432def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003433 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003434 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003435}
3436
Dale Johannesenf160d802008-10-02 18:53:47 +00003437let Constraints = "$val1 = $dst1, $val2 = $dst2",
3438 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3439 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003440 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003441 usesCustomDAGSchedInserter = 1 in {
3442def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3443 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003444 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003445def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3446 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003447 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003448def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3449 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003450 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003451def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3452 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003453 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003454def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3455 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003456 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003457def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3458 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003459 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003460def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3461 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003462 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003463}
3464
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003465//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003466// Non-Instruction Patterns
3467//===----------------------------------------------------------------------===//
3468
Bill Wendlingfef06052008-09-16 21:48:12 +00003469// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003470def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3471def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003472def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003473def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3474def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3475
3476def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3477 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3478def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3479 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3480def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3481 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3482def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3483 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3484
3485def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3486 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3487def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3488 (MOV32mi addr:$dst, texternalsym:$src)>;
3489
3490// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003491// tailcall stuff
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003492def : Pat<(X86tcret GR32:$dst, imm:$off),
3493 (TCRETURNri GR32:$dst, imm:$off)>;
3494
3495def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3496 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3497
3498def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3499 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003500
Dan Gohmance5dbff2009-08-02 16:10:01 +00003501// Normal calls, with various flavors of addresses.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003502def : Pat<(X86call (i32 tglobaladdr:$dst)),
3503 (CALLpcrel32 tglobaladdr:$dst)>;
3504def : Pat<(X86call (i32 texternalsym:$dst)),
3505 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003506def : Pat<(X86call (i32 imm:$dst)),
3507 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003508
3509// X86 specific add which produces a flag.
3510def : Pat<(addc GR32:$src1, GR32:$src2),
3511 (ADD32rr GR32:$src1, GR32:$src2)>;
3512def : Pat<(addc GR32:$src1, (load addr:$src2)),
3513 (ADD32rm GR32:$src1, addr:$src2)>;
3514def : Pat<(addc GR32:$src1, imm:$src2),
3515 (ADD32ri GR32:$src1, imm:$src2)>;
3516def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3517 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3518
3519def : Pat<(subc GR32:$src1, GR32:$src2),
3520 (SUB32rr GR32:$src1, GR32:$src2)>;
3521def : Pat<(subc GR32:$src1, (load addr:$src2)),
3522 (SUB32rm GR32:$src1, addr:$src2)>;
3523def : Pat<(subc GR32:$src1, imm:$src2),
3524 (SUB32ri GR32:$src1, imm:$src2)>;
3525def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3526 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3527
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003528// Comparisons.
3529
3530// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003531def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003532 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003533def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003534 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003535def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003536 (TEST32rr GR32:$src1, GR32:$src1)>;
3537
Dan Gohman0a3c5222009-01-07 01:00:24 +00003538// Conditional moves with folded loads with operands swapped and conditions
3539// inverted.
3540def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3541 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3542def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3543 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3544def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3545 (CMOVB16rm GR16:$src2, addr:$src1)>;
3546def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3547 (CMOVB32rm GR32:$src2, addr:$src1)>;
3548def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3549 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3550def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3551 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3552def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3553 (CMOVE16rm GR16:$src2, addr:$src1)>;
3554def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3555 (CMOVE32rm GR32:$src2, addr:$src1)>;
3556def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3557 (CMOVA16rm GR16:$src2, addr:$src1)>;
3558def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3559 (CMOVA32rm GR32:$src2, addr:$src1)>;
3560def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3561 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3562def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3563 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3564def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3565 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3566def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3567 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3568def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3569 (CMOVL16rm GR16:$src2, addr:$src1)>;
3570def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3571 (CMOVL32rm GR32:$src2, addr:$src1)>;
3572def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3573 (CMOVG16rm GR16:$src2, addr:$src1)>;
3574def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3575 (CMOVG32rm GR32:$src2, addr:$src1)>;
3576def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3577 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3578def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3579 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3580def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3581 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3582def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3583 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3584def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3585 (CMOVP16rm GR16:$src2, addr:$src1)>;
3586def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3587 (CMOVP32rm GR32:$src2, addr:$src1)>;
3588def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3589 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3590def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3591 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3592def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3593 (CMOVS16rm GR16:$src2, addr:$src1)>;
3594def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3595 (CMOVS32rm GR32:$src2, addr:$src1)>;
3596def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3597 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3598def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3599 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3600def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3601 (CMOVO16rm GR16:$src2, addr:$src1)>;
3602def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3603 (CMOVO32rm GR32:$src2, addr:$src1)>;
3604
Duncan Sands082524c2008-01-23 20:39:46 +00003605// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003606def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3607def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3608def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3609
3610// extload bool -> extload byte
3611def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003612def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3613 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003614def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003615def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3616 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003617def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3618def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3619
Dan Gohmandd612bb2008-08-20 21:27:32 +00003620// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003621def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3622 Requires<[In32BitMode]>;
3623def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3624 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003625def : Pat<(i32 (anyext GR16:$src)),
3626 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003627
Evan Chengf2abee72007-12-13 00:43:27 +00003628// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003629def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3630 (MOVZX32rm8 addr:$src)>;
3631def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3632 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003633
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003634//===----------------------------------------------------------------------===//
3635// Some peepholes
3636//===----------------------------------------------------------------------===//
3637
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003638// Odd encoding trick: -128 fits into an 8-bit immediate field while
3639// +128 doesn't, so in this special case use a sub instead of an add.
3640def : Pat<(add GR16:$src1, 128),
3641 (SUB16ri8 GR16:$src1, -128)>;
3642def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3643 (SUB16mi8 addr:$dst, -128)>;
3644def : Pat<(add GR32:$src1, 128),
3645 (SUB32ri8 GR32:$src1, -128)>;
3646def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3647 (SUB32mi8 addr:$dst, -128)>;
3648
Dan Gohman9203ab42008-07-30 18:09:17 +00003649// r & (2^16-1) ==> movz
3650def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003651 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003652// r & (2^8-1) ==> movz
3653def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003654 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003655 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003656 Requires<[In32BitMode]>;
3657// r & (2^8-1) ==> movz
3658def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003659 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003660 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003661 Requires<[In32BitMode]>;
3662
3663// sext_inreg patterns
3664def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003665 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003666def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003667 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003668 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003669 Requires<[In32BitMode]>;
3670def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003671 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003672 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003673 Requires<[In32BitMode]>;
3674
3675// trunc patterns
3676def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003677 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003678def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003679 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003680 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003681 Requires<[In32BitMode]>;
3682def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003683 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003684 x86_subreg_8bit)>,
3685 Requires<[In32BitMode]>;
3686
3687// h-register tricks
3688def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003689 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003690 x86_subreg_8bit_hi)>,
3691 Requires<[In32BitMode]>;
3692def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003693 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003694 x86_subreg_8bit_hi)>,
3695 Requires<[In32BitMode]>;
3696def : Pat<(srl_su GR16:$src, (i8 8)),
3697 (EXTRACT_SUBREG
3698 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003699 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003700 x86_subreg_8bit_hi)),
3701 x86_subreg_16bit)>,
3702 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003703def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3704 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3705 x86_subreg_8bit_hi))>,
3706 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003707def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003708 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003709 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003710 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003711
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003712// (shl x, 1) ==> (add x, x)
3713def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3714def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3715def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3716
Evan Cheng76a64c72008-08-30 02:03:58 +00003717// (shl x (and y, 31)) ==> (shl x, y)
3718def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3719 (SHL8rCL GR8:$src1)>;
3720def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3721 (SHL16rCL GR16:$src1)>;
3722def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3723 (SHL32rCL GR32:$src1)>;
3724def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3725 (SHL8mCL addr:$dst)>;
3726def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3727 (SHL16mCL addr:$dst)>;
3728def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3729 (SHL32mCL addr:$dst)>;
3730
3731def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3732 (SHR8rCL GR8:$src1)>;
3733def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3734 (SHR16rCL GR16:$src1)>;
3735def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3736 (SHR32rCL GR32:$src1)>;
3737def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3738 (SHR8mCL addr:$dst)>;
3739def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3740 (SHR16mCL addr:$dst)>;
3741def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3742 (SHR32mCL addr:$dst)>;
3743
3744def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3745 (SAR8rCL GR8:$src1)>;
3746def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3747 (SAR16rCL GR16:$src1)>;
3748def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3749 (SAR32rCL GR32:$src1)>;
3750def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3751 (SAR8mCL addr:$dst)>;
3752def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3753 (SAR16mCL addr:$dst)>;
3754def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3755 (SAR32mCL addr:$dst)>;
3756
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003757// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3758def : Pat<(or (srl GR32:$src1, CL:$amt),
3759 (shl GR32:$src2, (sub 32, CL:$amt))),
3760 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3761
3762def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3763 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3764 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3765
Dan Gohman921581d2008-10-17 01:23:35 +00003766def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3767 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3768 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3769
3770def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3771 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3772 addr:$dst),
3773 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3774
3775def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3776 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3777
3778def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3779 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3780 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3781
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003782// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3783def : Pat<(or (shl GR32:$src1, CL:$amt),
3784 (srl GR32:$src2, (sub 32, CL:$amt))),
3785 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3786
3787def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3788 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3789 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3790
Dan Gohman921581d2008-10-17 01:23:35 +00003791def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3792 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3793 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3794
3795def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3796 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3797 addr:$dst),
3798 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3799
3800def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3801 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3802
3803def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3804 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3805 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3806
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003807// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3808def : Pat<(or (srl GR16:$src1, CL:$amt),
3809 (shl GR16:$src2, (sub 16, CL:$amt))),
3810 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3811
3812def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3813 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3814 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3815
Dan Gohman921581d2008-10-17 01:23:35 +00003816def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3817 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3818 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3819
3820def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3821 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3822 addr:$dst),
3823 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3824
3825def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3826 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3827
3828def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3829 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3830 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3831
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003832// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3833def : Pat<(or (shl GR16:$src1, CL:$amt),
3834 (srl GR16:$src2, (sub 16, CL:$amt))),
3835 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3836
3837def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3838 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3839 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3840
Dan Gohman921581d2008-10-17 01:23:35 +00003841def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3842 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3843 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3844
3845def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3846 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3847 addr:$dst),
3848 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3849
3850def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3851 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3852
3853def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3854 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3855 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3856
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003857//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003858// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003859//===----------------------------------------------------------------------===//
3860
Dan Gohman99a12192009-03-04 19:44:21 +00003861// Register-Register Addition with EFLAGS result
3862def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003863 (implicit EFLAGS)),
3864 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003865def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003866 (implicit EFLAGS)),
3867 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003868def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003869 (implicit EFLAGS)),
3870 (ADD32rr GR32:$src1, GR32:$src2)>;
3871
Dan Gohman99a12192009-03-04 19:44:21 +00003872// Register-Memory Addition with EFLAGS result
3873def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003874 (implicit EFLAGS)),
3875 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003876def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003877 (implicit EFLAGS)),
3878 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003879def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003880 (implicit EFLAGS)),
3881 (ADD32rm GR32:$src1, addr:$src2)>;
3882
Dan Gohman99a12192009-03-04 19:44:21 +00003883// Register-Integer Addition with EFLAGS result
3884def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003885 (implicit EFLAGS)),
3886 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003887def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003888 (implicit EFLAGS)),
3889 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003890def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003891 (implicit EFLAGS)),
3892 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003893def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003894 (implicit EFLAGS)),
3895 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003896def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003897 (implicit EFLAGS)),
3898 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3899
Dan Gohman99a12192009-03-04 19:44:21 +00003900// Memory-Register Addition with EFLAGS result
3901def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003902 addr:$dst),
3903 (implicit EFLAGS)),
3904 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003905def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003906 addr:$dst),
3907 (implicit EFLAGS)),
3908 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003909def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003910 addr:$dst),
3911 (implicit EFLAGS)),
3912 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003913
3914// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003915def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003916 addr:$dst),
3917 (implicit EFLAGS)),
3918 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003919def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003920 addr:$dst),
3921 (implicit EFLAGS)),
3922 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003923def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003924 addr:$dst),
3925 (implicit EFLAGS)),
3926 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003927def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003928 addr:$dst),
3929 (implicit EFLAGS)),
3930 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003931def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003932 addr:$dst),
3933 (implicit EFLAGS)),
3934 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3935
Dan Gohman99a12192009-03-04 19:44:21 +00003936// Register-Register Subtraction with EFLAGS result
3937def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003938 (implicit EFLAGS)),
3939 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003940def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003941 (implicit EFLAGS)),
3942 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003943def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003944 (implicit EFLAGS)),
3945 (SUB32rr GR32:$src1, GR32:$src2)>;
3946
Dan Gohman99a12192009-03-04 19:44:21 +00003947// Register-Memory Subtraction with EFLAGS result
3948def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003949 (implicit EFLAGS)),
3950 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003951def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003952 (implicit EFLAGS)),
3953 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003954def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003955 (implicit EFLAGS)),
3956 (SUB32rm GR32:$src1, addr:$src2)>;
3957
Dan Gohman99a12192009-03-04 19:44:21 +00003958// Register-Integer Subtraction with EFLAGS result
3959def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003960 (implicit EFLAGS)),
3961 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003962def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003963 (implicit EFLAGS)),
3964 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003965def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003966 (implicit EFLAGS)),
3967 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003968def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003969 (implicit EFLAGS)),
3970 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003971def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003972 (implicit EFLAGS)),
3973 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3974
Dan Gohman99a12192009-03-04 19:44:21 +00003975// Memory-Register Subtraction with EFLAGS result
3976def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003977 addr:$dst),
3978 (implicit EFLAGS)),
3979 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003980def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003981 addr:$dst),
3982 (implicit EFLAGS)),
3983 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003984def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003985 addr:$dst),
3986 (implicit EFLAGS)),
3987 (SUB32mr addr:$dst, GR32:$src2)>;
3988
Dan Gohman99a12192009-03-04 19:44:21 +00003989// Memory-Integer Subtraction with EFLAGS result
3990def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003991 addr:$dst),
3992 (implicit EFLAGS)),
3993 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003994def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003995 addr:$dst),
3996 (implicit EFLAGS)),
3997 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003998def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003999 addr:$dst),
4000 (implicit EFLAGS)),
4001 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004002def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004003 addr:$dst),
4004 (implicit EFLAGS)),
4005 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004006def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004007 addr:$dst),
4008 (implicit EFLAGS)),
4009 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
4010
4011
Dan Gohman99a12192009-03-04 19:44:21 +00004012// Register-Register Signed Integer Multiply with EFLAGS result
4013def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004014 (implicit EFLAGS)),
4015 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004016def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004017 (implicit EFLAGS)),
4018 (IMUL32rr GR32:$src1, GR32:$src2)>;
4019
Dan Gohman99a12192009-03-04 19:44:21 +00004020// Register-Memory Signed Integer Multiply with EFLAGS result
4021def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004022 (implicit EFLAGS)),
4023 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004024def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00004025 (implicit EFLAGS)),
4026 (IMUL32rm GR32:$src1, addr:$src2)>;
4027
Dan Gohman99a12192009-03-04 19:44:21 +00004028// Register-Integer Signed Integer Multiply with EFLAGS result
4029def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004030 (implicit EFLAGS)),
4031 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004032def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004033 (implicit EFLAGS)),
4034 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004035def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004036 (implicit EFLAGS)),
4037 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004038def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004039 (implicit EFLAGS)),
4040 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
4041
Dan Gohman99a12192009-03-04 19:44:21 +00004042// Memory-Integer Signed Integer Multiply with EFLAGS result
4043def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004044 (implicit EFLAGS)),
4045 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004046def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004047 (implicit EFLAGS)),
4048 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004049def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004050 (implicit EFLAGS)),
4051 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00004052def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00004053 (implicit EFLAGS)),
4054 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
4055
Dan Gohman99a12192009-03-04 19:44:21 +00004056// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00004057let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00004058def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004059 (implicit EFLAGS)),
4060 (ADD16rr GR16:$src1, GR16:$src1)>;
4061
Dan Gohman99a12192009-03-04 19:44:21 +00004062def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00004063 (implicit EFLAGS)),
4064 (ADD32rr GR32:$src1, GR32:$src1)>;
4065}
4066
Dan Gohman99a12192009-03-04 19:44:21 +00004067// INC and DEC with EFLAGS result. Note that these do not set CF.
4068def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
4069 (INC8r GR8:$src)>;
4070def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
4071 (implicit EFLAGS)),
4072 (INC8m addr:$dst)>;
4073def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
4074 (DEC8r GR8:$src)>;
4075def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
4076 (implicit EFLAGS)),
4077 (DEC8m addr:$dst)>;
4078
4079def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004080 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004081def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
4082 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004083 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004084def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004085 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004086def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
4087 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004088 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004089
4090def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004091 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004092def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
4093 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004094 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004095def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004096 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004097def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
4098 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00004099 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00004100
Bill Wendlingf5399032008-12-12 21:15:41 +00004101//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004102// Floating Point Stack Support
4103//===----------------------------------------------------------------------===//
4104
4105include "X86InstrFPStack.td"
4106
4107//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00004108// X86-64 Support
4109//===----------------------------------------------------------------------===//
4110
Chris Lattner2de8d2b2008-01-10 05:50:42 +00004111include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00004112
4113//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004114// XMM Floating point support (requires SSE / SSE2)
4115//===----------------------------------------------------------------------===//
4116
4117include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00004118
4119//===----------------------------------------------------------------------===//
4120// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4121//===----------------------------------------------------------------------===//
4122
4123include "X86InstrMMX.td"