blob: 2d8f55f40c3a12bc4dcb0742c8f46c5c2d81fc0b [file] [log] [blame]
Arnold Schwaighofer48abc5c2007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
John Criswell856ba762003-10-21 15:17:13 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
John Criswell856ba762003-10-21 15:17:13 +00007//
8//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +00009//
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
Evan Chengaed7c722005-12-17 01:24:02 +000016//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
Evan Chenge3413162006-01-09 18:33:28 +000020def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
Evan Cheng71fb9ad2006-01-26 00:29:36 +000024def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000025
Evan Chenge5f62042007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng0488db92007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000029
Dan Gohman076aee32009-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 Chenge5f62042007-09-29 00:00:36 +000037def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng0488db92007-09-25 01:57:46 +000038 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengaed7c722005-12-17 01:24:02 +000040
Evan Chenge5f62042007-09-29 00:00:36 +000041def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng0488db92007-09-25 01:57:46 +000042 [SDTCisVT<0, i8>,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Evan Chengd5781fc2005-12-21 20:21:51 +000044
Andrew Lenharth26ed8692008-03-01 21:52:34 +000045def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
46 SDTCisVT<2, i8>]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000047def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth26ed8692008-03-01 21:52:34 +000048
Dale Johannesen48c1bc22008-10-02 18:53:47 +000049def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
50 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattner447ff682008-03-11 03:23:40 +000051def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Evan Cheng898101c2005-12-19 23:12:38 +000052
Bill Wendlingc69107c2007-11-13 09:19:02 +000053def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
54def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
55 SDTCisVT<1, i32> ]>;
Evan Chenge3413162006-01-09 18:33:28 +000056
Dan Gohmand35121a2008-05-29 19:57:41 +000057def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Evan Chenge3413162006-01-09 18:33:28 +000058
Evan Cheng67f92a72006-01-11 22:15:48 +000059def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
60
Evan Chenge3413162006-01-09 18:33:28 +000061def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
Evan Chengd90eb7f2006-01-05 00:27:02 +000062
Evan Cheng71fb8342006-02-25 10:02:21 +000063def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
64
Rafael Espindola2ee3db32009-04-17 14:35:58 +000065def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000066
Rafael Espindola094fad32009-04-08 21:14:34 +000067def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000068
Anton Korobeynikov2365f512007-07-14 14:06:15 +000069def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
70
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +000071def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
72
Evan Cheng18efe262007-12-14 02:13:44 +000073def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
74def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Evan Chenge3413162006-01-09 18:33:28 +000075def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
76def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
Evan Chengb077b842005-12-21 02:39:21 +000077
Evan Chenge5f62042007-09-29 00:00:36 +000078def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Evan Chengb077b842005-12-21 02:39:21 +000079
Dan Gohmanc7a37d42008-12-23 22:45:23 +000080def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
81
Evan Chenge5f62042007-09-29 00:00:36 +000082def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Evan Chenge3413162006-01-09 18:33:28 +000083def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng0488db92007-09-25 01:57:46 +000084 [SDNPHasChain]>;
Evan Chenge5f62042007-09-29 00:00:36 +000085def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Evan Chengb077b842005-12-21 02:39:21 +000086
Andrew Lenharth26ed8692008-03-01 21:52:34 +000087def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
89 SDNPMayLoad]>;
Andrew Lenharthd19189e2008-03-05 01:15:49 +000090def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
91 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
92 SDNPMayLoad]>;
Dale Johannesen48c1bc22008-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 Johannesen880ae362008-10-03 22:25:52 +0000111def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
112 [SDNPHasChain, SDNPMayStore,
113 SDNPMayLoad, SDNPMemOperand]>;
Evan Chenge3413162006-01-09 18:33:28 +0000114def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
115 [SDNPHasChain, SDNPOptInFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000116
Evan Chenge3413162006-01-09 18:33:28 +0000117def X86callseq_start :
118 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
Evan Chengbb7b8442006-08-11 09:03:33 +0000119 [SDNPHasChain, SDNPOutFlag]>;
Evan Chenge3413162006-01-09 18:33:28 +0000120def X86callseq_end :
121 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000122 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Evan Chengb077b842005-12-21 02:39:21 +0000123
Evan Chenge3413162006-01-09 18:33:28 +0000124def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
125 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
Evan Chengaed7c722005-12-17 01:24:02 +0000126
Evan Chengfb914c42006-05-20 01:40:16 +0000127def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
Evan Chengfea89c12006-04-27 08:40:39 +0000128 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
129
Evan Cheng67f92a72006-01-11 22:15:48 +0000130def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000131 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000132def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000133 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
134 SDNPMayLoad]>;
Evan Cheng67f92a72006-01-11 22:15:48 +0000135
Evan Chenge3413162006-01-09 18:33:28 +0000136def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerba7e7562008-01-10 07:59:24 +0000137 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Evan Chengd90eb7f2006-01-05 00:27:02 +0000138
Evan Cheng0085a282006-11-30 21:55:46 +0000139def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
140def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
Evan Cheng71fb8342006-02-25 10:02:21 +0000141
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000142def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov6625eff2008-05-04 21:36:32 +0000143 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindola094fad32009-04-08 21:14:34 +0000144def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
145 SDT_X86SegmentBaseAddress, []>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000146
Anton Korobeynikov2365f512007-07-14 14:06:15 +0000147def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
148 [SDNPHasChain]>;
149
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000150def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
151 [SDNPHasChain, SDNPOptInFlag]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +0000152
Dan Gohman076aee32009-03-04 19:44:21 +0000153def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
154def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
155def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
156def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
157def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
158def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +0000159
Evan Cheng73f24c92009-03-30 21:36:47 +0000160def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
161
Evan Chengaed7c722005-12-17 01:24:02 +0000162//===----------------------------------------------------------------------===//
163// X86 Operand Definitions.
164//
165
Chris Lattner7680e732009-06-20 19:34:09 +0000166def i32imm_pcrel : Operand<i32> {
167 let PrintMethod = "print_pcrel_imm";
168}
169
170
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000171// *mem - Operand definitions for the funky X86 addressing mode operands.
172//
Evan Chengaf78ef52006-05-17 21:21:41 +0000173class X86MemOperand<string printMethod> : Operand<iPTR> {
Nate Begeman391c5d22005-11-30 18:54:35 +0000174 let PrintMethod = printMethod;
Rafael Espindola094fad32009-04-08 21:14:34 +0000175 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm, i8imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000176}
Nate Begeman391c5d22005-11-30 18:54:35 +0000177
Chris Lattner45432512005-12-17 19:47:05 +0000178def i8mem : X86MemOperand<"printi8mem">;
179def i16mem : X86MemOperand<"printi16mem">;
180def i32mem : X86MemOperand<"printi32mem">;
181def i64mem : X86MemOperand<"printi64mem">;
Evan Cheng470a6ad2006-02-22 02:26:30 +0000182def i128mem : X86MemOperand<"printi128mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000183def f32mem : X86MemOperand<"printf32mem">;
184def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000185def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000186def f128mem : X86MemOperand<"printf128mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000187
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000188// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
189// plain GR64, so that it doesn't potentially require a REX prefix.
190def i8mem_NOREX : Operand<i64> {
191 let PrintMethod = "printi8mem";
192 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX, i32imm, i8imm);
193}
194
Evan Cheng25ab6902006-09-08 06:48:29 +0000195def lea32mem : Operand<i32> {
Rafael Espindola094fad32009-04-08 21:14:34 +0000196 let PrintMethod = "printlea32mem";
Evan Cheng25ab6902006-09-08 06:48:29 +0000197 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
198}
199
Nate Begeman16b04f32005-07-15 00:38:55 +0000200def SSECC : Operand<i8> {
201 let PrintMethod = "printSSECC";
202}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000203
Evan Cheng7ccced62006-02-18 00:15:05 +0000204def piclabel: Operand<i32> {
205 let PrintMethod = "printPICLabel";
206}
207
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000208// A couple of more descriptive operand definitions.
209// 16-bits but only 8 bits are significant.
210def i16i8imm : Operand<i16>;
211// 32-bits but only 8 bits are significant.
212def i32i8imm : Operand<i32>;
213
Chris Lattner7680e732009-06-20 19:34:09 +0000214// Branch targets have OtherVT type and print as pc-relative values.
215def brtarget : Operand<OtherVT> {
216 let PrintMethod = "print_pcrel_imm";
217}
Evan Chengd35b8c12005-12-04 08:19:43 +0000218
Evan Chengaed7c722005-12-17 01:24:02 +0000219//===----------------------------------------------------------------------===//
220// X86 Complex Pattern Definitions.
221//
222
Evan Chengec693f72005-12-08 02:01:35 +0000223// Define X86 specific addressing mode.
Rafael Espindola094fad32009-04-08 21:14:34 +0000224def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000225def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman3cd90a12009-05-11 18:02:53 +0000226 [add, sub, mul, shl, or, frameindex], []>;
Chris Lattner5c0b16d2009-06-20 20:38:48 +0000227def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
228 [tglobaltlsaddr], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000229
Evan Chengaed7c722005-12-17 01:24:02 +0000230//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000231// X86 Instruction Predicate Definitions.
Evan Cheng28b514392006-12-05 19:50:18 +0000232def HasMMX : Predicate<"Subtarget->hasMMX()">;
233def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
234def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
235def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000236def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000237def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
238def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000239def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
240def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000241def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
242def In64BitMode : Predicate<"Subtarget->is64Bit()">;
243def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
244def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
245def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000246def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengccb69762009-01-02 05:35:45 +0000247def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Chengd7f666a2009-05-20 04:53:57 +0000248def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000249
250//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000251// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000252//
253
Evan Chengc64a1a92007-07-31 08:04:03 +0000254include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000255
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000256//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000257// Pattern fragments...
258//
Evan Chengd9558e02006-01-06 00:43:03 +0000259
260// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000261// X86InstrInfo.h. They must be kept in synch.
Dan Gohman653456c2009-01-07 00:15:08 +0000262def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
263def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
264def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
265def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
266def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
267def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
268def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
269def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
270def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
271def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Evan Chengd9558e02006-01-06 00:43:03 +0000272def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000273def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Evan Chengd9558e02006-01-06 00:43:03 +0000274def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000275def X86_COND_O : PatLeaf<(i8 13)>;
276def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
277def X86_COND_S : PatLeaf<(i8 15)>;
Evan Chengd9558e02006-01-06 00:43:03 +0000278
Evan Cheng9b6b6422005-12-13 00:14:11 +0000279def i16immSExt8 : PatLeaf<(i16 imm), [{
280 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000281 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000282 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000283}]>;
284
Evan Cheng9b6b6422005-12-13 00:14:11 +0000285def i32immSExt8 : PatLeaf<(i32 imm), [{
286 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000287 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000288 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Evan Chengb3558542005-12-13 00:01:09 +0000289}]>;
290
Evan Cheng605c4152005-12-13 01:57:51 +0000291// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000292// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
293// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000294def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000295 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000296 if (const Value *Src = LD->getSrcValue())
297 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000298 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000299 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000300 ISD::LoadExtType ExtType = LD->getExtensionType();
301 if (ExtType == ISD::NON_EXTLOAD)
302 return true;
303 if (ExtType == ISD::EXTLOAD)
304 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000305 return false;
306}]>;
307
Dan Gohman33586292008-10-15 06:50:19 +0000308def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengca57f782008-09-24 23:27:55 +0000309 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000310 if (const Value *Src = LD->getSrcValue())
311 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000312 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000313 return false;
Evan Chengca57f782008-09-24 23:27:55 +0000314 ISD::LoadExtType ExtType = LD->getExtensionType();
315 if (ExtType == ISD::EXTLOAD)
316 return LD->getAlignment() >= 2 && !LD->isVolatile();
317 return false;
318}]>;
319
Dan Gohman33586292008-10-15 06:50:19 +0000320def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000321 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000322 if (const Value *Src = LD->getSrcValue())
323 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000324 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000325 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000326 ISD::LoadExtType ExtType = LD->getExtensionType();
327 if (ExtType == ISD::NON_EXTLOAD)
328 return true;
329 if (ExtType == ISD::EXTLOAD)
330 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000331 return false;
332}]>;
333
Dan Gohman33586292008-10-15 06:50:19 +0000334def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengd47e0b62008-09-29 17:26:18 +0000335 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000336 if (const Value *Src = LD->getSrcValue())
337 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000338 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000339 return false;
Evan Chengd47e0b62008-09-29 17:26:18 +0000340 if (LD->isVolatile())
341 return false;
Evan Chengd47e0b62008-09-29 17:26:18 +0000342 ISD::LoadExtType ExtType = LD->getExtensionType();
343 if (ExtType == ISD::NON_EXTLOAD)
344 return true;
345 if (ExtType == ISD::EXTLOAD)
346 return LD->getAlignment() >= 4;
347 return false;
348}]>;
349
Nate Begeman51a04372009-01-26 01:24:32 +0000350def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattnerc2406f22009-04-10 00:16:23 +0000351 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
352 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
353 return PT->getAddressSpace() == 256;
Nate Begeman51a04372009-01-26 01:24:32 +0000354 return false;
355}]>;
356
Chris Lattner1777d0c2009-05-05 18:52:19 +0000357def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
358 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
359 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
360 return PT->getAddressSpace() == 257;
361 return false;
362}]>;
363
Chris Lattnerc2406f22009-04-10 00:16:23 +0000364def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
365 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
366 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000367 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000368 return false;
369 return true;
370}]>;
371def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
372 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
373 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000374 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000375 return false;
376 return true;
377}]>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000378
Chris Lattnerc2406f22009-04-10 00:16:23 +0000379def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
380 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
381 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000382 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000383 return false;
384 return true;
385}]>;
386def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
387 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
388 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000389 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000390 return false;
391 return true;
392}]>;
393def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
394 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
395 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000396 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000397 return false;
398 return true;
399}]>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000400
Evan Cheng466685d2006-10-09 20:57:25 +0000401def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
402def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
403def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000404
Evan Cheng466685d2006-10-09 20:57:25 +0000405def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
406def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
407def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
408def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
409def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
410def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000411
Evan Cheng466685d2006-10-09 20:57:25 +0000412def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
413def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
414def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
415def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
416def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
417def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000418
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000419
420// An 'and' node with a single use.
421def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000422 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000423}]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000424// An 'srl' node with a single use.
425def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
426 return N->hasOneUse();
427}]>;
428// An 'trunc' node with a single use.
429def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
430 return N->hasOneUse();
431}]>;
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000432
Dan Gohman74feef22008-10-17 01:23:35 +0000433// 'shld' and 'shrd' instruction patterns. Note that even though these have
434// the srl and shl in their patterns, the C++ code must still check for them,
435// because predicates are tested before children nodes are explored.
436
437def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
438 (or (srl node:$src1, node:$amt1),
439 (shl node:$src2, node:$amt2)), [{
440 assert(N->getOpcode() == ISD::OR);
441 return N->getOperand(0).getOpcode() == ISD::SRL &&
442 N->getOperand(1).getOpcode() == ISD::SHL &&
443 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
444 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
445 N->getOperand(0).getConstantOperandVal(1) ==
446 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
447}]>;
448
449def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
450 (or (shl node:$src1, node:$amt1),
451 (srl node:$src2, node:$amt2)), [{
452 assert(N->getOpcode() == ISD::OR);
453 return N->getOperand(0).getOpcode() == ISD::SHL &&
454 N->getOperand(1).getOpcode() == ISD::SRL &&
455 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
456 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
457 N->getOperand(0).getConstantOperandVal(1) ==
458 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
459}]>;
460
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000461//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000462// Instruction list...
463//
464
Chris Lattnerf18c0742006-10-12 17:42:56 +0000465// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
466// a stack adjustment and the codegen must know that they may modify the stack
467// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000468// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
469// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000470let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000471def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
472 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000473 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000474 Requires<[In32BitMode]>;
475def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
476 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000477 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000478 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000479}
Evan Cheng4a460802006-01-11 00:33:36 +0000480
481// Nop
Chris Lattnerba7e7562008-01-10 07:59:24 +0000482let neverHasSideEffects = 1 in
483 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Evan Cheng4a460802006-01-11 00:33:36 +0000484
Evan Cheng0475ab52008-01-05 00:41:47 +0000485// PIC base
Dan Gohman2662d552008-10-01 04:14:30 +0000486let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerba7e7562008-01-10 07:59:24 +0000487 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman4d47b9b2009-04-27 15:13:28 +0000488 "call\t$label\n\t"
489 "pop{l}\t$reg", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000490
Chris Lattner1cca5e32003-08-03 21:54:21 +0000491//===----------------------------------------------------------------------===//
492// Control Flow Instructions...
493//
494
Chris Lattner1be48112005-05-13 17:56:48 +0000495// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000496let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattner447ff682008-03-11 03:23:40 +0000497 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000498 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000499 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000500 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000501 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
502 "ret\t$amt",
Evan Chenge3413162006-01-09 18:33:28 +0000503 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000504}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000505
506// All branches are RawFrm, Void, Branch, and Terminators
Evan Chengffbacca2007-07-21 00:34:19 +0000507let isBranch = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000508 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
509 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000510
Evan Chengec3bc392006-09-07 19:03:48 +0000511let isBranch = 1, isBarrier = 1 in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000512 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000513
Owen Anderson20ab2902007-11-12 07:39:39 +0000514// Indirect branches
515let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000516 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000517 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000518 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000519 [(brind (loadi32 addr:$dst))]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000520}
521
522// Conditional branches
Evan Cheng0488db92007-09-25 01:57:46 +0000523let Uses = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000524def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000525 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000526def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000527 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000528def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000529 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000530def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000531 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000532def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000533 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000534def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000535 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000536
Dan Gohmanb1576f52007-07-31 20:11:57 +0000537def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000538 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000539def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000540 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000541def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000542 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000543def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000544 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000545
Dan Gohmanb1576f52007-07-31 20:11:57 +0000546def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000547 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000548def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000549 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000550def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000551 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000552def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000553 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000554def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000555 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000556def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000557 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng0488db92007-09-25 01:57:46 +0000558} // Uses = [EFLAGS]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000559
560//===----------------------------------------------------------------------===//
561// Call Instructions...
562//
Evan Chengffbacca2007-07-21 00:34:19 +0000563let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000564 // All calls clobber the non-callee saved registers. ESP is marked as
565 // a use to prevent stack-pointer assignments that appear immediately
566 // before calls from potentially appearing dead. Uses for argument
567 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000568 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000569 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000570 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
571 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000572 Uses = [ESP] in {
Chris Lattner7680e732009-06-20 19:34:09 +0000573 def CALLpcrel32 : Ii32<0xE8, RawFrm,
574 (outs), (ins i32imm_pcrel:$dst,variable_ops),
575 "call\t$dst", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000576 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000577 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000578 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000579 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000580 }
581
Chris Lattner1e9448b2005-05-15 03:10:37 +0000582// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000583
Chris Lattner447ff682008-03-11 03:23:40 +0000584def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000585 "#TAILCALL",
586 []>;
587
Evan Chengffbacca2007-07-21 00:34:19 +0000588let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000589def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000590 "#TC_RETURN $dst $offset",
591 []>;
592
593let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000594def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000595 "#TC_RETURN $dst $offset",
596 []>;
597
598let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer30e62c02008-04-30 09:16:33 +0000599
Chris Lattner7680e732009-06-20 19:34:09 +0000600 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000601 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000602let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000603 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
604 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000605let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000606 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000607 "jmp\t{*}$dst # TAILCALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000608
Chris Lattner1cca5e32003-08-03 21:54:21 +0000609//===----------------------------------------------------------------------===//
610// Miscellaneous Instructions...
611//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000612let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000613def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000614 (outs), (ins), "leave", []>;
615
Chris Lattnerba7e7562008-01-10 07:59:24 +0000616let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
617let mayLoad = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000618def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000619
Chris Lattnerba7e7562008-01-10 07:59:24 +0000620let mayStore = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000621def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000622}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000623
Bill Wendling453eb262009-06-15 19:39:04 +0000624let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
625def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000626 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000627def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000628 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000629def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000630 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000631}
632
Chris Lattnerba7e7562008-01-10 07:59:24 +0000633let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000634def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000635let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000636def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000637
Evan Cheng069287d2006-05-16 07:21:53 +0000638let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000639 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000640 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000641 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000642 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000643
Chris Lattner1cca5e32003-08-03 21:54:21 +0000644
Evan Cheng18efe262007-12-14 02:13:44 +0000645// Bit scan instructions.
646let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000647def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000648 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000649 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000650def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000651 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000652 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
653 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000654def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000655 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000656 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000657def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000658 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000659 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
660 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000661
Evan Chengfd9e4732007-12-14 18:49:43 +0000662def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000663 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000664 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000665def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000666 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000667 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
668 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000669def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000670 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000671 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000672def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000673 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000674 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
675 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000676} // Defs = [EFLAGS]
677
Chris Lattnerba7e7562008-01-10 07:59:24 +0000678let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000679def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000680 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000681 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000682let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000683def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000684 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000685 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000686 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000687
Evan Cheng071a2792007-09-11 19:55:27 +0000688let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000689def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000690 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000691def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000692 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000693def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000694 [(X86rep_movs i32)]>, REP;
695}
Chris Lattner915e5e52004-02-12 17:53:22 +0000696
Evan Cheng071a2792007-09-11 19:55:27 +0000697let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000698def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000699 [(X86rep_stos i8)]>, REP;
700let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000701def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000702 [(X86rep_stos i16)]>, REP, OpSize;
703let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000704def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000705 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000706
Evan Cheng071a2792007-09-11 19:55:27 +0000707let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000708def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000709 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000710
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000711let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000712def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000713}
714
Chris Lattner1cca5e32003-08-03 21:54:21 +0000715//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000716// Input/Output Instructions...
717//
Evan Cheng071a2792007-09-11 19:55:27 +0000718let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000719def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000720 "in{b}\t{%dx, %al|%AL, %DX}", []>;
721let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000722def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000723 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
724let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000725def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000726 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000727
Evan Cheng071a2792007-09-11 19:55:27 +0000728let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000729def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000730 "in{b}\t{$port, %al|%AL, $port}", []>;
731let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000732def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000733 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
734let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000735def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000736 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000737
Evan Cheng071a2792007-09-11 19:55:27 +0000738let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000739def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000740 "out{b}\t{%al, %dx|%DX, %AL}", []>;
741let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000742def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000743 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
744let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000745def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000746 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000747
Evan Cheng071a2792007-09-11 19:55:27 +0000748let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000749def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000750 "out{b}\t{%al, $port|$port, %AL}", []>;
751let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000752def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000753 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
754let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000755def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000756 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000757
758//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000759// Move Instructions...
760//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000761let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000762def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000763 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000764def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000765 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000766def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000767 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000768}
Evan Cheng359e9372008-06-18 08:13:07 +0000769let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000770def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000771 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000772 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000773def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000774 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000775 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000776def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000777 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000778 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000779}
Evan Cheng64d80e32007-07-19 01:14:50 +0000780def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000781 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000782 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000783def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000784 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000785 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000786def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000787 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000788 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000789
Dan Gohman15511cf2008-12-03 18:15:48 +0000790let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000791def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000792 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +0000793 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000794def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000795 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +0000796 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000797def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000798 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +0000799 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +0000800}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000801
Evan Cheng64d80e32007-07-19 01:14:50 +0000802def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000803 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000804 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000805def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000806 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000807 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000808def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000809 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000810 [(store GR32:$src, addr:$dst)]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000811
Dan Gohman4af325d2009-04-27 16:41:36 +0000812// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
813// that they can be used for copying and storing h registers, which can't be
814// encoded when a REX prefix is present.
Dan Gohman6d9305c2009-04-15 00:04:23 +0000815let neverHasSideEffects = 1 in
Dan Gohmandf7dfc72009-04-15 19:48:57 +0000816def MOV8rr_NOREX : I<0x88, MRMDestReg,
817 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman6d9305c2009-04-15 00:04:23 +0000818 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +0000819let mayStore = 1 in
Dan Gohman6d9305c2009-04-15 00:04:23 +0000820def MOV8mr_NOREX : I<0x88, MRMDestMem,
821 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
822 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +0000823let mayLoad = 1,
824 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman4af325d2009-04-27 16:41:36 +0000825def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
826 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
827 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000828
Chris Lattner1cca5e32003-08-03 21:54:21 +0000829//===----------------------------------------------------------------------===//
830// Fixed-Register Multiplication and Division Instructions...
831//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000832
Chris Lattnerc8f45872003-08-04 04:59:56 +0000833// Extra precision multiplication
Evan Cheng24f2ea32007-09-14 21:48:26 +0000834let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000835def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000836 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
837 // This probably ought to be moved to a def : Pat<> if the
838 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +0000839 [(set AL, (mul AL, GR8:$src)),
840 (implicit EFLAGS)]>; // AL,AH = AL*GR8
841
Chris Lattnera731c9f2008-01-11 07:18:17 +0000842let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +0000843def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
844 "mul{w}\t$src",
845 []>, OpSize; // AX,DX = AX*GR16
846
Chris Lattnera731c9f2008-01-11 07:18:17 +0000847let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +0000848def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
849 "mul{l}\t$src",
850 []>; // EAX,EDX = EAX*GR32
851
Evan Cheng24f2ea32007-09-14 21:48:26 +0000852let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000853def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000854 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000855 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
856 // This probably ought to be moved to a def : Pat<> if the
857 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +0000858 [(set AL, (mul AL, (loadi8 addr:$src))),
859 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
860
Chris Lattnerba7e7562008-01-10 07:59:24 +0000861let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000862let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000863def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +0000864 "mul{w}\t$src",
865 []>, OpSize; // AX,DX = AX*[mem16]
866
Evan Cheng24f2ea32007-09-14 21:48:26 +0000867let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000868def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +0000869 "mul{l}\t$src",
870 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000871}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000872
Chris Lattnerba7e7562008-01-10 07:59:24 +0000873let neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000874let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +0000875def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
876 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +0000877let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000878def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +0000879 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +0000880let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +0000881def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
882 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +0000883let mayLoad = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000884let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000885def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000886 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +0000887let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000888def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000889 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
890let Defs = [EAX,EDX], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000891def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000892 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000893}
Dan Gohmanc99da132008-11-18 21:29:14 +0000894} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +0000895
Chris Lattnerc8f45872003-08-04 04:59:56 +0000896// unsigned division/remainder
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000897let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000898def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000899 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000900let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000901def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000902 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000903let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000904def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000905 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000906let mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000907let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000908def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000909 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000910let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000911def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000912 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000913let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000914def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000915 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000916}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000917
Chris Lattnerfc752712004-08-01 09:52:59 +0000918// Signed division/remainder.
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000919let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000920def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000921 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000922let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000923def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000924 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000925let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000926def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000927 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000928let mayLoad = 1, mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000929let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000930def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000931 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000932let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000933def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000934 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000935let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000936def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000937 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000938}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000939
Chris Lattner1cca5e32003-08-03 21:54:21 +0000940//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000941// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000942//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000943let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000944
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000945// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +0000946let Uses = [EFLAGS] in {
Evan Cheng7ad42d92007-10-05 23:13:21 +0000947let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +0000948def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000949 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000950 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000951 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000952 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000953 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000954def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000955 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000956 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000957 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000958 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000959 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000960def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000961 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000962 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000963 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000964 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000965 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000966def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000967 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000968 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000969 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000970 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000971 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000972def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000973 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000974 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000975 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000976 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000977 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000978def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000979 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000980 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000981 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000982 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000983 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000984def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000985 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000986 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000987 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000988 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000989 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000990def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000991 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000992 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000993 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000994 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000995 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000996def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000997 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000998 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000999 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001000 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001001 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001002def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001003 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001004 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001005 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001006 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001007 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001008def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001009 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001010 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001011 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001012 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001013 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001014def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001015 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001016 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001017 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001018 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001019 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001020def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001021 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001022 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001023 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001024 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001025 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001026def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001027 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001028 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001029 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001030 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001031 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001032def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001033 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001034 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001035 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001036 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001037 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001038def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001039 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001040 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001041 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001042 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001043 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001044def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001045 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001046 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001047 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001048 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001049 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001050def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001051 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001052 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001053 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001054 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001055 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001056def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001057 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001058 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001059 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001060 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001061 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001062def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001063 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001064 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001065 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001066 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001067 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001068def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001069 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001070 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001071 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001072 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001073 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001074def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001075 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001076 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001077 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001078 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001079 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001080def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001081 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001082 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001083 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001084 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001085 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001086def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001087 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001088 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001089 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001090 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001091 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001092def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001093 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001094 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001095 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001096 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001097 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001098def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001099 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001100 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001101 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001102 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001103 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001104def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001105 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001106 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001107 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001108 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001109 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001110def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001111 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001112 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001113 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001114 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001115 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001116def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1117 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1118 "cmovo\t{$src2, $dst|$dst, $src2}",
1119 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1120 X86_COND_O, EFLAGS))]>,
1121 TB, OpSize;
1122def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1123 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1124 "cmovo\t{$src2, $dst|$dst, $src2}",
1125 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1126 X86_COND_O, EFLAGS))]>,
Evan Cheng0488db92007-09-25 01:57:46 +00001127 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001128def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1129 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1130 "cmovno\t{$src2, $dst|$dst, $src2}",
1131 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1132 X86_COND_NO, EFLAGS))]>,
1133 TB, OpSize;
1134def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1135 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1136 "cmovno\t{$src2, $dst|$dst, $src2}",
1137 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1138 X86_COND_NO, EFLAGS))]>,
1139 TB;
1140} // isCommutable = 1
Evan Cheng7ad42d92007-10-05 23:13:21 +00001141
1142def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1143 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1144 "cmovb\t{$src2, $dst|$dst, $src2}",
1145 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1146 X86_COND_B, EFLAGS))]>,
1147 TB, OpSize;
1148def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1149 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1150 "cmovb\t{$src2, $dst|$dst, $src2}",
1151 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1152 X86_COND_B, EFLAGS))]>,
1153 TB;
1154def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1155 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1156 "cmovae\t{$src2, $dst|$dst, $src2}",
1157 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1158 X86_COND_AE, EFLAGS))]>,
1159 TB, OpSize;
1160def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1161 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1162 "cmovae\t{$src2, $dst|$dst, $src2}",
1163 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1164 X86_COND_AE, EFLAGS))]>,
1165 TB;
1166def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1167 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1168 "cmove\t{$src2, $dst|$dst, $src2}",
1169 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1170 X86_COND_E, EFLAGS))]>,
1171 TB, OpSize;
1172def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1173 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1174 "cmove\t{$src2, $dst|$dst, $src2}",
1175 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1176 X86_COND_E, EFLAGS))]>,
1177 TB;
1178def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1179 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1180 "cmovne\t{$src2, $dst|$dst, $src2}",
1181 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1182 X86_COND_NE, EFLAGS))]>,
1183 TB, OpSize;
1184def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1185 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1186 "cmovne\t{$src2, $dst|$dst, $src2}",
1187 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1188 X86_COND_NE, EFLAGS))]>,
1189 TB;
1190def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1191 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1192 "cmovbe\t{$src2, $dst|$dst, $src2}",
1193 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1194 X86_COND_BE, EFLAGS))]>,
1195 TB, OpSize;
1196def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1197 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1198 "cmovbe\t{$src2, $dst|$dst, $src2}",
1199 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1200 X86_COND_BE, EFLAGS))]>,
1201 TB;
1202def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1203 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1204 "cmova\t{$src2, $dst|$dst, $src2}",
1205 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1206 X86_COND_A, EFLAGS))]>,
1207 TB, OpSize;
1208def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1209 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1210 "cmova\t{$src2, $dst|$dst, $src2}",
1211 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1212 X86_COND_A, EFLAGS))]>,
1213 TB;
1214def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1215 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1216 "cmovl\t{$src2, $dst|$dst, $src2}",
1217 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1218 X86_COND_L, EFLAGS))]>,
1219 TB, OpSize;
1220def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1221 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1222 "cmovl\t{$src2, $dst|$dst, $src2}",
1223 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1224 X86_COND_L, EFLAGS))]>,
1225 TB;
1226def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1227 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1228 "cmovge\t{$src2, $dst|$dst, $src2}",
1229 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1230 X86_COND_GE, EFLAGS))]>,
1231 TB, OpSize;
1232def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1233 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1234 "cmovge\t{$src2, $dst|$dst, $src2}",
1235 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1236 X86_COND_GE, EFLAGS))]>,
1237 TB;
1238def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1239 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1240 "cmovle\t{$src2, $dst|$dst, $src2}",
1241 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1242 X86_COND_LE, EFLAGS))]>,
1243 TB, OpSize;
1244def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1245 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1246 "cmovle\t{$src2, $dst|$dst, $src2}",
1247 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1248 X86_COND_LE, EFLAGS))]>,
1249 TB;
1250def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1251 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1252 "cmovg\t{$src2, $dst|$dst, $src2}",
1253 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1254 X86_COND_G, EFLAGS))]>,
1255 TB, OpSize;
1256def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1257 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1258 "cmovg\t{$src2, $dst|$dst, $src2}",
1259 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1260 X86_COND_G, EFLAGS))]>,
1261 TB;
1262def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1263 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1264 "cmovs\t{$src2, $dst|$dst, $src2}",
1265 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1266 X86_COND_S, EFLAGS))]>,
1267 TB, OpSize;
1268def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1269 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1270 "cmovs\t{$src2, $dst|$dst, $src2}",
1271 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1272 X86_COND_S, EFLAGS))]>,
1273 TB;
1274def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1275 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1276 "cmovns\t{$src2, $dst|$dst, $src2}",
1277 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1278 X86_COND_NS, EFLAGS))]>,
1279 TB, OpSize;
1280def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1281 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1282 "cmovns\t{$src2, $dst|$dst, $src2}",
1283 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1284 X86_COND_NS, EFLAGS))]>,
1285 TB;
1286def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1287 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1288 "cmovp\t{$src2, $dst|$dst, $src2}",
1289 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1290 X86_COND_P, EFLAGS))]>,
1291 TB, OpSize;
1292def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1293 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1294 "cmovp\t{$src2, $dst|$dst, $src2}",
1295 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1296 X86_COND_P, EFLAGS))]>,
1297 TB;
1298def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1299 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1300 "cmovnp\t{$src2, $dst|$dst, $src2}",
1301 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1302 X86_COND_NP, EFLAGS))]>,
1303 TB, OpSize;
Dan Gohman305fceb2009-01-07 00:35:10 +00001304def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1305 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1306 "cmovnp\t{$src2, $dst|$dst, $src2}",
1307 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1308 X86_COND_NP, EFLAGS))]>,
1309 TB;
1310def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1311 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1312 "cmovo\t{$src2, $dst|$dst, $src2}",
1313 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1314 X86_COND_O, EFLAGS))]>,
1315 TB, OpSize;
1316def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1317 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1318 "cmovo\t{$src2, $dst|$dst, $src2}",
1319 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1320 X86_COND_O, EFLAGS))]>,
1321 TB;
1322def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1323 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1324 "cmovno\t{$src2, $dst|$dst, $src2}",
1325 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1326 X86_COND_NO, EFLAGS))]>,
1327 TB, OpSize;
1328def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1329 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1330 "cmovno\t{$src2, $dst|$dst, $src2}",
1331 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1332 X86_COND_NO, EFLAGS))]>,
1333 TB;
Evan Cheng0488db92007-09-25 01:57:46 +00001334} // Uses = [EFLAGS]
1335
1336
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001337// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001338let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001339let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001340def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001341 [(set GR8:$dst, (ineg GR8:$src)),
1342 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001343def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001344 [(set GR16:$dst, (ineg GR16:$src)),
1345 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001346def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001347 [(set GR32:$dst, (ineg GR32:$src)),
1348 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001349let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001350 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001351 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1352 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001353 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001354 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1355 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001356 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001357 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1358 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001359}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001360} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001361
Evan Chengaaf414c2009-01-21 02:09:05 +00001362// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1363let AddedComplexity = 15 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001364def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001365 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001366def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001367 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001368def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001369 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengaaf414c2009-01-21 02:09:05 +00001370}
Chris Lattner57a02302004-08-11 04:31:00 +00001371let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001372 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001373 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001374 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001375 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001376 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001377 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001378}
Evan Cheng1693e482006-07-19 00:27:29 +00001379} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001380
Evan Chengb51a0592005-12-10 00:48:20 +00001381// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001382let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001383let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001384def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001385 [(set GR8:$dst, (add GR8:$src, 1)),
1386 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001387let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001388def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001389 [(set GR16:$dst, (add GR16:$src, 1)),
1390 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001391 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001392def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001393 [(set GR32:$dst, (add GR32:$src, 1)),
1394 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001395}
Evan Cheng1693e482006-07-19 00:27:29 +00001396let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001397 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001398 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1399 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001400 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001401 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1402 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001403 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001404 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001405 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1406 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001407 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001408}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001409
Evan Cheng1693e482006-07-19 00:27:29 +00001410let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001411def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001412 [(set GR8:$dst, (add GR8:$src, -1)),
1413 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001414let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001415def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001416 [(set GR16:$dst, (add GR16:$src, -1)),
1417 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001418 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001419def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001420 [(set GR32:$dst, (add GR32:$src, -1)),
1421 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001422}
Chris Lattner57a02302004-08-11 04:31:00 +00001423
Evan Cheng1693e482006-07-19 00:27:29 +00001424let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001425 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001426 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1427 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001428 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001429 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1430 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001431 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001432 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001433 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1434 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001435 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001436}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001437} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001438
1439// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001440let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001441let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001442def AND8rr : I<0x20, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001443 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001444 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001445 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1446 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001447def AND16rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001448 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001449 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001450 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1451 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001452def AND32rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001453 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001454 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001455 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1456 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001457}
Chris Lattner57a02302004-08-11 04:31:00 +00001458
Chris Lattner3a173df2004-10-03 20:35:00 +00001459def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001460 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001461 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001462 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001463 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001464def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001465 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001466 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001467 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001468 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001469def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001470 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001471 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001472 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001473 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001474
Chris Lattner3a173df2004-10-03 20:35:00 +00001475def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001476 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001477 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001478 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1479 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001480def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001481 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001482 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001483 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1484 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001485def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001486 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001487 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001488 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1489 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001490def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001491 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001492 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001493 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1494 (implicit EFLAGS)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001495 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001496def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001497 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001498 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001499 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1500 (implicit EFLAGS)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001501
1502let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001503 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001504 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001505 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001506 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1507 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001508 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001509 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001510 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001511 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1512 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001513 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001514 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001515 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001516 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001517 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1518 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001519 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001520 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001521 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001522 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1523 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001524 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001525 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001526 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001527 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1528 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001529 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001530 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001531 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001532 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001533 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1534 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001535 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001536 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001537 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001538 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1539 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001540 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001541 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001542 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001543 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001544 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1545 (implicit EFLAGS)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001546}
1547
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001548
Chris Lattnercc65bee2005-01-02 02:35:46 +00001549let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001550def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001551 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001552 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1553 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001554def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001555 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001556 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1557 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001558def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001559 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001560 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1561 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001562}
Evan Cheng64d80e32007-07-19 01:14:50 +00001563def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001564 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001565 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1566 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001567def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001568 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001569 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1570 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001571def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001572 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001573 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1574 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001575
Evan Cheng64d80e32007-07-19 01:14:50 +00001576def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001577 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001578 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1579 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001580def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001581 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001582 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1583 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001584def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001585 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001586 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1587 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001588
Evan Cheng64d80e32007-07-19 01:14:50 +00001589def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001590 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001591 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1592 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001593def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001594 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001595 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1596 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001597let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001598 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001599 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001600 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1601 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001602 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001603 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001604 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1605 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001606 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001607 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001608 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1609 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001610 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001611 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001612 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1613 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001614 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001615 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001616 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1617 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001618 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001619 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001620 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001621 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1622 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001623 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001624 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001625 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1626 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001627 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001628 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001629 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001630 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1631 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001632} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001633
1634
Evan Cheng359e9372008-06-18 08:13:07 +00001635let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001636 def XOR8rr : I<0x30, MRMDestReg,
1637 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1638 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001639 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1640 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001641 def XOR16rr : I<0x31, MRMDestReg,
1642 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1643 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001644 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1645 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001646 def XOR32rr : I<0x31, MRMDestReg,
1647 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1648 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001649 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1650 (implicit EFLAGS)]>;
Evan Cheng359e9372008-06-18 08:13:07 +00001651} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00001652
Chris Lattner3a173df2004-10-03 20:35:00 +00001653def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001654 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001655 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001656 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1657 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001658def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001659 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001660 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001661 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1662 (implicit EFLAGS)]>,
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001663 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001664def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001665 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001666 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001667 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1668 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001669
Bill Wendling75cf88f2008-05-29 03:46:36 +00001670def XOR8ri : Ii8<0x80, MRM6r,
1671 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1672 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001673 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1674 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001675def XOR16ri : Ii16<0x81, MRM6r,
1676 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1677 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001678 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1679 (implicit EFLAGS)]>, OpSize;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001680def XOR32ri : Ii32<0x81, MRM6r,
1681 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1682 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001683 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1684 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001685def XOR16ri8 : Ii8<0x83, MRM6r,
1686 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1687 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001688 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1689 (implicit EFLAGS)]>,
Bill Wendling75cf88f2008-05-29 03:46:36 +00001690 OpSize;
1691def XOR32ri8 : Ii8<0x83, MRM6r,
1692 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1693 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001694 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1695 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001696
Chris Lattner57a02302004-08-11 04:31:00 +00001697let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001698 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001699 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001700 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001701 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1702 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001703 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001704 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001705 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001706 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1707 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001708 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001709 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001710 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001711 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001712 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1713 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001714 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001715 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001716 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001717 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1718 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001719 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001720 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001721 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001722 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1723 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001724 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001725 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001726 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001727 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001728 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1729 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001730 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001731 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001732 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001733 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1734 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001735 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001736 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001737 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001738 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001739 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1740 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001741} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00001742} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001743
1744// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00001745let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00001746let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001747def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001748 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001749 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001750def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001751 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001752 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001753def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001754 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001755 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001756} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00001757
Evan Cheng64d80e32007-07-19 01:14:50 +00001758def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001759 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001760 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001761let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00001762def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001763 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001764 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001765def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001766 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001767 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf9b3f372008-01-11 18:00:50 +00001768// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1769// cheaper.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001770} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00001771
Chris Lattnerf29ed092004-08-11 05:07:25 +00001772let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001773 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001774 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001775 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001776 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001777 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001778 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001779 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001780 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001781 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001782 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1783 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001784 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001785 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001786 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001787 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001788 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001789 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1790 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001791 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001792 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001793 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001794
1795 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001796 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001797 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001798 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001799 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001800 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001801 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1802 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001803 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001804 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001805 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001806}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001807
Evan Cheng071a2792007-09-11 19:55:27 +00001808let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001809def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001810 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001811 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001812def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001813 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001814 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001815def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001816 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001817 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1818}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001819
Evan Cheng64d80e32007-07-19 01:14:50 +00001820def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001821 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001822 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001823def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001824 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001825 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001826def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001827 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001828 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001829
Evan Cheng09c54572006-06-29 00:36:51 +00001830// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001831def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001832 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001833 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001834def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001835 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001836 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001837def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001838 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001839 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1840
Chris Lattner57a02302004-08-11 04:31:00 +00001841let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001842 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001843 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001844 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001845 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001846 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001847 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001848 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001849 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001850 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001851 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001852 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1853 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001854 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001855 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001856 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001857 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001858 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001859 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1860 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001861 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001862 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001863 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001864
1865 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001866 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001867 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001868 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001869 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001870 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001871 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001872 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001873 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001874 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001875}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001876
Evan Cheng071a2792007-09-11 19:55:27 +00001877let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001878def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001879 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001880 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001881def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001882 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001883 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001884def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001885 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001886 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1887}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001888
Evan Cheng64d80e32007-07-19 01:14:50 +00001889def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001890 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001891 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001892def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001893 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001894 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001895 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001896def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001897 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001898 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001899
1900// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001901def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001902 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001903 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001904def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001905 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001906 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001907def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001908 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001909 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1910
Chris Lattnerf29ed092004-08-11 05:07:25 +00001911let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001912 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001913 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001914 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001915 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001916 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001917 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001918 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001919 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001920 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001921 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1922 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001923 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001924 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001925 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001926 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001927 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001928 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1929 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001930 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001931 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001932 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001933
1934 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001935 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001936 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001937 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001938 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001939 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001940 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1941 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001942 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001943 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001944 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001945}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001946
Chris Lattner40ff6332005-01-19 07:50:03 +00001947// Rotate instructions
1948// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00001949let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001950def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001951 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001952 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001953def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001954 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001955 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001956def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001957 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001958 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1959}
Chris Lattner40ff6332005-01-19 07:50:03 +00001960
Evan Cheng64d80e32007-07-19 01:14:50 +00001961def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001962 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001963 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001964def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001965 "rol{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001966 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001967def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001968 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001969 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001970
Evan Cheng09c54572006-06-29 00:36:51 +00001971// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001972def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001973 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001974 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001975def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001976 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001977 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001978def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001979 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001980 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1981
Chris Lattner40ff6332005-01-19 07:50:03 +00001982let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001983 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001984 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001985 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001986 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001987 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001988 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001989 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001990 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001991 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001992 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1993 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001994 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001995 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001996 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001997 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001998 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00001999 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2000 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002001 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002002 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002003 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002004
2005 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002006 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002007 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002008 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002009 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002010 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002011 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2012 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002013 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002014 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002015 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002016}
2017
Evan Cheng071a2792007-09-11 19:55:27 +00002018let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002019def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002020 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002021 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002022def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002023 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002024 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002025def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002026 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002027 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2028}
Chris Lattner40ff6332005-01-19 07:50:03 +00002029
Evan Cheng64d80e32007-07-19 01:14:50 +00002030def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002031 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002032 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002033def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002034 "ror{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002035 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002036def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002037 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002038 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002039
2040// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002041def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002042 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002043 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002044def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002045 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002046 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002047def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002048 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002049 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2050
Chris Lattner40ff6332005-01-19 07:50:03 +00002051let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002052 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002053 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002054 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002055 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002056 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002057 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002058 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002059 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002060 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002061 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2062 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002063 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002064 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002065 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002066 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002067 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002068 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2069 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002070 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002071 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002072 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002073
2074 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002075 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002076 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002077 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002078 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002079 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002080 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2081 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002082 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002083 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002084 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002085}
2086
2087
2088
2089// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00002090let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002091def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002092 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002093 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002094def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002095 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002096 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002097def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002098 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002099 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002100 TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002101def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002102 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002103 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002104 TB, OpSize;
2105}
Chris Lattner41e431b2005-01-19 07:11:01 +00002106
2107let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00002108def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002109 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002110 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002111 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002112 (i8 imm:$src3)))]>,
2113 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002114def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002115 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002116 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002117 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002118 (i8 imm:$src3)))]>,
2119 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002120def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002121 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002122 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002123 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002124 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002125 TB, OpSize;
2126def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002127 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002128 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002129 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002130 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002131 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00002132}
Chris Lattner0e967d42004-08-01 08:13:11 +00002133
Chris Lattner57a02302004-08-11 04:31:00 +00002134let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002135 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002136 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002137 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002138 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002139 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002140 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002141 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002142 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002143 addr:$dst)]>, TB;
2144 }
Chris Lattner3a173df2004-10-03 20:35:00 +00002145 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002146 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002147 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002148 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002149 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002150 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002151 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002152 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002153 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002154 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002155 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002156 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002157
Evan Cheng071a2792007-09-11 19:55:27 +00002158 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002159 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002160 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002161 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002162 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002163 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002164 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002165 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002166 addr:$dst)]>, TB, OpSize;
2167 }
Chris Lattner0df53d22005-01-19 07:31:24 +00002168 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002169 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002170 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002171 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002172 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002173 TB, OpSize;
2174 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002175 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002176 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002177 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002178 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002179 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002180}
Evan Cheng24f2ea32007-09-14 21:48:26 +00002181} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002182
2183
Chris Lattnercc65bee2005-01-02 02:35:46 +00002184// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00002185let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002186let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002187// Register-Register Addition
2188def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2189 (ins GR8 :$src1, GR8 :$src2),
2190 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002191 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002192 (implicit EFLAGS)]>;
2193
Chris Lattnercc65bee2005-01-02 02:35:46 +00002194let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002195// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002196def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2197 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002198 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002199 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2200 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002201def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2202 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002203 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002204 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2205 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002206} // end isConvertibleToThreeAddress
2207} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002208
2209// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002210def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2211 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002212 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002213 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2214 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002215def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2216 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002217 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002218 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2219 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002220def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2221 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002222 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002223 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2224 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002225
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002226// Register-Integer Addition
2227def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2228 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002229 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2230 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002231
Chris Lattnercc65bee2005-01-02 02:35:46 +00002232let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002233// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002234def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2235 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002236 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002237 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2238 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002239def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2240 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002241 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002242 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2243 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002244def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2245 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002246 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002247 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2248 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002249def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2250 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002251 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002252 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2253 (implicit EFLAGS)]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002254}
Chris Lattner57a02302004-08-11 04:31:00 +00002255
2256let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002257 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002258 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002259 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002260 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2261 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002262 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002263 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002264 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2265 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002266 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002267 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002268 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2269 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002270 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002271 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002272 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2273 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002274 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002275 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002276 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2277 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002278 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002279 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002280 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2281 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002282 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002283 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002284 [(store (add (load addr:$dst), i16immSExt8:$src2),
2285 addr:$dst),
2286 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002287 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002288 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002289 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002290 addr:$dst),
2291 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002292}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002293
Evan Cheng3154cb62007-10-05 17:59:57 +00002294let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002295let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen874ae252009-06-02 03:12:52 +00002296def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002297 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002298 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002299def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2300 (ins GR16:$src1, GR16:$src2),
2301 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002302 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002303def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2304 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002305 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002306 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002307}
Dale Johannesenca11dae2009-05-18 17:44:15 +00002308def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2309 (ins GR8:$src1, i8mem:$src2),
2310 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002311 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002312def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2313 (ins GR16:$src1, i16mem:$src2),
2314 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002315 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002316 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002317def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2318 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002319 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002320 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2321def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002322 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002323 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002324def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2325 (ins GR16:$src1, i16imm:$src2),
2326 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002327 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002328def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2329 (ins GR16:$src1, i16i8imm:$src2),
2330 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002331 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2332 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002333def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2334 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002335 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002336 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002337def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2338 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002339 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002340 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002341
2342let isTwoAddress = 0 in {
Dale Johannesen874ae252009-06-02 03:12:52 +00002343 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002344 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002345 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2346 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002347 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002348 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2349 OpSize;
2350 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002351 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002352 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2353 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002354 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002355 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2356 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002357 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002358 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2359 OpSize;
2360 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002361 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002362 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2363 OpSize;
2364 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002365 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002366 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2367 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002368 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002369 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2370}
Evan Cheng3154cb62007-10-05 17:59:57 +00002371} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002372
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002373// Register-Register Subtraction
2374def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2375 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002376 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2377 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002378def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2379 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002380 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2381 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002382def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2383 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002384 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2385 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002386
2387// Register-Memory Subtraction
2388def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2389 (ins GR8 :$src1, i8mem :$src2),
2390 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002391 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2392 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002393def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2394 (ins GR16:$src1, i16mem:$src2),
2395 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002396 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2397 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002398def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2399 (ins GR32:$src1, i32mem:$src2),
2400 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002401 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2402 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002403
2404// Register-Integer Subtraction
2405def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2406 (ins GR8:$src1, i8imm:$src2),
2407 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002408 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2409 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002410def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2411 (ins GR16:$src1, i16imm:$src2),
2412 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002413 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2414 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002415def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2416 (ins GR32:$src1, i32imm:$src2),
2417 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002418 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2419 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002420def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2421 (ins GR16:$src1, i16i8imm:$src2),
2422 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002423 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2424 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002425def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2426 (ins GR32:$src1, i32i8imm:$src2),
2427 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002428 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2429 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002430
Chris Lattner57a02302004-08-11 04:31:00 +00002431let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002432 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002433 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002434 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002435 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2436 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002437 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002438 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002439 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2440 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002441 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002442 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002443 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2444 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002445
2446 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002447 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002448 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002449 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2450 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002451 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002452 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002453 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2454 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002455 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002456 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002457 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2458 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002459 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002460 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002461 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002462 addr:$dst),
2463 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002464 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002465 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002466 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002467 addr:$dst),
2468 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002469}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002470
Evan Cheng3154cb62007-10-05 17:59:57 +00002471let Uses = [EFLAGS] in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00002472def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2473 (ins GR8:$src1, GR8:$src2),
2474 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002475 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002476def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2477 (ins GR16:$src1, GR16:$src2),
2478 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002479 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002480def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2481 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002482 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002483 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00002484
Chris Lattner57a02302004-08-11 04:31:00 +00002485let isTwoAddress = 0 in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00002486 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2487 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002488 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002489 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2490 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002491 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002492 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002493 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002494 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002495 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002496 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002497 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002498 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002499 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2500 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002501 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002502 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002503 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2504 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002505 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002506 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002507 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002508 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002509 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002510 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002511 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002512 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002513}
Dale Johannesenca11dae2009-05-18 17:44:15 +00002514def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2515 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002516 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002517def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2518 (ins GR16:$src1, i16mem:$src2),
2519 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002520 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002521 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002522def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2523 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002524 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002525 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002526def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2527 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002528 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002529def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2530 (ins GR16:$src1, i16imm:$src2),
2531 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002532 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002533def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2534 (ins GR16:$src1, i16i8imm:$src2),
2535 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002536 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2537 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002538def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2539 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002540 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002541 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002542def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2543 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002544 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002545 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00002546} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00002547} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002548
Evan Cheng24f2ea32007-09-14 21:48:26 +00002549let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002550let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00002551// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002552def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002553 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002554 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2555 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002556def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002557 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002558 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2559 (implicit EFLAGS)]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00002560}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002561
Bill Wendlingd350e022008-12-12 21:15:41 +00002562// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002563def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2564 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002565 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002566 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2567 (implicit EFLAGS)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002568def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002569 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002570 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2571 (implicit EFLAGS)]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002572} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002573} // end Two Address instructions
2574
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002575// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00002576let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00002577// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00002578def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002579 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002580 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002581 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2582 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002583def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002584 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002585 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002586 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2587 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002588def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002589 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002590 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002591 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2592 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002593def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002594 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002595 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002596 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2597 (implicit EFLAGS)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002598
Bill Wendlingd350e022008-12-12 21:15:41 +00002599// Memory-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00002600def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002601 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002602 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002603 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2604 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002605def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002606 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002607 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002608 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2609 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002610def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002611 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002612 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002613 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00002614 i16immSExt8:$src2)),
2615 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002616def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002617 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002618 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002619 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00002620 i32immSExt8:$src2)),
2621 (implicit EFLAGS)]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002622} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002623
2624//===----------------------------------------------------------------------===//
2625// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002626//
Evan Cheng0488db92007-09-25 01:57:46 +00002627let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002628let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng64d80e32007-07-19 01:14:50 +00002629def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002630 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002631 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002632 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002633def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002634 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002635 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002636 (implicit EFLAGS)]>,
2637 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002638def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002639 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002640 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002641 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002642}
Evan Cheng734503b2006-09-11 02:19:56 +00002643
Evan Cheng64d80e32007-07-19 01:14:50 +00002644def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002645 "test{b}\t{$src2, $src1|$src1, $src2}",
2646 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2647 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002648def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002649 "test{w}\t{$src2, $src1|$src1, $src2}",
2650 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2651 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002652def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002653 "test{l}\t{$src2, $src1|$src1, $src2}",
2654 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2655 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002656
Evan Cheng069287d2006-05-16 07:21:53 +00002657def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002658 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002659 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002660 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002661 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002662def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002663 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002664 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002665 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002666 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002667def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002668 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002669 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002670 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002671 (implicit EFLAGS)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00002672
Evan Chenge5f62042007-09-29 00:00:36 +00002673def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002674 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002675 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002676 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2677 (implicit EFLAGS)]>;
2678def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002679 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002680 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002681 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2682 (implicit EFLAGS)]>, OpSize;
2683def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002684 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002685 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002686 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng0488db92007-09-25 01:57:46 +00002687 (implicit EFLAGS)]>;
2688} // Defs = [EFLAGS]
2689
2690
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002691// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00002692let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002693def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00002694let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002695def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002696
Evan Cheng0488db92007-09-25 01:57:46 +00002697let Uses = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002698def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002699 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002700 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002701 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002702 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002703def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002704 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002705 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002706 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002707 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00002708
Chris Lattner3a173df2004-10-03 20:35:00 +00002709def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002710 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002711 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002712 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002713 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002714def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002715 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002716 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002717 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002718 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00002719
Evan Chengd5781fc2005-12-21 20:21:51 +00002720def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002721 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002722 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002723 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002724 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002725def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002726 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002727 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002728 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002729 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00002730
Evan Chengd5781fc2005-12-21 20:21:51 +00002731def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002732 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002733 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002734 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002735 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002736def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002737 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002738 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002739 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002740 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00002741
Evan Chengd5781fc2005-12-21 20:21:51 +00002742def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002743 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002744 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002745 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002746 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002747def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002748 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002749 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002750 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002751 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00002752
Evan Chengd5781fc2005-12-21 20:21:51 +00002753def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002754 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002755 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002756 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002757 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002758def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002759 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002760 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002761 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002762 TB; // [mem8] = > signed
2763
2764def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002765 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002766 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002767 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002768 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002769def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002770 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002771 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002772 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002773 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002774
Evan Chengd5781fc2005-12-21 20:21:51 +00002775def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002776 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002777 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002778 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002779 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002780def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002781 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002782 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002783 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002784 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002785
Chris Lattner3a173df2004-10-03 20:35:00 +00002786def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002787 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002788 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002789 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002790 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002791def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002792 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002793 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002794 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002795 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002796
Chris Lattner3a173df2004-10-03 20:35:00 +00002797def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002798 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002799 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002800 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002801 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002802def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002803 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002804 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002805 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002806 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002807
Chris Lattner3a173df2004-10-03 20:35:00 +00002808def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002809 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002810 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002811 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002812 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002813def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002814 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002815 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002816 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002817 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002818def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002819 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002820 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002821 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002822 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002823def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002824 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002825 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002826 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002827 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00002828
Chris Lattner3a173df2004-10-03 20:35:00 +00002829def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002830 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002831 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002832 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002833 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002834def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002835 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002836 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002837 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002838 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002839def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002840 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002841 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002842 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002843 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002844def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002845 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002846 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002847 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002848 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00002849
2850def SETOr : I<0x90, MRM0r,
2851 (outs GR8 :$dst), (ins),
2852 "seto\t$dst",
2853 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2854 TB; // GR8 = overflow
2855def SETOm : I<0x90, MRM0m,
2856 (outs), (ins i8mem:$dst),
2857 "seto\t$dst",
2858 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2859 TB; // [mem8] = overflow
2860def SETNOr : I<0x91, MRM0r,
2861 (outs GR8 :$dst), (ins),
2862 "setno\t$dst",
2863 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2864 TB; // GR8 = not overflow
2865def SETNOm : I<0x91, MRM0m,
2866 (outs), (ins i8mem:$dst),
2867 "setno\t$dst",
2868 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2869 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00002870} // Uses = [EFLAGS]
2871
Chris Lattner1cca5e32003-08-03 21:54:21 +00002872
2873// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00002874let Defs = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002875def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002876 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002877 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002878 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002879def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002880 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002881 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002882 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002883def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002884 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002885 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002886 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002887def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002888 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002889 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002890 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2891 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002892def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002893 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002894 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002895 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2896 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002897def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002898 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002899 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002900 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2901 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002902def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002903 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002904 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002905 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2906 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002907def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002908 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002909 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002910 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2911 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002912def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002913 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002914 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002915 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2916 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002917def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002918 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002919 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002920 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002921def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002922 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002923 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002924 [(X86cmp GR16:$src1, imm:$src2),
2925 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002926def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002927 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002928 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002929 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002930def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002931 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002932 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002933 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2934 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002935def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002936 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002937 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002938 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2939 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002940def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002941 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002942 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002943 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2944 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002945def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002946 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002947 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002948 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2949 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002950def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002951 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002952 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002953 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2954 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002955def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002956 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002957 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002958 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2959 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002960def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002961 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002962 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002963 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +00002964 (implicit EFLAGS)]>;
2965} // Defs = [EFLAGS]
2966
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002967// Bit tests.
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002968// TODO: BTC, BTR, and BTS
2969let Defs = [EFLAGS] in {
Dan Gohman0c89b7e2009-01-13 20:32:45 +00002970def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002971 "bt{w}\t{$src2, $src1|$src1, $src2}",
2972 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00002973 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohman0c89b7e2009-01-13 20:32:45 +00002974def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002975 "bt{l}\t{$src2, $src1|$src1, $src2}",
2976 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00002977 (implicit EFLAGS)]>, TB;
Dan Gohmanf31408d2009-01-13 23:23:30 +00002978
2979// Unlike with the register+register form, the memory+register form of the
2980// bt instruction does not ignore the high bits of the index. From ISel's
2981// perspective, this is pretty bizarre. Disable these instructions for now.
2982//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2983// "bt{w}\t{$src2, $src1|$src1, $src2}",
2984// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2985// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2986//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2987// "bt{l}\t{$src2, $src1|$src1, $src2}",
2988// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2989// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman4afe15b2009-01-13 20:33:23 +00002990
2991def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2992 "bt{w}\t{$src2, $src1|$src1, $src2}",
2993 [(X86bt GR16:$src1, i16immSExt8:$src2),
2994 (implicit EFLAGS)]>, OpSize, TB;
2995def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2996 "bt{l}\t{$src2, $src1|$src1, $src2}",
2997 [(X86bt GR32:$src1, i32immSExt8:$src2),
2998 (implicit EFLAGS)]>, TB;
2999// Note that these instructions don't need FastBTMem because that
3000// only applies when the other operand is in a register. When it's
3001// an immediate, bt is still fast.
3002def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3003 "bt{w}\t{$src2, $src1|$src1, $src2}",
3004 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3005 (implicit EFLAGS)]>, OpSize, TB;
3006def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3007 "bt{l}\t{$src2, $src1|$src1, $src2}",
3008 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3009 (implicit EFLAGS)]>, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003010} // Defs = [EFLAGS]
3011
Chris Lattner1cca5e32003-08-03 21:54:21 +00003012// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00003013// Use movsbl intead of movsbw; we don't care about the high 16 bits
3014// of the register here. This has a smaller encoding and avoids a
3015// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00003016def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003017 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3018 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003019def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003020 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3021 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003022def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003023 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003024 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003025def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003026 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003027 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003028def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003029 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003030 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003031def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003032 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003033 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00003034
Dan Gohman11ba3b12008-07-30 18:09:17 +00003035// Use movzbl intead of movzbw; we don't care about the high 16 bits
3036// of the register here. This has a smaller encoding and avoids a
3037// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00003038def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003039 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3040 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003041def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003042 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3043 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003044def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003045 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003046 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003047def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003048 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003049 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003050def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003051 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003052 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003053def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003054 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003055 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00003056
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003057// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3058// except that they use GR32_NOREX for the output operand register class
3059// instead of GR32. This allows them to operate on h registers on x86-64.
3060def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3061 (outs GR32_NOREX:$dst), (ins GR8:$src),
3062 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3063 []>, TB;
Dan Gohman78e04d42009-04-30 03:11:48 +00003064let mayLoad = 1 in
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003065def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3066 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3067 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3068 []>, TB;
3069
Chris Lattnerba7e7562008-01-10 07:59:24 +00003070let neverHasSideEffects = 1 in {
3071 let Defs = [AX], Uses = [AL] in
3072 def CBW : I<0x98, RawFrm, (outs), (ins),
3073 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3074 let Defs = [EAX], Uses = [AX] in
3075 def CWDE : I<0x98, RawFrm, (outs), (ins),
3076 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00003077
Chris Lattnerba7e7562008-01-10 07:59:24 +00003078 let Defs = [AX,DX], Uses = [AX] in
3079 def CWD : I<0x99, RawFrm, (outs), (ins),
3080 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3081 let Defs = [EAX,EDX], Uses = [EAX] in
3082 def CDQ : I<0x99, RawFrm, (outs), (ins),
3083 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3084}
Evan Cheng747a90d2006-02-21 02:24:38 +00003085
Evan Cheng747a90d2006-02-21 02:24:38 +00003086//===----------------------------------------------------------------------===//
3087// Alias Instructions
3088//===----------------------------------------------------------------------===//
3089
3090// Alias instructions that map movr0 to xor.
3091// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00003092let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003093def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003094 "xor{b}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00003095 [(set GR8:$dst, 0)]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00003096// Use xorl instead of xorw since we don't care about the high 16 bits,
3097// it's smaller, and it avoids a partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00003098def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003099 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3100 [(set GR16:$dst, 0)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003101def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003102 "xor{l}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00003103 [(set GR32:$dst, 0)]>;
Dan Gohman1ab79892007-09-07 21:32:51 +00003104}
Evan Cheng747a90d2006-02-21 02:24:38 +00003105
Evan Cheng510e4782006-01-09 23:10:28 +00003106//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003107// Thread Local Storage Instructions
3108//
3109
Rafael Espindola15f1b662009-04-24 12:59:40 +00003110// All calls clobber the non-callee saved registers. ESP is marked as
3111// a use to prevent stack-pointer assignments that appear immediately
3112// before calls from potentially appearing dead.
3113let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3114 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3115 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3116 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003117 Uses = [ESP] in
3118def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3119 "leal\t$sym, %eax; "
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003120 "call\t___tls_get_addr@PLT",
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003121 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindola2ee3db32009-04-17 14:35:58 +00003122 Requires<[In32BitMode]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003123
Nate Begeman51a04372009-01-26 01:24:32 +00003124let AddedComplexity = 5 in
3125def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3126 "movl\t%gs:$src, $dst",
3127 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3128
Chris Lattner1777d0c2009-05-05 18:52:19 +00003129let AddedComplexity = 5 in
3130def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3131 "movl\t%fs:$src, $dst",
3132 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3133
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003134//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00003135// DWARF Pseudo Instructions
3136//
3137
Evan Cheng64d80e32007-07-19 01:14:50 +00003138def DWARF_LOC : I<0, Pseudo, (outs),
3139 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman6b5766e2007-09-24 19:25:06 +00003140 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Evan Cheng3c992d22006-03-07 02:02:57 +00003141 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3142 (i32 imm:$file))]>;
3143
Evan Cheng3c992d22006-03-07 02:02:57 +00003144//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003145// EH Pseudo Instructions
3146//
3147let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Chengffbacca2007-07-21 00:34:19 +00003148 hasCtrlDep = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003149def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003150 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003151 [(X86ehret GR32:$addr)]>;
3152
3153}
3154
3155//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003156// Atomic support
3157//
Andrew Lenharthea7da502008-03-01 13:37:02 +00003158
Evan Chengbb6939d2008-04-19 01:20:30 +00003159// Atomic swap. These are just normal xchg instructions. But since a memory
3160// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00003161let Constraints = "$val = $dst" in {
Evan Chengbb6939d2008-04-19 01:20:30 +00003162def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3163 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3164 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3165def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3166 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3167 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3168 OpSize;
3169def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3170 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3171 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3172}
3173
Evan Cheng7e032802008-04-18 20:55:36 +00003174// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003175let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003176def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003177 "lock\n\t"
3178 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003179 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003180}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003181let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovf88a6fa2008-07-22 16:22:48 +00003182def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003183 "lock\n\t"
3184 "cmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00003185 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3186}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003187
3188let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003189def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003190 "lock\n\t"
3191 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003192 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003193}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003194let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003195def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003196 "lock\n\t"
3197 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003198 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003199}
3200
Evan Cheng7e032802008-04-18 20:55:36 +00003201// Atomic exchange and add
3202let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3203def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003204 "lock\n\t"
3205 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003206 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003207 TB, LOCK;
3208def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003209 "lock\n\t"
3210 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003211 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003212 TB, OpSize, LOCK;
3213def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003214 "lock\n\t"
3215 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003216 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003217 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003218}
3219
Mon P Wang28873102008-06-25 08:15:39 +00003220// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00003221let Constraints = "$val = $dst", Defs = [EFLAGS],
3222 usesCustomDAGSchedInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00003223def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003224 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003225 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003226def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003227 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003228 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003229def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003230 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003231 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00003232def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003233 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003234 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003235def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003236 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003237 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003238def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003239 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003240 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003241def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003242 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003243 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003244def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003245 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003246 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003247
3248def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003249 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003250 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003251def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003252 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003253 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003254def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003255 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003256 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003257def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003258 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003259 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003260def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003261 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003262 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003263def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003264 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003265 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003266def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003267 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003268 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003269def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003270 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003271 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003272
3273def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003274 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003275 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003276def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003277 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003278 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003279def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003280 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003281 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003282def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003283 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003284 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00003285}
3286
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003287let Constraints = "$val1 = $dst1, $val2 = $dst2",
3288 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3289 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00003290 mayLoad = 1, mayStore = 1,
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003291 usesCustomDAGSchedInserter = 1 in {
3292def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3293 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003294 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003295def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3296 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003297 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003298def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3299 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003300 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003301def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3302 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003303 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003304def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3305 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003306 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003307def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3308 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003309 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00003310def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3311 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003312 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003313}
3314
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003315//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00003316// Non-Instruction Patterns
3317//===----------------------------------------------------------------------===//
3318
Bill Wendling056292f2008-09-16 21:48:12 +00003319// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00003320def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00003321def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00003322def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00003323def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3324def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3325
Evan Cheng069287d2006-05-16 07:21:53 +00003326def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3327 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3328def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3329 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3330def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3331 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3332def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3333 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00003334
Evan Chengfc8feb12006-05-19 07:30:36 +00003335def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00003336 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00003337def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00003338 (MOV32mi addr:$dst, texternalsym:$src)>;
3339
Evan Cheng510e4782006-01-09 23:10:28 +00003340// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003341// tailcall stuff
Evan Cheng069287d2006-05-16 07:21:53 +00003342def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003343 (TAILCALL)>;
Evan Chengfea89c12006-04-27 08:40:39 +00003344
Evan Cheng25ab6902006-09-08 06:48:29 +00003345def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003346 (TAILCALL)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00003347def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003348 (TAILCALL)>;
3349
3350def : Pat<(X86tcret GR32:$dst, imm:$off),
3351 (TCRETURNri GR32:$dst, imm:$off)>;
3352
3353def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3354 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3355
3356def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3357 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Evan Chengfea89c12006-04-27 08:40:39 +00003358
Evan Cheng25ab6902006-09-08 06:48:29 +00003359def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00003360 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00003361def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00003362 (CALLpcrel32 texternalsym:$dst)>;
Evan Chengd7f666a2009-05-20 04:53:57 +00003363def : Pat<(X86call (i32 imm:$dst)),
3364 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Evan Cheng510e4782006-01-09 23:10:28 +00003365
3366// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00003367def : Pat<(addc GR32:$src1, GR32:$src2),
3368 (ADD32rr GR32:$src1, GR32:$src2)>;
3369def : Pat<(addc GR32:$src1, (load addr:$src2)),
3370 (ADD32rm GR32:$src1, addr:$src2)>;
3371def : Pat<(addc GR32:$src1, imm:$src2),
3372 (ADD32ri GR32:$src1, imm:$src2)>;
3373def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3374 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003375
Evan Cheng069287d2006-05-16 07:21:53 +00003376def : Pat<(subc GR32:$src1, GR32:$src2),
3377 (SUB32rr GR32:$src1, GR32:$src2)>;
3378def : Pat<(subc GR32:$src1, (load addr:$src2)),
3379 (SUB32rm GR32:$src1, addr:$src2)>;
3380def : Pat<(subc GR32:$src1, imm:$src2),
3381 (SUB32ri GR32:$src1, imm:$src2)>;
3382def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3383 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003384
Chris Lattnerffc0b262006-09-07 20:33:45 +00003385// Comparisons.
3386
3387// TEST R,R is smaller than CMP R,0
Evan Chenge5f62042007-09-29 00:00:36 +00003388def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003389 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00003390def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003391 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00003392def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003393 (TEST32rr GR32:$src1, GR32:$src1)>;
3394
Dan Gohmanfbb74862009-01-07 01:00:24 +00003395// Conditional moves with folded loads with operands swapped and conditions
3396// inverted.
3397def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3398 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3399def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3400 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3401def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3402 (CMOVB16rm GR16:$src2, addr:$src1)>;
3403def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3404 (CMOVB32rm GR32:$src2, addr:$src1)>;
3405def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3406 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3407def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3408 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3409def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3410 (CMOVE16rm GR16:$src2, addr:$src1)>;
3411def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3412 (CMOVE32rm GR32:$src2, addr:$src1)>;
3413def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3414 (CMOVA16rm GR16:$src2, addr:$src1)>;
3415def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3416 (CMOVA32rm GR32:$src2, addr:$src1)>;
3417def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3418 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3419def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3420 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3421def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3422 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3423def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3424 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3425def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3426 (CMOVL16rm GR16:$src2, addr:$src1)>;
3427def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3428 (CMOVL32rm GR32:$src2, addr:$src1)>;
3429def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3430 (CMOVG16rm GR16:$src2, addr:$src1)>;
3431def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3432 (CMOVG32rm GR32:$src2, addr:$src1)>;
3433def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3434 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3435def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3436 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3437def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3438 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3439def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3440 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3441def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3442 (CMOVP16rm GR16:$src2, addr:$src1)>;
3443def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3444 (CMOVP32rm GR32:$src2, addr:$src1)>;
3445def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3446 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3447def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3448 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3449def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3450 (CMOVS16rm GR16:$src2, addr:$src1)>;
3451def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3452 (CMOVS32rm GR32:$src2, addr:$src1)>;
3453def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3454 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3455def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3456 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3457def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3458 (CMOVO16rm GR16:$src2, addr:$src1)>;
3459def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3460 (CMOVO32rm GR32:$src2, addr:$src1)>;
3461
Duncan Sandsf9c98e62008-01-23 20:39:46 +00003462// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00003463def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003464def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3465def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3466
3467// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00003468def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendling449416d2008-08-22 20:51:05 +00003469def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3470 Requires<[In32BitMode]>;
Evan Cheng47137242006-05-05 08:23:07 +00003471def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendling449416d2008-08-22 20:51:05 +00003472def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3473 Requires<[In32BitMode]>;
Evan Cheng47137242006-05-05 08:23:07 +00003474def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3475def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003476
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003477// anyext
Bill Wendling449416d2008-08-22 20:51:05 +00003478def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3479 Requires<[In32BitMode]>;
3480def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3481 Requires<[In32BitMode]>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003482def : Pat<(i32 (anyext GR16:$src)),
3483 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003484
Evan Cheng1314b002007-12-13 00:43:27 +00003485// (and (i32 load), 255) -> (zextload i8)
Evan Chengd47e0b62008-09-29 17:26:18 +00003486def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3487 (MOVZX32rm8 addr:$src)>;
3488def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3489 (MOVZX32rm16 addr:$src)>;
Evan Cheng1314b002007-12-13 00:43:27 +00003490
Evan Chengcfa260b2006-01-06 02:31:59 +00003491//===----------------------------------------------------------------------===//
3492// Some peepholes
3493//===----------------------------------------------------------------------===//
3494
Dan Gohman63f97202008-10-17 01:33:43 +00003495// Odd encoding trick: -128 fits into an 8-bit immediate field while
3496// +128 doesn't, so in this special case use a sub instead of an add.
3497def : Pat<(add GR16:$src1, 128),
3498 (SUB16ri8 GR16:$src1, -128)>;
3499def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3500 (SUB16mi8 addr:$dst, -128)>;
3501def : Pat<(add GR32:$src1, 128),
3502 (SUB32ri8 GR32:$src1, -128)>;
3503def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3504 (SUB32mi8 addr:$dst, -128)>;
3505
Dan Gohman11ba3b12008-07-30 18:09:17 +00003506// r & (2^16-1) ==> movz
3507def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003508 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00003509// r & (2^8-1) ==> movz
3510def : Pat<(and GR32:$src1, 0xff),
Dan Gohman62417622009-04-27 16:33:14 +00003511 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003512 x86_subreg_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00003513 Requires<[In32BitMode]>;
3514// r & (2^8-1) ==> movz
3515def : Pat<(and GR16:$src1, 0xff),
Dan Gohman62417622009-04-27 16:33:14 +00003516 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003517 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003518 Requires<[In32BitMode]>;
3519
3520// sext_inreg patterns
3521def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003522 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003523def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman62417622009-04-27 16:33:14 +00003524 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003525 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003526 Requires<[In32BitMode]>;
3527def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman62417622009-04-27 16:33:14 +00003528 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003529 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003530 Requires<[In32BitMode]>;
3531
3532// trunc patterns
3533def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003534 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003535def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman62417622009-04-27 16:33:14 +00003536 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003537 x86_subreg_8bit)>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003538 Requires<[In32BitMode]>;
3539def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman62417622009-04-27 16:33:14 +00003540 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003541 x86_subreg_8bit)>,
3542 Requires<[In32BitMode]>;
3543
3544// h-register tricks
3545def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman62417622009-04-27 16:33:14 +00003546 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003547 x86_subreg_8bit_hi)>,
3548 Requires<[In32BitMode]>;
3549def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman62417622009-04-27 16:33:14 +00003550 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003551 x86_subreg_8bit_hi)>,
3552 Requires<[In32BitMode]>;
3553def : Pat<(srl_su GR16:$src, (i8 8)),
3554 (EXTRACT_SUBREG
3555 (MOVZX32rr8
Dan Gohman62417622009-04-27 16:33:14 +00003556 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003557 x86_subreg_8bit_hi)),
3558 x86_subreg_16bit)>,
3559 Requires<[In32BitMode]>;
Evan Chengcb219f02009-05-29 01:44:43 +00003560def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3561 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3562 x86_subreg_8bit_hi))>,
3563 Requires<[In32BitMode]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003564def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman62417622009-04-27 16:33:14 +00003565 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003566 x86_subreg_8bit_hi))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00003567 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00003568
Evan Chengcfa260b2006-01-06 02:31:59 +00003569// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00003570def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3571def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3572def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00003573
Evan Chengeb9f8922008-08-30 02:03:58 +00003574// (shl x (and y, 31)) ==> (shl x, y)
3575def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3576 (SHL8rCL GR8:$src1)>;
3577def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3578 (SHL16rCL GR16:$src1)>;
3579def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3580 (SHL32rCL GR32:$src1)>;
3581def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3582 (SHL8mCL addr:$dst)>;
3583def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3584 (SHL16mCL addr:$dst)>;
3585def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3586 (SHL32mCL addr:$dst)>;
3587
3588def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3589 (SHR8rCL GR8:$src1)>;
3590def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3591 (SHR16rCL GR16:$src1)>;
3592def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3593 (SHR32rCL GR32:$src1)>;
3594def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3595 (SHR8mCL addr:$dst)>;
3596def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3597 (SHR16mCL addr:$dst)>;
3598def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3599 (SHR32mCL addr:$dst)>;
3600
3601def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3602 (SAR8rCL GR8:$src1)>;
3603def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3604 (SAR16rCL GR16:$src1)>;
3605def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3606 (SAR32rCL GR32:$src1)>;
3607def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3608 (SAR8mCL addr:$dst)>;
3609def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3610 (SAR16mCL addr:$dst)>;
3611def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3612 (SAR32mCL addr:$dst)>;
3613
Evan Cheng956044c2006-01-19 23:26:24 +00003614// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003615def : Pat<(or (srl GR32:$src1, CL:$amt),
3616 (shl GR32:$src2, (sub 32, CL:$amt))),
3617 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00003618
Evan Cheng21d54432006-01-20 01:13:30 +00003619def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003620 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3621 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003622
Dan Gohman74feef22008-10-17 01:23:35 +00003623def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3624 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3625 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3626
3627def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3628 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3629 addr:$dst),
3630 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3631
3632def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3633 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3634
3635def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3636 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3637 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3638
Evan Cheng956044c2006-01-19 23:26:24 +00003639// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003640def : Pat<(or (shl GR32:$src1, CL:$amt),
3641 (srl GR32:$src2, (sub 32, CL:$amt))),
3642 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003643
Evan Cheng21d54432006-01-20 01:13:30 +00003644def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003645 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3646 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003647
Dan Gohman74feef22008-10-17 01:23:35 +00003648def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3649 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3650 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3651
3652def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3653 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3654 addr:$dst),
3655 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3656
3657def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3658 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3659
3660def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3661 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3662 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3663
Evan Cheng956044c2006-01-19 23:26:24 +00003664// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003665def : Pat<(or (srl GR16:$src1, CL:$amt),
3666 (shl GR16:$src2, (sub 16, CL:$amt))),
3667 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003668
Evan Cheng21d54432006-01-20 01:13:30 +00003669def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003670 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3671 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003672
Dan Gohman74feef22008-10-17 01:23:35 +00003673def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3674 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3675 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3676
3677def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3678 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3679 addr:$dst),
3680 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3681
3682def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3683 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3684
3685def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3686 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3687 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3688
Evan Cheng956044c2006-01-19 23:26:24 +00003689// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003690def : Pat<(or (shl GR16:$src1, CL:$amt),
3691 (srl GR16:$src2, (sub 16, CL:$amt))),
3692 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003693
3694def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003695 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3696 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003697
Dan Gohman74feef22008-10-17 01:23:35 +00003698def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3699 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3700 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3701
3702def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3703 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3704 addr:$dst),
3705 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3706
3707def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3708 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3709
3710def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3711 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3712 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3713
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003714//===----------------------------------------------------------------------===//
Dan Gohman076aee32009-03-04 19:44:21 +00003715// EFLAGS-defining Patterns
Bill Wendlingd350e022008-12-12 21:15:41 +00003716//===----------------------------------------------------------------------===//
3717
Dan Gohman076aee32009-03-04 19:44:21 +00003718// Register-Register Addition with EFLAGS result
3719def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003720 (implicit EFLAGS)),
3721 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003722def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003723 (implicit EFLAGS)),
3724 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003725def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003726 (implicit EFLAGS)),
3727 (ADD32rr GR32:$src1, GR32:$src2)>;
3728
Dan Gohman076aee32009-03-04 19:44:21 +00003729// Register-Memory Addition with EFLAGS result
3730def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003731 (implicit EFLAGS)),
3732 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003733def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003734 (implicit EFLAGS)),
3735 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003736def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003737 (implicit EFLAGS)),
3738 (ADD32rm GR32:$src1, addr:$src2)>;
3739
Dan Gohman076aee32009-03-04 19:44:21 +00003740// Register-Integer Addition with EFLAGS result
3741def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003742 (implicit EFLAGS)),
3743 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003744def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003745 (implicit EFLAGS)),
3746 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003747def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003748 (implicit EFLAGS)),
3749 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003750def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003751 (implicit EFLAGS)),
3752 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003753def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003754 (implicit EFLAGS)),
3755 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3756
Dan Gohman076aee32009-03-04 19:44:21 +00003757// Memory-Register Addition with EFLAGS result
3758def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003759 addr:$dst),
3760 (implicit EFLAGS)),
3761 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003762def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003763 addr:$dst),
3764 (implicit EFLAGS)),
3765 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003766def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003767 addr:$dst),
3768 (implicit EFLAGS)),
3769 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003770
3771// Memory-Integer Addition with EFLAGS result
Dan Gohman076aee32009-03-04 19:44:21 +00003772def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003773 addr:$dst),
3774 (implicit EFLAGS)),
3775 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003776def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003777 addr:$dst),
3778 (implicit EFLAGS)),
3779 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003780def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003781 addr:$dst),
3782 (implicit EFLAGS)),
3783 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003784def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003785 addr:$dst),
3786 (implicit EFLAGS)),
3787 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003788def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003789 addr:$dst),
3790 (implicit EFLAGS)),
3791 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3792
Dan Gohman076aee32009-03-04 19:44:21 +00003793// Register-Register Subtraction with EFLAGS result
3794def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003795 (implicit EFLAGS)),
3796 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003797def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003798 (implicit EFLAGS)),
3799 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003800def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003801 (implicit EFLAGS)),
3802 (SUB32rr GR32:$src1, GR32:$src2)>;
3803
Dan Gohman076aee32009-03-04 19:44:21 +00003804// Register-Memory Subtraction with EFLAGS result
3805def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003806 (implicit EFLAGS)),
3807 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003808def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003809 (implicit EFLAGS)),
3810 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003811def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003812 (implicit EFLAGS)),
3813 (SUB32rm GR32:$src1, addr:$src2)>;
3814
Dan Gohman076aee32009-03-04 19:44:21 +00003815// Register-Integer Subtraction with EFLAGS result
3816def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003817 (implicit EFLAGS)),
3818 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003819def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003820 (implicit EFLAGS)),
3821 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003822def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003823 (implicit EFLAGS)),
3824 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003825def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003826 (implicit EFLAGS)),
3827 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003828def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003829 (implicit EFLAGS)),
3830 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3831
Dan Gohman076aee32009-03-04 19:44:21 +00003832// Memory-Register Subtraction with EFLAGS result
3833def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003834 addr:$dst),
3835 (implicit EFLAGS)),
3836 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003837def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003838 addr:$dst),
3839 (implicit EFLAGS)),
3840 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003841def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003842 addr:$dst),
3843 (implicit EFLAGS)),
3844 (SUB32mr addr:$dst, GR32:$src2)>;
3845
Dan Gohman076aee32009-03-04 19:44:21 +00003846// Memory-Integer Subtraction with EFLAGS result
3847def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003848 addr:$dst),
3849 (implicit EFLAGS)),
3850 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003851def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003852 addr:$dst),
3853 (implicit EFLAGS)),
3854 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003855def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003856 addr:$dst),
3857 (implicit EFLAGS)),
3858 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003859def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003860 addr:$dst),
3861 (implicit EFLAGS)),
3862 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003863def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003864 addr:$dst),
3865 (implicit EFLAGS)),
3866 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3867
3868
Dan Gohman076aee32009-03-04 19:44:21 +00003869// Register-Register Signed Integer Multiply with EFLAGS result
3870def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003871 (implicit EFLAGS)),
3872 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003873def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003874 (implicit EFLAGS)),
3875 (IMUL32rr GR32:$src1, GR32:$src2)>;
3876
Dan Gohman076aee32009-03-04 19:44:21 +00003877// Register-Memory Signed Integer Multiply with EFLAGS result
3878def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003879 (implicit EFLAGS)),
3880 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003881def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003882 (implicit EFLAGS)),
3883 (IMUL32rm GR32:$src1, addr:$src2)>;
3884
Dan Gohman076aee32009-03-04 19:44:21 +00003885// Register-Integer Signed Integer Multiply with EFLAGS result
3886def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003887 (implicit EFLAGS)),
3888 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003889def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003890 (implicit EFLAGS)),
3891 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003892def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003893 (implicit EFLAGS)),
3894 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003895def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003896 (implicit EFLAGS)),
3897 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3898
Dan Gohman076aee32009-03-04 19:44:21 +00003899// Memory-Integer Signed Integer Multiply with EFLAGS result
3900def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003901 (implicit EFLAGS)),
3902 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003903def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003904 (implicit EFLAGS)),
3905 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003906def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003907 (implicit EFLAGS)),
3908 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003909def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003910 (implicit EFLAGS)),
3911 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3912
Dan Gohman076aee32009-03-04 19:44:21 +00003913// Optimize multiply by 2 with EFLAGS result.
Evan Cheng6a86bd72009-01-27 03:30:42 +00003914let AddedComplexity = 2 in {
Dan Gohman076aee32009-03-04 19:44:21 +00003915def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00003916 (implicit EFLAGS)),
3917 (ADD16rr GR16:$src1, GR16:$src1)>;
3918
Dan Gohman076aee32009-03-04 19:44:21 +00003919def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00003920 (implicit EFLAGS)),
3921 (ADD32rr GR32:$src1, GR32:$src1)>;
3922}
3923
Dan Gohman076aee32009-03-04 19:44:21 +00003924// INC and DEC with EFLAGS result. Note that these do not set CF.
3925def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3926 (INC8r GR8:$src)>;
3927def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3928 (implicit EFLAGS)),
3929 (INC8m addr:$dst)>;
3930def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3931 (DEC8r GR8:$src)>;
3932def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3933 (implicit EFLAGS)),
3934 (DEC8m addr:$dst)>;
3935
3936def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003937 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003938def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3939 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003940 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003941def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003942 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003943def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3944 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003945 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003946
3947def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003948 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003949def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3950 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003951 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003952def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003953 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003954def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3955 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003956 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003957
Bill Wendlingd350e022008-12-12 21:15:41 +00003958//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003959// Floating Point Stack Support
3960//===----------------------------------------------------------------------===//
3961
3962include "X86InstrFPStack.td"
3963
3964//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00003965// X86-64 Support
3966//===----------------------------------------------------------------------===//
3967
Chris Lattner36fe6d22008-01-10 05:50:42 +00003968include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00003969
3970//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003971// XMM Floating point support (requires SSE / SSE2)
3972//===----------------------------------------------------------------------===//
3973
3974include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00003975
3976//===----------------------------------------------------------------------===//
3977// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3978//===----------------------------------------------------------------------===//
3979
3980include "X86InstrMMX.td"