blob: e83f6aab7be755f2998b8bc15d1a6e9eee6c9911 [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
Sean Callanan1c97ceb2009-06-23 23:25:37 +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">;
David Greenef0c3d022009-06-30 19:24:59 +0000183def i256mem : X86MemOperand<"printi256mem">;
Chris Lattner45432512005-12-17 19:47:05 +0000184def f32mem : X86MemOperand<"printf32mem">;
185def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen59a58732007-08-05 18:49:15 +0000186def f80mem : X86MemOperand<"printf80mem">;
Evan Cheng223547a2006-01-31 22:28:30 +0000187def f128mem : X86MemOperand<"printf128mem">;
David Greenef0c3d022009-06-30 19:24:59 +0000188def f256mem : X86MemOperand<"printf256mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +0000189
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000190// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
191// plain GR64, so that it doesn't potentially require a REX prefix.
192def i8mem_NOREX : Operand<i64> {
193 let PrintMethod = "printi8mem";
194 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX, i32imm, i8imm);
195}
196
Evan Cheng25ab6902006-09-08 06:48:29 +0000197def lea32mem : Operand<i32> {
Rafael Espindola094fad32009-04-08 21:14:34 +0000198 let PrintMethod = "printlea32mem";
Evan Cheng25ab6902006-09-08 06:48:29 +0000199 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
200}
201
Nate Begeman16b04f32005-07-15 00:38:55 +0000202def SSECC : Operand<i8> {
203 let PrintMethod = "printSSECC";
204}
Chris Lattner66fa1dc2004-08-11 02:25:00 +0000205
Evan Cheng7ccced62006-02-18 00:15:05 +0000206def piclabel: Operand<i32> {
207 let PrintMethod = "printPICLabel";
208}
209
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000210// A couple of more descriptive operand definitions.
211// 16-bits but only 8 bits are significant.
212def i16i8imm : Operand<i16>;
213// 32-bits but only 8 bits are significant.
214def i32i8imm : Operand<i32>;
215
Chris Lattner7680e732009-06-20 19:34:09 +0000216// Branch targets have OtherVT type and print as pc-relative values.
217def brtarget : Operand<OtherVT> {
218 let PrintMethod = "print_pcrel_imm";
219}
Evan Chengd35b8c12005-12-04 08:19:43 +0000220
Evan Cheng77159e32009-07-21 06:00:18 +0000221def brtarget8 : Operand<OtherVT> {
222 let PrintMethod = "print_pcrel_imm";
223}
224
Evan Chengaed7c722005-12-17 01:24:02 +0000225//===----------------------------------------------------------------------===//
226// X86 Complex Pattern Definitions.
227//
228
Evan Chengec693f72005-12-08 02:01:35 +0000229// Define X86 specific addressing mode.
Rafael Espindola094fad32009-04-08 21:14:34 +0000230def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Evan Cheng25ab6902006-09-08 06:48:29 +0000231def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman3cd90a12009-05-11 18:02:53 +0000232 [add, sub, mul, shl, or, frameindex], []>;
Chris Lattner5c0b16d2009-06-20 20:38:48 +0000233def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
234 [tglobaltlsaddr], []>;
Evan Chengec693f72005-12-08 02:01:35 +0000235
Evan Chengaed7c722005-12-17 01:24:02 +0000236//===----------------------------------------------------------------------===//
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000237// X86 Instruction Predicate Definitions.
Evan Cheng28b514392006-12-05 19:50:18 +0000238def HasMMX : Predicate<"Subtarget->hasMMX()">;
239def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
240def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
241def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
Bill Wendlingbb1ee052007-04-10 22:10:25 +0000242def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begeman63ec90a2008-02-03 07:18:54 +0000243def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
244def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene343dadb2009-06-26 22:46:54 +0000245def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
246def HasAVX : Predicate<"Subtarget->hasAVX()">;
247def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
248def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesenf1fc3a82007-09-23 14:52:20 +0000249def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
250def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Evan Cheng28b514392006-12-05 19:50:18 +0000251def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
252def In64BitMode : Predicate<"Subtarget->is64Bit()">;
253def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
254def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
255def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Chengb7a75a52008-09-26 23:41:32 +0000256def OptForSpeed : Predicate<"!OptForSize">;
Evan Chengccb69762009-01-02 05:35:45 +0000257def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Chengd7f666a2009-05-20 04:53:57 +0000258def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Evan Chengbbc8ddb2005-12-20 22:59:51 +0000259
260//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +0000261// X86 Instruction Format Definitions.
Evan Chengaed7c722005-12-17 01:24:02 +0000262//
263
Evan Chengc64a1a92007-07-31 08:04:03 +0000264include "X86InstrFormats.td"
Chris Lattner1cca5e32003-08-03 21:54:21 +0000265
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000266//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000267// Pattern fragments...
268//
Evan Chengd9558e02006-01-06 00:43:03 +0000269
270// X86 specific condition code. These correspond to CondCode in
Nate Begeman9a225302007-05-06 04:00:55 +0000271// X86InstrInfo.h. They must be kept in synch.
Dan Gohman653456c2009-01-07 00:15:08 +0000272def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
273def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
274def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
275def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
276def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
277def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
278def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
279def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
280def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
281def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Evan Chengd9558e02006-01-06 00:43:03 +0000282def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000283def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Evan Chengd9558e02006-01-06 00:43:03 +0000284def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman653456c2009-01-07 00:15:08 +0000285def X86_COND_O : PatLeaf<(i8 13)>;
286def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
287def X86_COND_S : PatLeaf<(i8 15)>;
Evan Chengd9558e02006-01-06 00:43:03 +0000288
Evan Cheng9b6b6422005-12-13 00:14:11 +0000289def i16immSExt8 : PatLeaf<(i16 imm), [{
290 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000291 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000292 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000293}]>;
294
Evan Cheng9b6b6422005-12-13 00:14:11 +0000295def i32immSExt8 : PatLeaf<(i32 imm), [{
296 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000297 // sign extended field.
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +0000298 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Evan Chengb3558542005-12-13 00:01:09 +0000299}]>;
300
Evan Cheng605c4152005-12-13 01:57:51 +0000301// Helper fragments for loads.
Evan Chengb6564432008-05-13 18:59:59 +0000302// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
303// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman33586292008-10-15 06:50:19 +0000304def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000305 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000306 if (const Value *Src = LD->getSrcValue())
307 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000308 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000309 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000310 ISD::LoadExtType ExtType = LD->getExtensionType();
311 if (ExtType == ISD::NON_EXTLOAD)
312 return true;
313 if (ExtType == ISD::EXTLOAD)
314 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000315 return false;
316}]>;
317
Dan Gohman33586292008-10-15 06:50:19 +0000318def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengca57f782008-09-24 23:27:55 +0000319 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000320 if (const Value *Src = LD->getSrcValue())
321 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000322 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000323 return false;
Evan Chengca57f782008-09-24 23:27:55 +0000324 ISD::LoadExtType ExtType = LD->getExtensionType();
325 if (ExtType == ISD::EXTLOAD)
326 return LD->getAlignment() >= 2 && !LD->isVolatile();
327 return false;
328}]>;
329
Dan Gohman33586292008-10-15 06:50:19 +0000330def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman67ca6be2008-08-20 15:24:22 +0000331 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000332 if (const Value *Src = LD->getSrcValue())
333 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000334 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000335 return false;
Dan Gohman67ca6be2008-08-20 15:24:22 +0000336 ISD::LoadExtType ExtType = LD->getExtensionType();
337 if (ExtType == ISD::NON_EXTLOAD)
338 return true;
339 if (ExtType == ISD::EXTLOAD)
340 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Chengfa7fd332008-05-13 00:54:02 +0000341 return false;
342}]>;
343
Dan Gohman33586292008-10-15 06:50:19 +0000344def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Chengd47e0b62008-09-29 17:26:18 +0000345 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattnerc2406f22009-04-10 00:16:23 +0000346 if (const Value *Src = LD->getSrcValue())
347 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000348 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000349 return false;
Evan Chengd47e0b62008-09-29 17:26:18 +0000350 if (LD->isVolatile())
351 return false;
Evan Chengd47e0b62008-09-29 17:26:18 +0000352 ISD::LoadExtType ExtType = LD->getExtensionType();
353 if (ExtType == ISD::NON_EXTLOAD)
354 return true;
355 if (ExtType == ISD::EXTLOAD)
356 return LD->getAlignment() >= 4;
357 return false;
358}]>;
359
Nate Begeman51a04372009-01-26 01:24:32 +0000360def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattnerc2406f22009-04-10 00:16:23 +0000361 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
362 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
363 return PT->getAddressSpace() == 256;
Nate Begeman51a04372009-01-26 01:24:32 +0000364 return false;
365}]>;
366
Chris Lattner1777d0c2009-05-05 18:52:19 +0000367def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
368 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
369 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
370 return PT->getAddressSpace() == 257;
371 return false;
372}]>;
373
Chris Lattnerc2406f22009-04-10 00:16:23 +0000374def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
375 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
376 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000377 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000378 return false;
379 return true;
380}]>;
381def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
382 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
383 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000384 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000385 return false;
386 return true;
387}]>;
Evan Cheng06a8aa12006-03-17 19:55:52 +0000388
Chris Lattnerc2406f22009-04-10 00:16:23 +0000389def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
390 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
391 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000392 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000393 return false;
394 return true;
395}]>;
396def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
397 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
398 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000399 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000400 return false;
401 return true;
402}]>;
403def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
404 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
405 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wanga7e01d72009-04-27 07:22:10 +0000406 if (PT->getAddressSpace() > 255)
Chris Lattnerc2406f22009-04-10 00:16:23 +0000407 return false;
408 return true;
409}]>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000410
Evan Cheng466685d2006-10-09 20:57:25 +0000411def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
412def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
413def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000414
Evan Cheng466685d2006-10-09 20:57:25 +0000415def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
416def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
417def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
418def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
419def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
420def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
Evan Cheng7a7e8372005-12-14 02:22:27 +0000421
Evan Cheng466685d2006-10-09 20:57:25 +0000422def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
423def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
424def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
425def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
426def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
427def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
Evan Cheng747a90d2006-02-21 02:24:38 +0000428
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000429
430// An 'and' node with a single use.
431def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng07b7ea12008-03-04 00:40:35 +0000432 return N->hasOneUse();
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000433}]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000434// An 'srl' node with a single use.
435def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
436 return N->hasOneUse();
437}]>;
438// An 'trunc' node with a single use.
439def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
440 return N->hasOneUse();
441}]>;
Chris Lattnerce2bcc82008-02-19 17:37:35 +0000442
Dan Gohman74feef22008-10-17 01:23:35 +0000443// 'shld' and 'shrd' instruction patterns. Note that even though these have
444// the srl and shl in their patterns, the C++ code must still check for them,
445// because predicates are tested before children nodes are explored.
446
447def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
448 (or (srl node:$src1, node:$amt1),
449 (shl node:$src2, node:$amt2)), [{
450 assert(N->getOpcode() == ISD::OR);
451 return N->getOperand(0).getOpcode() == ISD::SRL &&
452 N->getOperand(1).getOpcode() == ISD::SHL &&
453 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
454 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
455 N->getOperand(0).getConstantOperandVal(1) ==
456 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
457}]>;
458
459def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
460 (or (shl node:$src1, node:$amt1),
461 (srl node:$src2, node:$amt2)), [{
462 assert(N->getOpcode() == ISD::OR);
463 return N->getOperand(0).getOpcode() == ISD::SHL &&
464 N->getOperand(1).getOpcode() == ISD::SRL &&
465 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
466 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
467 N->getOperand(0).getConstantOperandVal(1) ==
468 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
469}]>;
470
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000471//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000472// Instruction list...
473//
474
Chris Lattnerf18c0742006-10-12 17:42:56 +0000475// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
476// a stack adjustment and the codegen must know that they may modify the stack
477// pointer before prolog-epilog rewriting occurs.
Chris Lattner447ff682008-03-11 03:23:40 +0000478// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
479// sub / add which can clobber EFLAGS.
Evan Cheng8decf6b2007-09-28 01:19:48 +0000480let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman6d4b0522008-10-01 18:28:06 +0000481def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
482 "#ADJCALLSTACKDOWN",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000483 [(X86callseq_start timm:$amt)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000484 Requires<[In32BitMode]>;
485def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
486 "#ADJCALLSTACKUP",
Chris Lattnere563bbc2008-10-11 22:08:30 +0000487 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman6d4b0522008-10-01 18:28:06 +0000488 Requires<[In32BitMode]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000489}
Evan Cheng4a460802006-01-11 00:33:36 +0000490
491// Nop
Chris Lattnerba7e7562008-01-10 07:59:24 +0000492let neverHasSideEffects = 1 in
493 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Evan Cheng4a460802006-01-11 00:33:36 +0000494
Evan Cheng0475ab52008-01-05 00:41:47 +0000495// PIC base
Dan Gohman2662d552008-10-01 04:14:30 +0000496let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerba7e7562008-01-10 07:59:24 +0000497 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman4d47b9b2009-04-27 15:13:28 +0000498 "call\t$label\n\t"
499 "pop{l}\t$reg", []>;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000500
Chris Lattner1cca5e32003-08-03 21:54:21 +0000501//===----------------------------------------------------------------------===//
502// Control Flow Instructions...
503//
504
Chris Lattner1be48112005-05-13 17:56:48 +0000505// Return instructions.
Evan Cheng2b4ea792005-12-26 09:11:45 +0000506let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattner447ff682008-03-11 03:23:40 +0000507 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000508 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattner447ff682008-03-11 03:23:40 +0000509 "ret",
Dan Gohmane4c67cd2008-05-31 02:11:25 +0000510 [(X86retflag 0)]>;
Chris Lattner447ff682008-03-11 03:23:40 +0000511 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
512 "ret\t$amt",
Evan Chenge3413162006-01-09 18:33:28 +0000513 [(X86retflag imm:$amt)]>;
Evan Cheng171049d2005-12-23 22:14:32 +0000514}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000515
516// All branches are RawFrm, Void, Branch, and Terminators
Evan Chengffbacca2007-07-21 00:34:19 +0000517let isBranch = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000518 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
519 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000520
Evan Chengec3bc392006-09-07 19:03:48 +0000521let isBranch = 1, isBarrier = 1 in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000522 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Evan Cheng898101c2005-12-19 23:12:38 +0000523
Owen Anderson20ab2902007-11-12 07:39:39 +0000524// Indirect branches
525let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +0000526 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000527 [(brind GR32:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000528 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Evan Cheng25ab6902006-09-08 06:48:29 +0000529 [(brind (loadi32 addr:$dst))]>;
Nate Begeman37efe672006-04-22 18:53:45 +0000530}
531
532// Conditional branches
Evan Cheng0488db92007-09-25 01:57:46 +0000533let Uses = [EFLAGS] in {
Evan Cheng77159e32009-07-21 06:00:18 +0000534// Short conditional jumps
535def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
536def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
537def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
538def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
539def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
540def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
541def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
542def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
543def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
544def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
545def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
546def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
547def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
548def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
549def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
550def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
551
552def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
553
Dan Gohmanb1576f52007-07-31 20:11:57 +0000554def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000555 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000556def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000557 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000558def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000559 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000560def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000561 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000562def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000563 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000564def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000565 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000566
Dan Gohmanb1576f52007-07-31 20:11:57 +0000567def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000568 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000569def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000570 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000571def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000572 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000573def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000574 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Evan Cheng898101c2005-12-19 23:12:38 +0000575
Dan Gohmanb1576f52007-07-31 20:11:57 +0000576def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000577 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000578def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000579 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000580def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000581 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000582def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000583 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000584def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000585 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohmanb1576f52007-07-31 20:11:57 +0000586def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +0000587 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng0488db92007-09-25 01:57:46 +0000588} // Uses = [EFLAGS]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000589
590//===----------------------------------------------------------------------===//
591// Call Instructions...
592//
Evan Chengffbacca2007-07-21 00:34:19 +0000593let isCall = 1 in
Dan Gohman6d4b0522008-10-01 18:28:06 +0000594 // All calls clobber the non-callee saved registers. ESP is marked as
595 // a use to prevent stack-pointer assignments that appear immediately
596 // before calls from potentially appearing dead. Uses for argument
597 // registers are added manually.
Nate Begemanf63be7d2005-07-06 18:59:04 +0000598 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Bill Wendling3f3a17d2007-04-25 21:31:48 +0000599 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng109a5622008-10-17 21:02:22 +0000600 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
601 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman2662d552008-10-01 04:14:30 +0000602 Uses = [ESP] in {
Chris Lattner7680e732009-06-20 19:34:09 +0000603 def CALLpcrel32 : Ii32<0xE8, RawFrm,
604 (outs), (ins i32imm_pcrel:$dst,variable_ops),
605 "call\t$dst", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000606 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000607 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000608 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanb4106172008-05-29 21:50:34 +0000609 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000610 }
611
Chris Lattner1e9448b2005-05-15 03:10:37 +0000612// Tail call stuff.
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000613
Chris Lattner447ff682008-03-11 03:23:40 +0000614def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000615 "#TAILCALL",
616 []>;
617
Evan Chengffbacca2007-07-21 00:34:19 +0000618let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000619def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000620 "#TC_RETURN $dst $offset",
621 []>;
622
623let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer4fe30732008-03-19 16:39:45 +0000624def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000625 "#TC_RETURN $dst $offset",
626 []>;
627
628let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer30e62c02008-04-30 09:16:33 +0000629
Chris Lattner7680e732009-06-20 19:34:09 +0000630 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Evan Chengf10c17f2006-09-22 21:43:59 +0000631 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000632let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000633 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
634 []>;
Evan Chengffbacca2007-07-21 00:34:19 +0000635let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000636 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +0000637 "jmp\t{*}$dst # TAILCALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000638
Chris Lattner1cca5e32003-08-03 21:54:21 +0000639//===----------------------------------------------------------------------===//
640// Miscellaneous Instructions...
641//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000642let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Chris Lattner30bf2d82004-08-10 20:17:41 +0000643def LEAVE : I<0xC9, RawFrm,
Evan Cheng071a2792007-09-11 19:55:27 +0000644 (outs), (ins), "leave", []>;
645
Chris Lattnerba7e7562008-01-10 07:59:24 +0000646let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
647let mayLoad = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000648def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000649
Chris Lattnerba7e7562008-01-10 07:59:24 +0000650let mayStore = 1 in
Evan Cheng2f245ba2007-09-26 01:29:06 +0000651def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng071a2792007-09-11 19:55:27 +0000652}
Anton Korobeynikov57fc00d2007-04-17 09:20:00 +0000653
Bill Wendling453eb262009-06-15 19:39:04 +0000654let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
655def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000656 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000657def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000658 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000659def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling927788c2009-06-15 20:59:31 +0000660 "push{l}\t$imm", []>;
Bill Wendling453eb262009-06-15 19:39:04 +0000661}
662
Chris Lattnerba7e7562008-01-10 07:59:24 +0000663let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000664def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000665let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengbf4f89d2007-09-26 21:28:00 +0000666def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Cheng2f245ba2007-09-26 01:29:06 +0000667
Evan Cheng069287d2006-05-16 07:21:53 +0000668let isTwoAddress = 1 in // GR32 = bswap GR32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000669 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Cheng64d80e32007-07-19 01:14:50 +0000670 (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000671 "bswap{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +0000672 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000673
Chris Lattner1cca5e32003-08-03 21:54:21 +0000674
Evan Cheng18efe262007-12-14 02:13:44 +0000675// Bit scan instructions.
676let Defs = [EFLAGS] in {
Evan Chengfd9e4732007-12-14 18:49:43 +0000677def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000678 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000679 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000680def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000681 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000682 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
683 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000684def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000685 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000686 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000687def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000688 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000689 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
690 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000691
Evan Chengfd9e4732007-12-14 18:49:43 +0000692def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000693 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000694 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000695def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000696 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000697 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
698 (implicit EFLAGS)]>, TB;
Evan Chengfd9e4732007-12-14 18:49:43 +0000699def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000700 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000701 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000702def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman1a8001e2007-12-14 15:10:00 +0000703 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng152804e2007-12-14 08:30:15 +0000704 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
705 (implicit EFLAGS)]>, TB;
Evan Cheng18efe262007-12-14 02:13:44 +0000706} // Defs = [EFLAGS]
707
Chris Lattnerba7e7562008-01-10 07:59:24 +0000708let neverHasSideEffects = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000709def LEA16r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000710 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000711 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Chenge771ebd2008-03-27 01:41:09 +0000712let isReMaterializable = 1 in
Chris Lattner3a173df2004-10-03 20:35:00 +0000713def LEA32r : I<0x8D, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +0000714 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000715 "lea{l}\t{$src|$dst}, {$dst|$src}",
Evan Cheng25ab6902006-09-08 06:48:29 +0000716 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000717
Evan Cheng071a2792007-09-11 19:55:27 +0000718let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000719def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000720 [(X86rep_movs i8)]>, REP;
Evan Cheng64d80e32007-07-19 01:14:50 +0000721def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000722 [(X86rep_movs i16)]>, REP, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000723def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000724 [(X86rep_movs i32)]>, REP;
725}
Chris Lattner915e5e52004-02-12 17:53:22 +0000726
Evan Cheng071a2792007-09-11 19:55:27 +0000727let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000728def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng071a2792007-09-11 19:55:27 +0000729 [(X86rep_stos i8)]>, REP;
730let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000731def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng071a2792007-09-11 19:55:27 +0000732 [(X86rep_stos i16)]>, REP, OpSize;
733let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000734def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng071a2792007-09-11 19:55:27 +0000735 [(X86rep_stos i32)]>, REP;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000736
Evan Cheng071a2792007-09-11 19:55:27 +0000737let Defs = [RAX, RDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000738def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng071a2792007-09-11 19:55:27 +0000739 TB;
Chris Lattnerb89abef2004-02-14 04:45:37 +0000740
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000741let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattnerda68d302008-01-15 21:58:22 +0000742def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov66fac792008-01-15 07:02:33 +0000743}
744
Chris Lattner1cca5e32003-08-03 21:54:21 +0000745//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000746// Input/Output Instructions...
747//
Evan Cheng071a2792007-09-11 19:55:27 +0000748let Defs = [AL], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000749def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000750 "in{b}\t{%dx, %al|%AL, %DX}", []>;
751let Defs = [AX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000752def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000753 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
754let Defs = [EAX], Uses = [DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000755def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000756 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000757
Evan Cheng071a2792007-09-11 19:55:27 +0000758let Defs = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000759def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000760 "in{b}\t{$port, %al|%AL, $port}", []>;
761let Defs = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000762def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000763 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
764let Defs = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000765def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000766 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000767
Evan Cheng071a2792007-09-11 19:55:27 +0000768let Uses = [DX, AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000769def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000770 "out{b}\t{%al, %dx|%DX, %AL}", []>;
771let Uses = [DX, AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000772def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000773 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
774let Uses = [DX, EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000775def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng071a2792007-09-11 19:55:27 +0000776 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000777
Evan Cheng071a2792007-09-11 19:55:27 +0000778let Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000779def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000780 "out{b}\t{%al, $port|$port, %AL}", []>;
781let Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000782def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000783 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
784let Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000785def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng071a2792007-09-11 19:55:27 +0000786 "out{l}\t{%eax, $port|$port, %EAX}", []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000787
788//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000789// Move Instructions...
790//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000791let neverHasSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000792def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000793 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000794def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000795 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000796def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000797 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000798}
Evan Cheng359e9372008-06-18 08:13:07 +0000799let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000800def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000801 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000802 [(set GR8:$dst, imm:$src)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000803def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000804 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000805 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000806def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000807 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000808 [(set GR32:$dst, imm:$src)]>;
Dan Gohmand45eddd2007-06-26 00:48:07 +0000809}
Evan Cheng64d80e32007-07-19 01:14:50 +0000810def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000811 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000812 [(store (i8 imm:$src), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000813def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000814 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000815 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000816def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000817 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Chengb51a0592005-12-10 00:48:20 +0000818 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000819
Dan Gohman15511cf2008-12-03 18:15:48 +0000820let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000821def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000822 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +0000823 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000824def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000825 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +0000826 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000827def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000828 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattnerc2406f22009-04-10 00:16:23 +0000829 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng2f394262007-08-30 05:49:43 +0000830}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000831
Evan Cheng64d80e32007-07-19 01:14:50 +0000832def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000833 "mov{b}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000834 [(store GR8:$src, addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +0000835def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000836 "mov{w}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000837 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +0000838def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000839 "mov{l}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +0000840 [(store GR32:$src, addr:$dst)]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000841
Dan Gohman4af325d2009-04-27 16:41:36 +0000842// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
843// that they can be used for copying and storing h registers, which can't be
844// encoded when a REX prefix is present.
Dan Gohman6d9305c2009-04-15 00:04:23 +0000845let neverHasSideEffects = 1 in
Dan Gohmandf7dfc72009-04-15 19:48:57 +0000846def MOV8rr_NOREX : I<0x88, MRMDestReg,
847 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman6d9305c2009-04-15 00:04:23 +0000848 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +0000849let mayStore = 1 in
Dan Gohman6d9305c2009-04-15 00:04:23 +0000850def MOV8mr_NOREX : I<0x88, MRMDestMem,
851 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
852 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Cheng8c147402009-04-30 00:58:57 +0000853let mayLoad = 1,
854 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman4af325d2009-04-27 16:41:36 +0000855def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
856 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
857 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +0000858
Chris Lattner1cca5e32003-08-03 21:54:21 +0000859//===----------------------------------------------------------------------===//
860// Fixed-Register Multiplication and Division Instructions...
861//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000862
Chris Lattnerc8f45872003-08-04 04:59:56 +0000863// Extra precision multiplication
Evan Cheng24f2ea32007-09-14 21:48:26 +0000864let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000865def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000866 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
867 // This probably ought to be moved to a def : Pat<> if the
868 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +0000869 [(set AL, (mul AL, GR8:$src)),
870 (implicit EFLAGS)]>; // AL,AH = AL*GR8
871
Chris Lattnera731c9f2008-01-11 07:18:17 +0000872let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +0000873def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
874 "mul{w}\t$src",
875 []>, OpSize; // AX,DX = AX*GR16
876
Chris Lattnera731c9f2008-01-11 07:18:17 +0000877let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingd350e022008-12-12 21:15:41 +0000878def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
879 "mul{l}\t$src",
880 []>; // EAX,EDX = EAX*GR32
881
Evan Cheng24f2ea32007-09-14 21:48:26 +0000882let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000883def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000884 "mul{b}\t$src",
Evan Chengcf74a7c2006-01-15 10:05:20 +0000885 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
886 // This probably ought to be moved to a def : Pat<> if the
887 // syntax can be accepted.
Bill Wendlingd350e022008-12-12 21:15:41 +0000888 [(set AL, (mul AL, (loadi8 addr:$src))),
889 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
890
Chris Lattnerba7e7562008-01-10 07:59:24 +0000891let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000892let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000893def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +0000894 "mul{w}\t$src",
895 []>, OpSize; // AX,DX = AX*[mem16]
896
Evan Cheng24f2ea32007-09-14 21:48:26 +0000897let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000898def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingd350e022008-12-12 21:15:41 +0000899 "mul{l}\t$src",
900 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000901}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000902
Chris Lattnerba7e7562008-01-10 07:59:24 +0000903let neverHasSideEffects = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000904let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng071a2792007-09-11 19:55:27 +0000905def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
906 // AL,AH = AL*GR8
Evan Cheng24f2ea32007-09-14 21:48:26 +0000907let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohmanb1576f52007-07-31 20:11:57 +0000908def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng071a2792007-09-11 19:55:27 +0000909 OpSize; // AX,DX = AX*GR16
Evan Cheng24f2ea32007-09-14 21:48:26 +0000910let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng071a2792007-09-11 19:55:27 +0000911def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
912 // EAX,EDX = EAX*GR32
Chris Lattnerba7e7562008-01-10 07:59:24 +0000913let mayLoad = 1 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +0000914let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000915def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000916 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng24f2ea32007-09-14 21:48:26 +0000917let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000918def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000919 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
920let Defs = [EAX,EDX], Uses = [EAX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000921def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng071a2792007-09-11 19:55:27 +0000922 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerba7e7562008-01-10 07:59:24 +0000923}
Dan Gohmanc99da132008-11-18 21:29:14 +0000924} // neverHasSideEffects
Chris Lattner1e6a7152005-04-06 04:19:22 +0000925
Chris Lattnerc8f45872003-08-04 04:59:56 +0000926// unsigned division/remainder
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000927let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000928def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000929 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000930let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000931def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000932 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000933let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000934def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000935 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000936let mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000937let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000938def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000939 "div{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000940let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000941def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000942 "div{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000943let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000944def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000945 "div{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000946}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000947
Chris Lattnerfc752712004-08-01 09:52:59 +0000948// Signed division/remainder.
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000949let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000950def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000951 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000952let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000953def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000954 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000955let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000956def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000957 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000958let mayLoad = 1, mayLoad = 1 in {
Dale Johannesen2cb48ea2008-10-07 18:54:28 +0000959let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000960def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng071a2792007-09-11 19:55:27 +0000961 "idiv{b}\t$src", []>;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000962let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000963def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng071a2792007-09-11 19:55:27 +0000964 "idiv{w}\t$src", []>, OpSize;
Evan Cheng24f2ea32007-09-14 21:48:26 +0000965let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Cheng64d80e32007-07-19 01:14:50 +0000966def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng071a2792007-09-11 19:55:27 +0000967 "idiv{l}\t$src", []>;
Chris Lattnerba7e7562008-01-10 07:59:24 +0000968}
Chris Lattner1cca5e32003-08-03 21:54:21 +0000969
Chris Lattner1cca5e32003-08-03 21:54:21 +0000970//===----------------------------------------------------------------------===//
Chris Lattnerba7e7562008-01-10 07:59:24 +0000971// Two address Instructions.
Chris Lattner1cca5e32003-08-03 21:54:21 +0000972//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000973let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000974
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000975// Conditional moves
Evan Cheng0488db92007-09-25 01:57:46 +0000976let Uses = [EFLAGS] in {
Evan Cheng7ad42d92007-10-05 23:13:21 +0000977let isCommutable = 1 in {
Evan Cheng069287d2006-05-16 07:21:53 +0000978def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000979 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000980 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000981 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000982 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000983 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000984def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000985 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000986 "cmovb\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000987 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000988 X86_COND_B, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000989 TB;
Evan Cheng069287d2006-05-16 07:21:53 +0000990def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +0000991 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000992 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000993 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +0000994 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +0000995 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +0000996def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +0000997 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +0000998 "cmovae\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +0000999 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001000 X86_COND_AE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001001 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001002def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001003 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001004 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001005 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001006 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001007 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001008def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001009 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001010 "cmove\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001011 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001012 X86_COND_E, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001013 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001014def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001015 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001016 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001017 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001018 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001019 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001020def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001021 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001022 "cmovne\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001023 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001024 X86_COND_NE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001025 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001026def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001027 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001028 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001029 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001030 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001031 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001032def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001033 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001034 "cmovbe\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001035 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001036 X86_COND_BE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001037 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001038def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001039 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001040 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001041 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001042 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001043 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001044def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001045 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001046 "cmova\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001047 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001048 X86_COND_A, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001049 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001050def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001051 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001052 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001053 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001054 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001055 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001056def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001057 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001058 "cmovl\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001059 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001060 X86_COND_L, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001061 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001062def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001063 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001064 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001065 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001066 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001067 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001068def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001069 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001070 "cmovge\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001071 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001072 X86_COND_GE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001073 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001074def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001075 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001076 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001077 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001078 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001079 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001080def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001081 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001082 "cmovle\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001083 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001084 X86_COND_LE, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001085 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001086def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001087 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001088 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001089 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001090 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001091 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001092def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001093 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001094 "cmovg\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001095 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001096 X86_COND_G, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001097 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001098def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001099 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001100 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001101 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001102 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001103 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001104def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001105 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001106 "cmovs\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001107 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001108 X86_COND_S, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001109 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001110def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001111 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001112 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001113 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001114 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001115 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001116def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001117 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001118 "cmovns\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001119 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001120 X86_COND_NS, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001121 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001122def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001123 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001124 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001125 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001126 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001127 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001128def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001129 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001130 "cmovp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001131 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001132 X86_COND_P, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001133 TB;
Evan Cheng069287d2006-05-16 07:21:53 +00001134def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Cheng64d80e32007-07-19 01:14:50 +00001135 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001136 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001137 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001138 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001139 TB, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00001140def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Cheng64d80e32007-07-19 01:14:50 +00001141 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001142 "cmovnp\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001143 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Chenge5f62042007-09-29 00:00:36 +00001144 X86_COND_NP, EFLAGS))]>,
Evan Cheng71fb9ad2006-01-26 00:29:36 +00001145 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001146def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1147 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1148 "cmovo\t{$src2, $dst|$dst, $src2}",
1149 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1150 X86_COND_O, EFLAGS))]>,
1151 TB, OpSize;
1152def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1153 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1154 "cmovo\t{$src2, $dst|$dst, $src2}",
1155 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1156 X86_COND_O, EFLAGS))]>,
Evan Cheng0488db92007-09-25 01:57:46 +00001157 TB;
Dan Gohman305fceb2009-01-07 00:35:10 +00001158def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1159 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1160 "cmovno\t{$src2, $dst|$dst, $src2}",
1161 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1162 X86_COND_NO, EFLAGS))]>,
1163 TB, OpSize;
1164def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1165 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1166 "cmovno\t{$src2, $dst|$dst, $src2}",
1167 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1168 X86_COND_NO, EFLAGS))]>,
1169 TB;
1170} // isCommutable = 1
Evan Cheng7ad42d92007-10-05 23:13:21 +00001171
1172def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1173 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1174 "cmovb\t{$src2, $dst|$dst, $src2}",
1175 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1176 X86_COND_B, EFLAGS))]>,
1177 TB, OpSize;
1178def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1179 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1180 "cmovb\t{$src2, $dst|$dst, $src2}",
1181 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1182 X86_COND_B, EFLAGS))]>,
1183 TB;
1184def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1185 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1186 "cmovae\t{$src2, $dst|$dst, $src2}",
1187 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1188 X86_COND_AE, EFLAGS))]>,
1189 TB, OpSize;
1190def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1191 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1192 "cmovae\t{$src2, $dst|$dst, $src2}",
1193 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1194 X86_COND_AE, EFLAGS))]>,
1195 TB;
1196def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1197 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1198 "cmove\t{$src2, $dst|$dst, $src2}",
1199 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1200 X86_COND_E, EFLAGS))]>,
1201 TB, OpSize;
1202def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1203 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1204 "cmove\t{$src2, $dst|$dst, $src2}",
1205 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1206 X86_COND_E, EFLAGS))]>,
1207 TB;
1208def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1209 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1210 "cmovne\t{$src2, $dst|$dst, $src2}",
1211 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1212 X86_COND_NE, EFLAGS))]>,
1213 TB, OpSize;
1214def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1215 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1216 "cmovne\t{$src2, $dst|$dst, $src2}",
1217 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1218 X86_COND_NE, EFLAGS))]>,
1219 TB;
1220def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1221 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1222 "cmovbe\t{$src2, $dst|$dst, $src2}",
1223 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1224 X86_COND_BE, EFLAGS))]>,
1225 TB, OpSize;
1226def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1227 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1228 "cmovbe\t{$src2, $dst|$dst, $src2}",
1229 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1230 X86_COND_BE, EFLAGS))]>,
1231 TB;
1232def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1233 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1234 "cmova\t{$src2, $dst|$dst, $src2}",
1235 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1236 X86_COND_A, EFLAGS))]>,
1237 TB, OpSize;
1238def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1239 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1240 "cmova\t{$src2, $dst|$dst, $src2}",
1241 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1242 X86_COND_A, EFLAGS))]>,
1243 TB;
1244def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1245 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1246 "cmovl\t{$src2, $dst|$dst, $src2}",
1247 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1248 X86_COND_L, EFLAGS))]>,
1249 TB, OpSize;
1250def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1251 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1252 "cmovl\t{$src2, $dst|$dst, $src2}",
1253 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1254 X86_COND_L, EFLAGS))]>,
1255 TB;
1256def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1257 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1258 "cmovge\t{$src2, $dst|$dst, $src2}",
1259 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1260 X86_COND_GE, EFLAGS))]>,
1261 TB, OpSize;
1262def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1263 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1264 "cmovge\t{$src2, $dst|$dst, $src2}",
1265 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1266 X86_COND_GE, EFLAGS))]>,
1267 TB;
1268def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1269 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1270 "cmovle\t{$src2, $dst|$dst, $src2}",
1271 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1272 X86_COND_LE, EFLAGS))]>,
1273 TB, OpSize;
1274def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1275 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1276 "cmovle\t{$src2, $dst|$dst, $src2}",
1277 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1278 X86_COND_LE, EFLAGS))]>,
1279 TB;
1280def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1281 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1282 "cmovg\t{$src2, $dst|$dst, $src2}",
1283 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1284 X86_COND_G, EFLAGS))]>,
1285 TB, OpSize;
1286def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1287 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1288 "cmovg\t{$src2, $dst|$dst, $src2}",
1289 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1290 X86_COND_G, EFLAGS))]>,
1291 TB;
1292def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1293 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1294 "cmovs\t{$src2, $dst|$dst, $src2}",
1295 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1296 X86_COND_S, EFLAGS))]>,
1297 TB, OpSize;
1298def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1299 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1300 "cmovs\t{$src2, $dst|$dst, $src2}",
1301 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1302 X86_COND_S, EFLAGS))]>,
1303 TB;
1304def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1305 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1306 "cmovns\t{$src2, $dst|$dst, $src2}",
1307 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1308 X86_COND_NS, EFLAGS))]>,
1309 TB, OpSize;
1310def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1311 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1312 "cmovns\t{$src2, $dst|$dst, $src2}",
1313 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1314 X86_COND_NS, EFLAGS))]>,
1315 TB;
1316def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1317 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1318 "cmovp\t{$src2, $dst|$dst, $src2}",
1319 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1320 X86_COND_P, EFLAGS))]>,
1321 TB, OpSize;
1322def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1323 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1324 "cmovp\t{$src2, $dst|$dst, $src2}",
1325 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1326 X86_COND_P, EFLAGS))]>,
1327 TB;
1328def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1329 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1330 "cmovnp\t{$src2, $dst|$dst, $src2}",
1331 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1332 X86_COND_NP, EFLAGS))]>,
1333 TB, OpSize;
Dan Gohman305fceb2009-01-07 00:35:10 +00001334def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1335 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1336 "cmovnp\t{$src2, $dst|$dst, $src2}",
1337 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1338 X86_COND_NP, EFLAGS))]>,
1339 TB;
1340def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1341 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1342 "cmovo\t{$src2, $dst|$dst, $src2}",
1343 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1344 X86_COND_O, EFLAGS))]>,
1345 TB, OpSize;
1346def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1347 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1348 "cmovo\t{$src2, $dst|$dst, $src2}",
1349 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1350 X86_COND_O, EFLAGS))]>,
1351 TB;
1352def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1353 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1354 "cmovno\t{$src2, $dst|$dst, $src2}",
1355 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1356 X86_COND_NO, EFLAGS))]>,
1357 TB, OpSize;
1358def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1359 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1360 "cmovno\t{$src2, $dst|$dst, $src2}",
1361 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1362 X86_COND_NO, EFLAGS))]>,
1363 TB;
Evan Cheng0488db92007-09-25 01:57:46 +00001364} // Uses = [EFLAGS]
1365
1366
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001367// unary instructions
Evan Cheng1693e482006-07-19 00:27:29 +00001368let CodeSize = 2 in {
Evan Cheng24f2ea32007-09-14 21:48:26 +00001369let Defs = [EFLAGS] in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001370def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001371 [(set GR8:$dst, (ineg GR8:$src)),
1372 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001373def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001374 [(set GR16:$dst, (ineg GR16:$src)),
1375 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001376def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001377 [(set GR32:$dst, (ineg GR32:$src)),
1378 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001379let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001380 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001381 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1382 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001383 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001384 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1385 (implicit EFLAGS)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001386 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001387 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1388 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001389}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001390} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001391
Evan Chengaaf414c2009-01-21 02:09:05 +00001392// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1393let AddedComplexity = 15 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001394def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001395 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001396def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001397 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001398def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Evan Cheng069287d2006-05-16 07:21:53 +00001399 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengaaf414c2009-01-21 02:09:05 +00001400}
Chris Lattner57a02302004-08-11 04:31:00 +00001401let isTwoAddress = 0 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001402 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001403 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001404 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001405 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001406 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Evan Cheng605c4152005-12-13 01:57:51 +00001407 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001408}
Evan Cheng1693e482006-07-19 00:27:29 +00001409} // CodeSize
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001410
Evan Chengb51a0592005-12-10 00:48:20 +00001411// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng24f2ea32007-09-14 21:48:26 +00001412let Defs = [EFLAGS] in {
Evan Cheng1693e482006-07-19 00:27:29 +00001413let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001414def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001415 [(set GR8:$dst, (add GR8:$src, 1)),
1416 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001417let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001418def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001419 [(set GR16:$dst, (add GR16:$src, 1)),
1420 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001421 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001422def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001423 [(set GR32:$dst, (add GR32:$src, 1)),
1424 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001425}
Evan Cheng1693e482006-07-19 00:27:29 +00001426let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001427 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001428 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1429 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001430 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001431 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1432 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001433 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001434 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001435 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1436 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001437 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001438}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001439
Evan Cheng1693e482006-07-19 00:27:29 +00001440let CodeSize = 2 in
Dan Gohmanb1576f52007-07-31 20:11:57 +00001441def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001442 [(set GR8:$dst, (add GR8:$src, -1)),
1443 (implicit EFLAGS)]>;
Evan Cheng1693e482006-07-19 00:27:29 +00001444let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohmanb1576f52007-07-31 20:11:57 +00001445def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001446 [(set GR16:$dst, (add GR16:$src, -1)),
1447 (implicit EFLAGS)]>,
Evan Cheng25ab6902006-09-08 06:48:29 +00001448 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001449def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001450 [(set GR32:$dst, (add GR32:$src, -1)),
1451 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001452}
Chris Lattner57a02302004-08-11 04:31:00 +00001453
Evan Cheng1693e482006-07-19 00:27:29 +00001454let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohmanb1576f52007-07-31 20:11:57 +00001455 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001456 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1457 (implicit EFLAGS)]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001458 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001459 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1460 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001461 OpSize, Requires<[In32BitMode]>;
Dan Gohmanb1576f52007-07-31 20:11:57 +00001462 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001463 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1464 (implicit EFLAGS)]>,
Evan Cheng66f71632007-10-19 21:23:22 +00001465 Requires<[In32BitMode]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001466}
Evan Cheng24f2ea32007-09-14 21:48:26 +00001467} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001468
1469// Logical operators...
Evan Cheng24f2ea32007-09-14 21:48:26 +00001470let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00001471let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001472def AND8rr : I<0x20, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001473 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001474 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001475 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1476 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001477def AND16rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001478 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001479 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001480 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1481 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001482def AND32rr : I<0x21, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00001483 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001484 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001485 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1486 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001487}
Chris Lattner57a02302004-08-11 04:31:00 +00001488
Chris Lattner3a173df2004-10-03 20:35:00 +00001489def AND8rm : I<0x22, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001490 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001491 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001492 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001493 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001494def AND16rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001495 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001496 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001497 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001498 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001499def AND32rm : I<0x23, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001500 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001501 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattnerc2406f22009-04-10 00:16:23 +00001502 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman09a2609e2009-03-03 19:53:46 +00001503 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001504
Chris Lattner3a173df2004-10-03 20:35:00 +00001505def AND8ri : Ii8<0x80, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001506 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001507 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001508 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1509 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001510def AND16ri : Ii16<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001511 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001512 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001513 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1514 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001515def AND32ri : Ii32<0x81, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001516 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001517 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001518 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1519 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001520def AND16ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001521 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001522 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001523 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1524 (implicit EFLAGS)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001525 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001526def AND32ri8 : Ii8<0x83, MRM4r,
Evan Cheng64d80e32007-07-19 01:14:50 +00001527 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001528 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001529 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1530 (implicit EFLAGS)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001531
1532let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001533 def AND8mr : I<0x20, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001534 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001535 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001536 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1537 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001538 def AND16mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001539 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001540 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001541 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1542 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001543 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001544 def AND32mr : I<0x21, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001545 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001546 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001547 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1548 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001549 def AND8mi : Ii8<0x80, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001550 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001551 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001552 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1553 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001554 def AND16mi : Ii16<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001555 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001556 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001557 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1558 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001559 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001560 def AND32mi : Ii32<0x81, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001561 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001562 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001563 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1564 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001565 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001566 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001567 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001568 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1569 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001570 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001571 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001572 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001573 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001574 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1575 (implicit EFLAGS)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001576}
1577
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001578
Chris Lattnercc65bee2005-01-02 02:35:46 +00001579let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Cheng64d80e32007-07-19 01:14:50 +00001580def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001581 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001582 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1583 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001584def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001585 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001586 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1587 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001588def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001589 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001590 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1591 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001592}
Evan Cheng64d80e32007-07-19 01:14:50 +00001593def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001594 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001595 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1596 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001597def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001598 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001599 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1600 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001601def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001602 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001603 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1604 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001605
Evan Cheng64d80e32007-07-19 01:14:50 +00001606def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001607 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001608 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1609 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001610def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001611 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001612 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1613 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001614def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001615 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001616 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1617 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001618
Evan Cheng64d80e32007-07-19 01:14:50 +00001619def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001620 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001621 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1622 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001623def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001624 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001625 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1626 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001627let isTwoAddress = 0 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001628 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001629 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001630 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1631 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001632 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001633 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001634 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1635 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001636 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001637 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001638 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1639 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001640 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001641 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001642 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1643 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001644 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001645 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001646 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1647 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001648 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001649 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001650 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001651 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1652 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001653 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001654 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001655 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1656 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001657 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001658 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001659 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001660 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1661 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001662} // isTwoAddress = 0
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001663
1664
Evan Cheng359e9372008-06-18 08:13:07 +00001665let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001666 def XOR8rr : I<0x30, MRMDestReg,
1667 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1668 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001669 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1670 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001671 def XOR16rr : I<0x31, MRMDestReg,
1672 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1673 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001674 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1675 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001676 def XOR32rr : I<0x31, MRMDestReg,
1677 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1678 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001679 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1680 (implicit EFLAGS)]>;
Evan Cheng359e9372008-06-18 08:13:07 +00001681} // isCommutable = 1
Chris Lattnercc65bee2005-01-02 02:35:46 +00001682
Chris Lattner3a173df2004-10-03 20:35:00 +00001683def XOR8rm : I<0x32, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001684 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001685 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001686 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1687 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001688def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001689 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001690 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001691 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1692 (implicit EFLAGS)]>,
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001693 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001694def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng64d80e32007-07-19 01:14:50 +00001695 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001696 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001697 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1698 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001699
Bill Wendling75cf88f2008-05-29 03:46:36 +00001700def XOR8ri : Ii8<0x80, MRM6r,
1701 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1702 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001703 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1704 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001705def XOR16ri : Ii16<0x81, MRM6r,
1706 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1707 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001708 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1709 (implicit EFLAGS)]>, OpSize;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001710def XOR32ri : Ii32<0x81, MRM6r,
1711 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1712 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001713 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1714 (implicit EFLAGS)]>;
Bill Wendling75cf88f2008-05-29 03:46:36 +00001715def XOR16ri8 : Ii8<0x83, MRM6r,
1716 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1717 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001718 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1719 (implicit EFLAGS)]>,
Bill Wendling75cf88f2008-05-29 03:46:36 +00001720 OpSize;
1721def XOR32ri8 : Ii8<0x83, MRM6r,
1722 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1723 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001724 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1725 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001726
Chris Lattner57a02302004-08-11 04:31:00 +00001727let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001728 def XOR8mr : I<0x30, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001729 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001730 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001731 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1732 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001733 def XOR16mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001734 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001735 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001736 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1737 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001738 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001739 def XOR32mr : I<0x31, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00001740 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001741 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001742 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1743 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001744 def XOR8mi : Ii8<0x80, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001745 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001746 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001747 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1748 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001749 def XOR16mi : Ii16<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001750 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001751 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001752 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1753 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001754 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001755 def XOR32mi : Ii32<0x81, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001756 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001757 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001758 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1759 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001760 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001761 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001762 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001763 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1764 (implicit EFLAGS)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +00001765 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001766 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng64d80e32007-07-19 01:14:50 +00001767 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001768 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman09a2609e2009-03-03 19:53:46 +00001769 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1770 (implicit EFLAGS)]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001771} // isTwoAddress = 0
Evan Cheng24f2ea32007-09-14 21:48:26 +00001772} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001773
1774// Shift instructions
Evan Cheng24f2ea32007-09-14 21:48:26 +00001775let Defs = [EFLAGS] in {
Evan Cheng071a2792007-09-11 19:55:27 +00001776let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001777def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001778 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001779 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001780def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001781 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001782 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001783def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001784 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001785 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001786} // Uses = [CL]
Chris Lattnercc65bee2005-01-02 02:35:46 +00001787
Evan Cheng64d80e32007-07-19 01:14:50 +00001788def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001789 "shl{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001790 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001791let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng64d80e32007-07-19 01:14:50 +00001792def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001793 "shl{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001794 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001795def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001796 "shl{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001797 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf9b3f372008-01-11 18:00:50 +00001798// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1799// cheaper.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00001800} // isConvertibleToThreeAddress = 1
Evan Cheng09c54572006-06-29 00:36:51 +00001801
Chris Lattnerf29ed092004-08-11 05:07:25 +00001802let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001803 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001804 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001805 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001806 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001807 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001808 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001809 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001810 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001811 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001812 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1813 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001814 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001815 "shl{b}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001816 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001817 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001818 "shl{w}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001819 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1820 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001821 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001822 "shl{l}\t{$src, $dst|$dst, $src}",
Evan Cheng763b0292005-12-13 02:34:51 +00001823 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001824
1825 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001826 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001827 "shl{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001828 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001829 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001830 "shl{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001831 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1832 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001833 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001834 "shl{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001835 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001836}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001837
Evan Cheng071a2792007-09-11 19:55:27 +00001838let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001839def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001840 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001841 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001842def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001843 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001844 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001845def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001846 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001847 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1848}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001849
Evan Cheng64d80e32007-07-19 01:14:50 +00001850def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001851 "shr{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001852 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001853def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001854 "shr{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001855 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001856def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001857 "shr{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001858 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001859
Evan Cheng09c54572006-06-29 00:36:51 +00001860// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001861def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001862 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001863 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001864def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001865 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001866 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001867def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001868 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001869 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1870
Chris Lattner57a02302004-08-11 04:31:00 +00001871let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001872 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001873 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001874 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001875 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001876 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001877 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001878 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng071a2792007-09-11 19:55:27 +00001879 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001880 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001881 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001882 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1883 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001884 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001885 "shr{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001886 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001887 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001888 "shr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001889 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1890 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001891 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001892 "shr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001893 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001894
1895 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001896 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001897 "shr{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001898 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001899 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001900 "shr{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001901 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001902 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001903 "shr{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001904 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001905}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001906
Evan Cheng071a2792007-09-11 19:55:27 +00001907let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001908def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001909 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001910 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001911def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001912 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001913 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001914def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001915 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001916 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1917}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001918
Evan Cheng64d80e32007-07-19 01:14:50 +00001919def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001920 "sar{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001921 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001922def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001923 "sar{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001924 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001925 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001926def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001927 "sar{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001928 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001929
1930// Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001931def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001932 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001933 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001934def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001935 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001936 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001937def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001938 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001939 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1940
Chris Lattnerf29ed092004-08-11 05:07:25 +00001941let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00001942 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001943 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001944 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001945 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001946 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001947 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001948 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001949 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001950 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001951 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1952 }
Evan Cheng64d80e32007-07-19 01:14:50 +00001953 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001954 "sar{b}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001955 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001956 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001957 "sar{w}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001958 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1959 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001960 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001961 "sar{l}\t{$src, $dst|$dst, $src}",
Evan Cheng85dd8892005-12-13 07:24:22 +00001962 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00001963
1964 // Shift by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00001965 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001966 "sar{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001967 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001968 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001969 "sar{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001970 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1971 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001972 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001973 "sar{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00001974 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001975}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001976
Chris Lattner40ff6332005-01-19 07:50:03 +00001977// Rotate instructions
1978// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng071a2792007-09-11 19:55:27 +00001979let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00001980def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001981 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001982 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001983def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001984 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001985 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001986def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00001987 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00001988 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1989}
Chris Lattner40ff6332005-01-19 07:50:03 +00001990
Evan Cheng64d80e32007-07-19 01:14:50 +00001991def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001992 "rol{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001993 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00001994def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001995 "rol{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001996 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00001997def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00001998 "rol{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00001999 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002000
Evan Cheng09c54572006-06-29 00:36:51 +00002001// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002002def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002003 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002004 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002005def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002006 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002007 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002008def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002009 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002010 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2011
Chris Lattner40ff6332005-01-19 07:50:03 +00002012let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002013 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002014 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002015 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002016 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002017 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002018 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002019 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002020 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002021 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002022 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2023 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002024 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002025 "rol{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002026 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002027 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002028 "rol{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002029 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2030 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002031 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002032 "rol{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002033 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002034
2035 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002036 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002037 "rol{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002038 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002039 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002040 "rol{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002041 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2042 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002043 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002044 "rol{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002045 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002046}
2047
Evan Cheng071a2792007-09-11 19:55:27 +00002048let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002049def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002050 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002051 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002052def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002053 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002054 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002055def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002056 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002057 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2058}
Chris Lattner40ff6332005-01-19 07:50:03 +00002059
Evan Cheng64d80e32007-07-19 01:14:50 +00002060def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002061 "ror{b}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002062 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002063def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002064 "ror{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002065 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002066def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002067 "ror{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng069287d2006-05-16 07:21:53 +00002068 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002069
2070// Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002071def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002072 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002073 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002074def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002075 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002076 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002077def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002078 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002079 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2080
Chris Lattner40ff6332005-01-19 07:50:03 +00002081let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002082 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002083 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002084 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002085 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002086 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002087 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002088 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002089 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002090 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002091 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2092 }
Evan Cheng64d80e32007-07-19 01:14:50 +00002093 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002094 "ror{b}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002095 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002096 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002097 "ror{w}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002098 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2099 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002100 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002101 "ror{l}\t{$src, $dst|$dst, $src}",
Evan Chengeb422a72006-01-11 23:20:05 +00002102 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Cheng09c54572006-06-29 00:36:51 +00002103
2104 // Rotate by 1
Evan Cheng64d80e32007-07-19 01:14:50 +00002105 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002106 "ror{b}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002107 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002108 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002109 "ror{w}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002110 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2111 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002112 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002113 "ror{l}\t$dst",
Evan Cheng09c54572006-06-29 00:36:51 +00002114 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00002115}
2116
2117
2118
2119// Double shift instructions (generalizations of rotate)
Evan Cheng071a2792007-09-11 19:55:27 +00002120let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002121def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002122 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002123 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002124def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002125 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng071a2792007-09-11 19:55:27 +00002126 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002127def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002128 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002129 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002130 TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002131def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002132 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002133 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng071a2792007-09-11 19:55:27 +00002134 TB, OpSize;
2135}
Chris Lattner41e431b2005-01-19 07:11:01 +00002136
2137let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00002138def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002139 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002140 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002141 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002142 (i8 imm:$src3)))]>,
2143 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002144def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002145 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002146 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002147 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002148 (i8 imm:$src3)))]>,
2149 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002150def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002151 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002152 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002153 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002154 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002155 TB, OpSize;
2156def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002157 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002158 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002159 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002160 (i8 imm:$src3)))]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002161 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00002162}
Chris Lattner0e967d42004-08-01 08:13:11 +00002163
Chris Lattner57a02302004-08-11 04:31:00 +00002164let isTwoAddress = 0 in {
Evan Cheng071a2792007-09-11 19:55:27 +00002165 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002166 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002167 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002168 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002169 addr:$dst)]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00002170 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002171 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002172 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002173 addr:$dst)]>, TB;
2174 }
Chris Lattner3a173df2004-10-03 20:35:00 +00002175 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002176 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002177 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002178 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002179 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002180 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00002181 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002182 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002183 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002184 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002185 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattnerf124d5e2005-11-18 01:04:42 +00002186 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00002187
Evan Cheng071a2792007-09-11 19:55:27 +00002188 let Uses = [CL] in {
Evan Cheng64d80e32007-07-19 01:14:50 +00002189 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002190 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002191 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002192 addr:$dst)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002193 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedmanaace4b12009-06-19 04:48:38 +00002194 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng069287d2006-05-16 07:21:53 +00002195 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng071a2792007-09-11 19:55:27 +00002196 addr:$dst)]>, TB, OpSize;
2197 }
Chris Lattner0df53d22005-01-19 07:31:24 +00002198 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002199 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002200 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002201 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002202 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002203 TB, OpSize;
2204 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002205 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002206 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Evan Cheng069287d2006-05-16 07:21:53 +00002207 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
Evan Chenge3413162006-01-09 18:33:28 +00002208 (i8 imm:$src3)), addr:$dst)]>,
Chris Lattner0df53d22005-01-19 07:31:24 +00002209 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00002210}
Evan Cheng24f2ea32007-09-14 21:48:26 +00002211} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002212
2213
Chris Lattnercc65bee2005-01-02 02:35:46 +00002214// Arithmetic.
Evan Cheng24f2ea32007-09-14 21:48:26 +00002215let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002216let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002217// Register-Register Addition
2218def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2219 (ins GR8 :$src1, GR8 :$src2),
2220 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002221 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002222 (implicit EFLAGS)]>;
2223
Chris Lattnercc65bee2005-01-02 02:35:46 +00002224let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002225// Register-Register Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002226def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2227 (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002228 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002229 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2230 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002231def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2232 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002233 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002234 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2235 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002236} // end isConvertibleToThreeAddress
2237} // end isCommutable
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002238
2239// Register-Memory Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002240def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2241 (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002242 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002243 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2244 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002245def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2246 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002247 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002248 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2249 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002250def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2251 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002252 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002253 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2254 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002255
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002256// Register-Integer Addition
2257def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2258 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002259 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2260 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002261
Chris Lattnercc65bee2005-01-02 02:35:46 +00002262let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002263// Register-Integer Addition
Evan Cheng071a2792007-09-11 19:55:27 +00002264def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2265 (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002266 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002267 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2268 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002269def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2270 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002271 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002272 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2273 (implicit EFLAGS)]>;
Evan Cheng071a2792007-09-11 19:55:27 +00002274def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2275 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002276 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002277 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2278 (implicit EFLAGS)]>, OpSize;
Evan Cheng071a2792007-09-11 19:55:27 +00002279def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2280 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002281 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002282 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2283 (implicit EFLAGS)]>;
Evan Cheng09e3c802006-05-19 18:40:54 +00002284}
Chris Lattner57a02302004-08-11 04:31:00 +00002285
2286let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002287 // Memory-Register Addition
Bill Wendlingd350e022008-12-12 21:15:41 +00002288 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002289 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002290 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2291 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002292 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002293 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002294 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2295 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002296 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002297 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002298 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2299 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002300 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002301 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002302 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2303 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002304 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002305 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002306 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2307 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002308 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002309 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002310 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2311 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002312 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002313 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002314 [(store (add (load addr:$dst), i16immSExt8:$src2),
2315 addr:$dst),
2316 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002317 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002318 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002319 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002320 addr:$dst),
2321 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002322}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002323
Evan Cheng3154cb62007-10-05 17:59:57 +00002324let Uses = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002325let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen874ae252009-06-02 03:12:52 +00002326def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002327 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002328 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002329def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2330 (ins GR16:$src1, GR16:$src2),
2331 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002332 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002333def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2334 (ins GR32:$src1, GR32:$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, GR32:$src2))]>;
Chris Lattner10197ff2005-01-03 01:27:59 +00002337}
Dale Johannesenca11dae2009-05-18 17:44:15 +00002338def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2339 (ins GR8:$src1, i8mem:$src2),
2340 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002341 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002342def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2343 (ins GR16:$src1, i16mem:$src2),
2344 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002345 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002346 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002347def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2348 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002349 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002350 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2351def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002352 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002353 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002354def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2355 (ins GR16:$src1, i16imm:$src2),
2356 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002357 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002358def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2359 (ins GR16:$src1, i16i8imm:$src2),
2360 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002361 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2362 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002363def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2364 (ins GR32:$src1, 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 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002367def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2368 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002369 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002370 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002371
2372let isTwoAddress = 0 in {
Dale Johannesen874ae252009-06-02 03:12:52 +00002373 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002374 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002375 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2376 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002377 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002378 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2379 OpSize;
2380 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002381 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002382 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2383 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002384 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002385 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2386 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002387 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002388 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2389 OpSize;
2390 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesenca11dae2009-05-18 17:44:15 +00002391 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002392 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2393 OpSize;
2394 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002395 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002396 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2397 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002398 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002399 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2400}
Evan Cheng3154cb62007-10-05 17:59:57 +00002401} // Uses = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002402
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002403// Register-Register Subtraction
2404def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2405 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002406 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2407 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002408def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2409 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002410 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2411 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002412def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2413 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002414 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2415 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002416
2417// Register-Memory Subtraction
2418def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2419 (ins GR8 :$src1, i8mem :$src2),
2420 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002421 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2422 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002423def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2424 (ins GR16:$src1, i16mem:$src2),
2425 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002426 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2427 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002428def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2429 (ins GR32:$src1, i32mem:$src2),
2430 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002431 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2432 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002433
2434// Register-Integer Subtraction
2435def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2436 (ins GR8:$src1, i8imm:$src2),
2437 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002438 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2439 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002440def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2441 (ins GR16:$src1, i16imm:$src2),
2442 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002443 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2444 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002445def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2446 (ins GR32:$src1, i32imm:$src2),
2447 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002448 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2449 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002450def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2451 (ins GR16:$src1, i16i8imm:$src2),
2452 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002453 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2454 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002455def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2456 (ins GR32:$src1, i32i8imm:$src2),
2457 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002458 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2459 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002460
Chris Lattner57a02302004-08-11 04:31:00 +00002461let isTwoAddress = 0 in {
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002462 // Memory-Register Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002463 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002464 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002465 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2466 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002467 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002468 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002469 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2470 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002471 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002472 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002473 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2474 (implicit EFLAGS)]>;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002475
2476 // Memory-Integer Subtraction
Evan Cheng64d80e32007-07-19 01:14:50 +00002477 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002478 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002479 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2480 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002481 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002482 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002483 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2484 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002485 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002486 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002487 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2488 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002489 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002490 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002491 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002492 addr:$dst),
2493 (implicit EFLAGS)]>, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002494 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002495 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002496 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00002497 addr:$dst),
2498 (implicit EFLAGS)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002499}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002500
Evan Cheng3154cb62007-10-05 17:59:57 +00002501let Uses = [EFLAGS] in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00002502def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2503 (ins GR8:$src1, GR8:$src2),
2504 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002505 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002506def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2507 (ins GR16:$src1, GR16:$src2),
2508 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002509 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002510def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2511 (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002512 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002513 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00002514
Chris Lattner57a02302004-08-11 04:31:00 +00002515let isTwoAddress = 0 in {
Dale Johannesenca11dae2009-05-18 17:44:15 +00002516 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2517 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002518 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002519 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2520 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002521 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002522 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002523 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002524 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002525 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002526 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002527 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002528 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002529 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2530 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002531 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002532 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002533 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2534 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002535 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002536 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002537 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002538 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002539 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002540 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002541 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002542 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00002543}
Dale Johannesenca11dae2009-05-18 17:44:15 +00002544def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2545 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002546 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002547def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2548 (ins GR16:$src1, i16mem:$src2),
2549 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002550 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen94c9cd12009-05-18 21:41:59 +00002551 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002552def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2553 (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002554 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002555 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002556def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2557 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002558 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002559def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2560 (ins GR16:$src1, i16imm:$src2),
2561 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002562 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002563def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2564 (ins GR16:$src1, i16i8imm:$src2),
2565 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002566 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2567 OpSize;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002568def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2569 (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002570 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002571 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00002572def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2573 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002574 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen874ae252009-06-02 03:12:52 +00002575 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng3154cb62007-10-05 17:59:57 +00002576} // Uses = [EFLAGS]
Evan Cheng24f2ea32007-09-14 21:48:26 +00002577} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002578
Evan Cheng24f2ea32007-09-14 21:48:26 +00002579let Defs = [EFLAGS] in {
Chris Lattner10197ff2005-01-03 01:27:59 +00002580let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingd350e022008-12-12 21:15:41 +00002581// Register-Register Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002582def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002583 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002584 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2585 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002586def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002587 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002588 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2589 (implicit EFLAGS)]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00002590}
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002591
Bill Wendlingd350e022008-12-12 21:15:41 +00002592// Register-Memory Signed Integer Multiply
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002593def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2594 (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002595 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002596 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2597 (implicit EFLAGS)]>, TB, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002598def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002599 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002600 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2601 (implicit EFLAGS)]>, TB;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002602} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002603} // end Two Address instructions
2604
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002605// Suprisingly enough, these are not two address instructions!
Evan Cheng24f2ea32007-09-14 21:48:26 +00002606let Defs = [EFLAGS] in {
Bill Wendlingd350e022008-12-12 21:15:41 +00002607// Register-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00002608def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002609 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002610 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002611 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2612 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002613def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002614 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002615 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002616 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2617 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002618def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002619 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002620 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002621 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2622 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002623def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002624 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002625 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002626 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2627 (implicit EFLAGS)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00002628
Bill Wendlingd350e022008-12-12 21:15:41 +00002629// Memory-Integer Signed Integer Multiply
Evan Cheng069287d2006-05-16 07:21:53 +00002630def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Cheng64d80e32007-07-19 01:14:50 +00002631 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002632 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002633 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2634 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002635def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Cheng64d80e32007-07-19 01:14:50 +00002636 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002637 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingd350e022008-12-12 21:15:41 +00002638 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2639 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002640def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002641 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002642 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002643 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00002644 i16immSExt8:$src2)),
2645 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002646def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Cheng64d80e32007-07-19 01:14:50 +00002647 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002648 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingab55ebd2008-12-12 00:56:36 +00002649 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingd350e022008-12-12 21:15:41 +00002650 i32immSExt8:$src2)),
2651 (implicit EFLAGS)]>;
Evan Cheng24f2ea32007-09-14 21:48:26 +00002652} // Defs = [EFLAGS]
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002653
2654//===----------------------------------------------------------------------===//
2655// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00002656//
Evan Cheng0488db92007-09-25 01:57:46 +00002657let Defs = [EFLAGS] in {
Chris Lattnercc65bee2005-01-02 02:35:46 +00002658let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Cheng64d80e32007-07-19 01:14:50 +00002659def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002660 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002661 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002662 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002663def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002664 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002665 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002666 (implicit EFLAGS)]>,
2667 OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002668def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002669 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002670 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002671 (implicit EFLAGS)]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00002672}
Evan Cheng734503b2006-09-11 02:19:56 +00002673
Evan Cheng64d80e32007-07-19 01:14:50 +00002674def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002675 "test{b}\t{$src2, $src1|$src1, $src2}",
2676 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2677 (implicit EFLAGS)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00002678def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002679 "test{w}\t{$src2, $src1|$src1, $src2}",
2680 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2681 (implicit EFLAGS)]>, OpSize;
Evan Cheng64d80e32007-07-19 01:14:50 +00002682def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Chenge5f62042007-09-29 00:00:36 +00002683 "test{l}\t{$src2, $src1|$src1, $src2}",
2684 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2685 (implicit EFLAGS)]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002686
Evan Cheng069287d2006-05-16 07:21:53 +00002687def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002688 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002689 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002690 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002691 (implicit EFLAGS)]>;
Evan Cheng069287d2006-05-16 07:21:53 +00002692def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002693 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002694 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002695 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002696 (implicit EFLAGS)]>, OpSize;
Evan Cheng069287d2006-05-16 07:21:53 +00002697def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002698 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002699 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattnerce2bcc82008-02-19 17:37:35 +00002700 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Chenge5f62042007-09-29 00:00:36 +00002701 (implicit EFLAGS)]>;
Evan Cheng734503b2006-09-11 02:19:56 +00002702
Evan Chenge5f62042007-09-29 00:00:36 +00002703def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Cheng64d80e32007-07-19 01:14:50 +00002704 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002705 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002706 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2707 (implicit EFLAGS)]>;
2708def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Cheng64d80e32007-07-19 01:14:50 +00002709 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002710 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002711 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2712 (implicit EFLAGS)]>, OpSize;
2713def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Cheng64d80e32007-07-19 01:14:50 +00002714 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002715 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002716 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng0488db92007-09-25 01:57:46 +00002717 (implicit EFLAGS)]>;
2718} // Defs = [EFLAGS]
2719
2720
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002721// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerba7e7562008-01-10 07:59:24 +00002722let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002723def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerba7e7562008-01-10 07:59:24 +00002724let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng071a2792007-09-11 19:55:27 +00002725def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00002726
Evan Cheng0488db92007-09-25 01:57:46 +00002727let Uses = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002728def SETEr : I<0x94, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002729 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002730 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002731 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002732 TB; // GR8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00002733def SETEm : I<0x94, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002734 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002735 "sete\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002736 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002737 TB; // [mem8] = ==
Bill Wendling9f248742008-12-02 00:07:05 +00002738
Chris Lattner3a173df2004-10-03 20:35:00 +00002739def SETNEr : I<0x95, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002740 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002741 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002742 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002743 TB; // GR8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00002744def SETNEm : I<0x95, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002745 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002746 "setne\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002747 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002748 TB; // [mem8] = !=
Bill Wendling9f248742008-12-02 00:07:05 +00002749
Evan Chengd5781fc2005-12-21 20:21:51 +00002750def SETLr : I<0x9C, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002751 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002752 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002753 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002754 TB; // GR8 = < signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002755def SETLm : I<0x9C, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002756 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002757 "setl\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002758 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002759 TB; // [mem8] = < signed
Bill Wendling9f248742008-12-02 00:07:05 +00002760
Evan Chengd5781fc2005-12-21 20:21:51 +00002761def SETGEr : I<0x9D, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002762 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002763 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002764 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002765 TB; // GR8 = >= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002766def SETGEm : I<0x9D, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002767 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002768 "setge\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002769 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002770 TB; // [mem8] = >= signed
Bill Wendling9f248742008-12-02 00:07:05 +00002771
Evan Chengd5781fc2005-12-21 20:21:51 +00002772def SETLEr : I<0x9E, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002773 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002774 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002775 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002776 TB; // GR8 = <= signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002777def SETLEm : I<0x9E, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002778 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002779 "setle\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002780 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002781 TB; // [mem8] = <= signed
Bill Wendling9f248742008-12-02 00:07:05 +00002782
Evan Chengd5781fc2005-12-21 20:21:51 +00002783def SETGr : I<0x9F, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002784 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002785 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002786 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002787 TB; // GR8 = > signed
Evan Chengd5781fc2005-12-21 20:21:51 +00002788def SETGm : I<0x9F, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002789 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002790 "setg\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002791 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002792 TB; // [mem8] = > signed
2793
2794def SETBr : I<0x92, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002795 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002796 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002797 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002798 TB; // GR8 = < unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002799def SETBm : I<0x92, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002800 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002801 "setb\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002802 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002803 TB; // [mem8] = < unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002804
Evan Chengd5781fc2005-12-21 20:21:51 +00002805def SETAEr : I<0x93, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002806 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002807 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002808 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002809 TB; // GR8 = >= unsign
Evan Chengd5781fc2005-12-21 20:21:51 +00002810def SETAEm : I<0x93, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002811 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002812 "setae\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002813 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002814 TB; // [mem8] = >= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002815
Chris Lattner3a173df2004-10-03 20:35:00 +00002816def SETBEr : I<0x96, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002817 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002818 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002819 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002820 TB; // GR8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00002821def SETBEm : I<0x96, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002822 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002823 "setbe\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002824 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002825 TB; // [mem8] = <= unsign
Bill Wendling9f248742008-12-02 00:07:05 +00002826
Chris Lattner3a173df2004-10-03 20:35:00 +00002827def SETAr : I<0x97, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002828 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002829 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002830 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002831 TB; // GR8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00002832def SETAm : I<0x97, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002833 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002834 "seta\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002835 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Evan Chengd5781fc2005-12-21 20:21:51 +00002836 TB; // [mem8] = > signed
Evan Chengd9558e02006-01-06 00:43:03 +00002837
Chris Lattner3a173df2004-10-03 20:35:00 +00002838def SETSr : I<0x98, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002839 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002840 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002841 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002842 TB; // GR8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002843def SETSm : I<0x98, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002844 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002845 "sets\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002846 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002847 TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002848def SETNSr : I<0x99, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002849 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002850 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002851 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002852 TB; // GR8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00002853def SETNSm : I<0x99, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002854 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002855 "setns\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002856 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002857 TB; // [mem8] = !<sign bit>
Bill Wendling9f248742008-12-02 00:07:05 +00002858
Chris Lattner3a173df2004-10-03 20:35:00 +00002859def SETPr : I<0x9A, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002860 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002861 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002862 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002863 TB; // GR8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00002864def SETPm : I<0x9A, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002865 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002866 "setp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002867 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002868 TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002869def SETNPr : I<0x9B, MRM0r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002870 (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002871 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002872 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Evan Cheng069287d2006-05-16 07:21:53 +00002873 TB; // GR8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00002874def SETNPm : I<0x9B, MRM0m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002875 (outs), (ins i8mem:$dst),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002876 "setnp\t$dst",
Evan Chenge5f62042007-09-29 00:00:36 +00002877 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Evan Chengd9558e02006-01-06 00:43:03 +00002878 TB; // [mem8] = not parity
Bill Wendling9f248742008-12-02 00:07:05 +00002879
2880def SETOr : I<0x90, MRM0r,
2881 (outs GR8 :$dst), (ins),
2882 "seto\t$dst",
2883 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2884 TB; // GR8 = overflow
2885def SETOm : I<0x90, MRM0m,
2886 (outs), (ins i8mem:$dst),
2887 "seto\t$dst",
2888 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2889 TB; // [mem8] = overflow
2890def SETNOr : I<0x91, MRM0r,
2891 (outs GR8 :$dst), (ins),
2892 "setno\t$dst",
2893 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2894 TB; // GR8 = not overflow
2895def SETNOm : I<0x91, MRM0m,
2896 (outs), (ins i8mem:$dst),
2897 "setno\t$dst",
2898 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2899 TB; // [mem8] = not overflow
Evan Cheng0488db92007-09-25 01:57:46 +00002900} // Uses = [EFLAGS]
2901
Chris Lattner1cca5e32003-08-03 21:54:21 +00002902
2903// Integer comparisons
Evan Cheng24f2ea32007-09-14 21:48:26 +00002904let Defs = [EFLAGS] in {
Chris Lattner3a173df2004-10-03 20:35:00 +00002905def CMP8rr : I<0x38, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002906 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002907 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002908 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002909def CMP16rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002910 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002911 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002912 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002913def CMP32rr : I<0x39, MRMDestReg,
Evan Cheng64d80e32007-07-19 01:14:50 +00002914 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002915 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002916 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002917def CMP8mr : I<0x38, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002918 (outs), (ins i8mem :$src1, GR8 :$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 (loadi8 addr:$src1), GR8:$src2),
2921 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002922def CMP16mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002923 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002924 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002925 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2926 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002927def CMP32mr : I<0x39, MRMDestMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002928 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002929 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002930 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2931 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002932def CMP8rm : I<0x3A, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002933 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002934 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002935 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2936 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002937def CMP16rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002938 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002939 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002940 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2941 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002942def CMP32rm : I<0x3B, MRMSrcMem,
Evan Cheng64d80e32007-07-19 01:14:50 +00002943 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002944 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002945 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2946 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002947def CMP8ri : Ii8<0x80, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002948 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002949 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002950 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002951def CMP16ri : Ii16<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002952 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002953 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002954 [(X86cmp GR16:$src1, imm:$src2),
2955 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002956def CMP32ri : Ii32<0x81, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002957 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002958 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002959 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002960def CMP8mi : Ii8 <0x80, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002961 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002962 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002963 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2964 (implicit EFLAGS)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002965def CMP16mi : Ii16<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002966 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002967 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002968 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2969 (implicit EFLAGS)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00002970def CMP32mi : Ii32<0x81, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002971 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002972 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002973 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2974 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002975def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002976 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002977 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002978 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2979 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002980def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002981 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002982 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002983 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2984 (implicit EFLAGS)]>, OpSize;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002985def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Cheng64d80e32007-07-19 01:14:50 +00002986 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002987 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002988 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2989 (implicit EFLAGS)]>;
Chris Lattner29b4dd02006-03-23 16:13:50 +00002990def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Cheng64d80e32007-07-19 01:14:50 +00002991 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohmanb1576f52007-07-31 20:11:57 +00002992 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Chenge5f62042007-09-29 00:00:36 +00002993 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng0488db92007-09-25 01:57:46 +00002994 (implicit EFLAGS)]>;
2995} // Defs = [EFLAGS]
2996
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002997// Bit tests.
Dan Gohmanc7a37d42008-12-23 22:45:23 +00002998// TODO: BTC, BTR, and BTS
2999let Defs = [EFLAGS] in {
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003000def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003001 "bt{w}\t{$src2, $src1|$src1, $src2}",
3002 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00003003 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohman0c89b7e2009-01-13 20:32:45 +00003004def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003005 "bt{l}\t{$src2, $src1|$src1, $src2}",
3006 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattnerf1e9fd52008-12-25 01:32:49 +00003007 (implicit EFLAGS)]>, TB;
Dan Gohmanf31408d2009-01-13 23:23:30 +00003008
3009// Unlike with the register+register form, the memory+register form of the
3010// bt instruction does not ignore the high bits of the index. From ISel's
3011// perspective, this is pretty bizarre. Disable these instructions for now.
3012//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3013// "bt{w}\t{$src2, $src1|$src1, $src2}",
3014// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3015// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3016//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3017// "bt{l}\t{$src2, $src1|$src1, $src2}",
3018// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3019// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman4afe15b2009-01-13 20:33:23 +00003020
3021def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3022 "bt{w}\t{$src2, $src1|$src1, $src2}",
3023 [(X86bt GR16:$src1, i16immSExt8:$src2),
3024 (implicit EFLAGS)]>, OpSize, TB;
3025def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3026 "bt{l}\t{$src2, $src1|$src1, $src2}",
3027 [(X86bt GR32:$src1, i32immSExt8:$src2),
3028 (implicit EFLAGS)]>, TB;
3029// Note that these instructions don't need FastBTMem because that
3030// only applies when the other operand is in a register. When it's
3031// an immediate, bt is still fast.
3032def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3033 "bt{w}\t{$src2, $src1|$src1, $src2}",
3034 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3035 (implicit EFLAGS)]>, OpSize, TB;
3036def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3037 "bt{l}\t{$src2, $src1|$src1, $src2}",
3038 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3039 (implicit EFLAGS)]>, TB;
Dan Gohmanc7a37d42008-12-23 22:45:23 +00003040} // Defs = [EFLAGS]
3041
Chris Lattner1cca5e32003-08-03 21:54:21 +00003042// Sign/Zero extenders
Dan Gohman11ba3b12008-07-30 18:09:17 +00003043// Use movsbl intead of movsbw; we don't care about the high 16 bits
3044// of the register here. This has a smaller encoding and avoids a
3045// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00003046def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003047 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3048 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003049def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003050 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3051 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003052def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003053 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003054 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003055def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003056 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003057 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003058def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003059 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003060 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003061def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003062 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003063 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00003064
Dan Gohman11ba3b12008-07-30 18:09:17 +00003065// Use movzbl intead of movzbw; we don't care about the high 16 bits
3066// of the register here. This has a smaller encoding and avoids a
3067// partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00003068def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003069 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3070 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003071def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003072 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3073 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003074def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003075 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003076 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003077def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003078 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003079 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003080def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003081 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003082 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Cheng64d80e32007-07-19 01:14:50 +00003083def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003084 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Evan Cheng069287d2006-05-16 07:21:53 +00003085 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
Evan Cheng7a7e8372005-12-14 02:22:27 +00003086
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003087// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3088// except that they use GR32_NOREX for the output operand register class
3089// instead of GR32. This allows them to operate on h registers on x86-64.
3090def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3091 (outs GR32_NOREX:$dst), (ins GR8:$src),
3092 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3093 []>, TB;
Dan Gohman78e04d42009-04-30 03:11:48 +00003094let mayLoad = 1 in
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003095def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3096 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3097 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3098 []>, TB;
3099
Chris Lattnerba7e7562008-01-10 07:59:24 +00003100let neverHasSideEffects = 1 in {
3101 let Defs = [AX], Uses = [AL] in
3102 def CBW : I<0x98, RawFrm, (outs), (ins),
3103 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3104 let Defs = [EAX], Uses = [AX] in
3105 def CWDE : I<0x98, RawFrm, (outs), (ins),
3106 "{cwtl|cwde}", []>; // EAX = signext(AX)
Evan Chengf91c1012006-05-31 22:05:11 +00003107
Chris Lattnerba7e7562008-01-10 07:59:24 +00003108 let Defs = [AX,DX], Uses = [AX] in
3109 def CWD : I<0x99, RawFrm, (outs), (ins),
3110 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3111 let Defs = [EAX,EDX], Uses = [EAX] in
3112 def CDQ : I<0x99, RawFrm, (outs), (ins),
3113 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3114}
Evan Cheng747a90d2006-02-21 02:24:38 +00003115
Evan Cheng747a90d2006-02-21 02:24:38 +00003116//===----------------------------------------------------------------------===//
3117// Alias Instructions
3118//===----------------------------------------------------------------------===//
3119
3120// Alias instructions that map movr0 to xor.
3121// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingbd0879d2008-05-29 01:02:09 +00003122let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003123def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003124 "xor{b}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00003125 [(set GR8:$dst, 0)]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00003126// Use xorl instead of xorw since we don't care about the high 16 bits,
3127// it's smaller, and it avoids a partial-register update.
Evan Cheng64d80e32007-07-19 01:14:50 +00003128def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman11ba3b12008-07-30 18:09:17 +00003129 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3130 [(set GR16:$dst, 0)]>;
Evan Cheng64d80e32007-07-19 01:14:50 +00003131def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003132 "xor{l}\t$dst, $dst",
Evan Cheng069287d2006-05-16 07:21:53 +00003133 [(set GR32:$dst, 0)]>;
Dan Gohman1ab79892007-09-07 21:32:51 +00003134}
Evan Cheng747a90d2006-02-21 02:24:38 +00003135
Evan Cheng510e4782006-01-09 23:10:28 +00003136//===----------------------------------------------------------------------===//
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003137// Thread Local Storage Instructions
3138//
3139
Rafael Espindola15f1b662009-04-24 12:59:40 +00003140// All calls clobber the non-callee saved registers. ESP is marked as
3141// a use to prevent stack-pointer assignments that appear immediately
3142// before calls from potentially appearing dead.
3143let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3144 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3145 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3146 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003147 Uses = [ESP] in
3148def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3149 "leal\t$sym, %eax; "
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003150 "call\t___tls_get_addr@PLT",
Chris Lattner5c0b16d2009-06-20 20:38:48 +00003151 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindola2ee3db32009-04-17 14:35:58 +00003152 Requires<[In32BitMode]>;
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003153
Nate Begeman51a04372009-01-26 01:24:32 +00003154let AddedComplexity = 5 in
3155def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3156 "movl\t%gs:$src, $dst",
3157 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3158
Chris Lattner1777d0c2009-05-05 18:52:19 +00003159let AddedComplexity = 5 in
3160def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3161 "movl\t%fs:$src, $dst",
3162 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3163
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +00003164//===----------------------------------------------------------------------===//
Evan Cheng3c992d22006-03-07 02:02:57 +00003165// DWARF Pseudo Instructions
3166//
3167
Evan Cheng64d80e32007-07-19 01:14:50 +00003168def DWARF_LOC : I<0, Pseudo, (outs),
3169 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Chris Lattner226b6082009-07-10 22:34:11 +00003170 ".loc\t$file $line $col",
Evan Cheng3c992d22006-03-07 02:02:57 +00003171 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3172 (i32 imm:$file))]>;
3173
Evan Cheng3c992d22006-03-07 02:02:57 +00003174//===----------------------------------------------------------------------===//
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003175// EH Pseudo Instructions
3176//
3177let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Chengffbacca2007-07-21 00:34:19 +00003178 hasCtrlDep = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +00003179def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohmanb1576f52007-07-31 20:11:57 +00003180 "ret\t#eh_return, addr: $addr",
Anton Korobeynikov2365f512007-07-14 14:06:15 +00003181 [(X86ehret GR32:$addr)]>;
3182
3183}
3184
3185//===----------------------------------------------------------------------===//
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003186// Atomic support
3187//
Andrew Lenharthea7da502008-03-01 13:37:02 +00003188
Evan Chengbb6939d2008-04-19 01:20:30 +00003189// Atomic swap. These are just normal xchg instructions. But since a memory
3190// operand is referenced, the atomicity is ensured.
Dan Gohman165660e2008-08-06 15:52:50 +00003191let Constraints = "$val = $dst" in {
Evan Chengbb6939d2008-04-19 01:20:30 +00003192def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3193 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3194 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3195def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3196 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3197 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3198 OpSize;
3199def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3200 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3201 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3202}
3203
Evan Cheng7e032802008-04-18 20:55:36 +00003204// Atomic compare and swap.
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003205let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003206def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003207 "lock\n\t"
3208 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003209 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003210}
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003211let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovf88a6fa2008-07-22 16:22:48 +00003212def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003213 "lock\n\t"
3214 "cmpxchg8b\t$ptr",
Andrew Lenharthd19189e2008-03-05 01:15:49 +00003215 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3216}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003217
3218let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003219def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003220 "lock\n\t"
3221 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003222 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003223}
Andrew Lenharth26ed8692008-03-01 21:52:34 +00003224let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Cheng7e032802008-04-18 20:55:36 +00003225def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003226 "lock\n\t"
3227 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng32967d22008-03-04 03:20:06 +00003228 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003229}
3230
Evan Cheng7e032802008-04-18 20:55:36 +00003231// Atomic exchange and add
3232let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3233def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003234 "lock\n\t"
3235 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003236 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003237 TB, LOCK;
3238def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003239 "lock\n\t"
3240 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003241 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003242 TB, OpSize, LOCK;
3243def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman4d47b9b2009-04-27 15:13:28 +00003244 "lock\n\t"
3245 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang28873102008-06-25 08:15:39 +00003246 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Cheng7e032802008-04-18 20:55:36 +00003247 TB, LOCK;
Andrew Lenharthea7da502008-03-01 13:37:02 +00003248}
3249
Mon P Wang28873102008-06-25 08:15:39 +00003250// Atomic exchange, and, or, xor
Mon P Wang63307c32008-05-05 19:05:59 +00003251let Constraints = "$val = $dst", Defs = [EFLAGS],
3252 usesCustomDAGSchedInserter = 1 in {
Dan Gohman9499b712008-05-12 20:22:45 +00003253def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003254 "#ATOMAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003255 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003256def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003257 "#ATOMOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003258 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003259def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003260 "#ATOMXOR32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003261 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharth507a58a2008-06-14 05:48:15 +00003262def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003263 "#ATOMNAND32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003264 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003265def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003266 "#ATOMMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003267 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003268def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003269 "#ATOMMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003270 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003271def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003272 "#ATOMUMIN32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003273 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman9499b712008-05-12 20:22:45 +00003274def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003275 "#ATOMUMAX32 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003276 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003277
3278def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003279 "#ATOMAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003280 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003281def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003282 "#ATOMOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003283 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003284def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003285 "#ATOMXOR16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003286 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003287def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003288 "#ATOMNAND16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003289 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003290def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003291 "#ATOMMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003292 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003293def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003294 "#ATOMMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003295 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003296def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003297 "#ATOMUMIN16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003298 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003299def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003300 "#ATOMUMAX16 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003301 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003302
3303def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003304 "#ATOMAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003305 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003306def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003307 "#ATOMOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003308 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003309def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003310 "#ATOMXOR8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003311 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesen140be2d2008-08-19 18:47:28 +00003312def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003313 "#ATOMNAND8 PSEUDO!",
Dale Johannesene00a8a22008-08-28 02:44:49 +00003314 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang63307c32008-05-05 19:05:59 +00003315}
3316
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003317let Constraints = "$val1 = $dst1, $val2 = $dst2",
3318 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3319 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen1b54c7f2008-10-03 19:41:08 +00003320 mayLoad = 1, mayStore = 1,
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003321 usesCustomDAGSchedInserter = 1 in {
3322def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3323 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003324 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003325def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3326 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003327 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003328def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3329 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003330 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003331def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3332 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003333 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003334def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3335 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003336 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003337def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3338 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003339 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen880ae362008-10-03 22:25:52 +00003340def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3341 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewycky6ecf5ce2008-12-07 03:49:52 +00003342 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesen48c1bc22008-10-02 18:53:47 +00003343}
3344
Andrew Lenharthab0b9492008-02-21 06:45:13 +00003345//===----------------------------------------------------------------------===//
Evan Cheng510e4782006-01-09 23:10:28 +00003346// Non-Instruction Patterns
3347//===----------------------------------------------------------------------===//
3348
Bill Wendling056292f2008-09-16 21:48:12 +00003349// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Evan Cheng71fb8342006-02-25 10:02:21 +00003350def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
Nate Begeman37efe672006-04-22 18:53:45 +00003351def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begeman6795ebb2008-04-12 00:47:57 +00003352def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00003353def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3354def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3355
Evan Cheng069287d2006-05-16 07:21:53 +00003356def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3357 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3358def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3359 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3360def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3361 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3362def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3363 (ADD32ri GR32:$src1, texternalsym:$src2)>;
Evan Cheng71fb8342006-02-25 10:02:21 +00003364
Evan Chengfc8feb12006-05-19 07:30:36 +00003365def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00003366 (MOV32mi addr:$dst, tglobaladdr:$src)>;
Evan Chengfc8feb12006-05-19 07:30:36 +00003367def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
Evan Cheng71fb8342006-02-25 10:02:21 +00003368 (MOV32mi addr:$dst, texternalsym:$src)>;
3369
Evan Cheng510e4782006-01-09 23:10:28 +00003370// Calls
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003371// tailcall stuff
Evan Cheng069287d2006-05-16 07:21:53 +00003372def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003373 (TAILCALL)>;
Evan Chengfea89c12006-04-27 08:40:39 +00003374
Evan Cheng25ab6902006-09-08 06:48:29 +00003375def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003376 (TAILCALL)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00003377def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighoferc85e1712007-10-11 19:40:01 +00003378 (TAILCALL)>;
3379
3380def : Pat<(X86tcret GR32:$dst, imm:$off),
3381 (TCRETURNri GR32:$dst, imm:$off)>;
3382
3383def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3384 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3385
3386def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3387 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Evan Chengfea89c12006-04-27 08:40:39 +00003388
Evan Cheng25ab6902006-09-08 06:48:29 +00003389def : Pat<(X86call (i32 tglobaladdr:$dst)),
Evan Cheng510e4782006-01-09 23:10:28 +00003390 (CALLpcrel32 tglobaladdr:$dst)>;
Evan Cheng25ab6902006-09-08 06:48:29 +00003391def : Pat<(X86call (i32 texternalsym:$dst)),
Evan Cheng8700e142006-01-11 06:09:51 +00003392 (CALLpcrel32 texternalsym:$dst)>;
Evan Chengd7f666a2009-05-20 04:53:57 +00003393def : Pat<(X86call (i32 imm:$dst)),
3394 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Evan Cheng510e4782006-01-09 23:10:28 +00003395
3396// X86 specific add which produces a flag.
Evan Cheng069287d2006-05-16 07:21:53 +00003397def : Pat<(addc GR32:$src1, GR32:$src2),
3398 (ADD32rr GR32:$src1, GR32:$src2)>;
3399def : Pat<(addc GR32:$src1, (load addr:$src2)),
3400 (ADD32rm GR32:$src1, addr:$src2)>;
3401def : Pat<(addc GR32:$src1, imm:$src2),
3402 (ADD32ri GR32:$src1, imm:$src2)>;
3403def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3404 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003405
Evan Cheng069287d2006-05-16 07:21:53 +00003406def : Pat<(subc GR32:$src1, GR32:$src2),
3407 (SUB32rr GR32:$src1, GR32:$src2)>;
3408def : Pat<(subc GR32:$src1, (load addr:$src2)),
3409 (SUB32rm GR32:$src1, addr:$src2)>;
3410def : Pat<(subc GR32:$src1, imm:$src2),
3411 (SUB32ri GR32:$src1, imm:$src2)>;
3412def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3413 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003414
Chris Lattnerffc0b262006-09-07 20:33:45 +00003415// Comparisons.
3416
3417// TEST R,R is smaller than CMP R,0
Evan Chenge5f62042007-09-29 00:00:36 +00003418def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003419 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00003420def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003421 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Chenge5f62042007-09-29 00:00:36 +00003422def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Chris Lattnerffc0b262006-09-07 20:33:45 +00003423 (TEST32rr GR32:$src1, GR32:$src1)>;
3424
Dan Gohmanfbb74862009-01-07 01:00:24 +00003425// Conditional moves with folded loads with operands swapped and conditions
3426// inverted.
3427def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3428 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3429def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3430 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3431def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3432 (CMOVB16rm GR16:$src2, addr:$src1)>;
3433def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3434 (CMOVB32rm GR32:$src2, addr:$src1)>;
3435def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3436 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3437def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3438 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3439def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3440 (CMOVE16rm GR16:$src2, addr:$src1)>;
3441def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3442 (CMOVE32rm GR32:$src2, addr:$src1)>;
3443def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3444 (CMOVA16rm GR16:$src2, addr:$src1)>;
3445def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3446 (CMOVA32rm GR32:$src2, addr:$src1)>;
3447def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3448 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3449def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3450 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3451def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3452 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3453def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3454 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3455def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3456 (CMOVL16rm GR16:$src2, addr:$src1)>;
3457def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3458 (CMOVL32rm GR32:$src2, addr:$src1)>;
3459def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3460 (CMOVG16rm GR16:$src2, addr:$src1)>;
3461def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3462 (CMOVG32rm GR32:$src2, addr:$src1)>;
3463def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3464 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3465def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3466 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3467def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3468 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3469def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3470 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3471def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3472 (CMOVP16rm GR16:$src2, addr:$src1)>;
3473def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3474 (CMOVP32rm GR32:$src2, addr:$src1)>;
3475def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3476 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3477def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3478 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3479def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3480 (CMOVS16rm GR16:$src2, addr:$src1)>;
3481def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3482 (CMOVS32rm GR32:$src2, addr:$src1)>;
3483def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3484 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3485def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3486 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3487def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3488 (CMOVO16rm GR16:$src2, addr:$src1)>;
3489def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3490 (CMOVO32rm GR32:$src2, addr:$src1)>;
3491
Duncan Sandsf9c98e62008-01-23 20:39:46 +00003492// zextload bool -> zextload byte
Evan Chenge5d93432006-01-17 07:02:46 +00003493def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003494def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3495def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3496
3497// extload bool -> extload byte
Evan Cheng47137242006-05-05 08:23:07 +00003498def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendling449416d2008-08-22 20:51:05 +00003499def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3500 Requires<[In32BitMode]>;
Evan Cheng47137242006-05-05 08:23:07 +00003501def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendling449416d2008-08-22 20:51:05 +00003502def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3503 Requires<[In32BitMode]>;
Evan Cheng47137242006-05-05 08:23:07 +00003504def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3505def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003506
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003507// anyext
Bill Wendling449416d2008-08-22 20:51:05 +00003508def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3509 Requires<[In32BitMode]>;
3510def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3511 Requires<[In32BitMode]>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003512def : Pat<(i32 (anyext GR16:$src)),
3513 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Evan Cheng510e4782006-01-09 23:10:28 +00003514
Evan Cheng1314b002007-12-13 00:43:27 +00003515// (and (i32 load), 255) -> (zextload i8)
Evan Chengd47e0b62008-09-29 17:26:18 +00003516def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3517 (MOVZX32rm8 addr:$src)>;
3518def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3519 (MOVZX32rm16 addr:$src)>;
Evan Cheng1314b002007-12-13 00:43:27 +00003520
Evan Chengcfa260b2006-01-06 02:31:59 +00003521//===----------------------------------------------------------------------===//
3522// Some peepholes
3523//===----------------------------------------------------------------------===//
3524
Dan Gohman63f97202008-10-17 01:33:43 +00003525// Odd encoding trick: -128 fits into an 8-bit immediate field while
3526// +128 doesn't, so in this special case use a sub instead of an add.
3527def : Pat<(add GR16:$src1, 128),
3528 (SUB16ri8 GR16:$src1, -128)>;
3529def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3530 (SUB16mi8 addr:$dst, -128)>;
3531def : Pat<(add GR32:$src1, 128),
3532 (SUB32ri8 GR32:$src1, -128)>;
3533def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3534 (SUB32mi8 addr:$dst, -128)>;
3535
Dan Gohman11ba3b12008-07-30 18:09:17 +00003536// r & (2^16-1) ==> movz
3537def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003538 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman8a1510d2008-08-06 18:27:21 +00003539// r & (2^8-1) ==> movz
3540def : Pat<(and GR32:$src1, 0xff),
Dan Gohman62417622009-04-27 16:33:14 +00003541 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003542 x86_subreg_8bit))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00003543 Requires<[In32BitMode]>;
3544// r & (2^8-1) ==> movz
3545def : Pat<(and GR16:$src1, 0xff),
Dan Gohman62417622009-04-27 16:33:14 +00003546 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003547 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003548 Requires<[In32BitMode]>;
3549
3550// sext_inreg patterns
3551def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003552 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003553def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman62417622009-04-27 16:33:14 +00003554 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003555 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003556 Requires<[In32BitMode]>;
3557def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman62417622009-04-27 16:33:14 +00003558 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003559 x86_subreg_8bit))>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003560 Requires<[In32BitMode]>;
3561
3562// trunc patterns
3563def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003564 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003565def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman62417622009-04-27 16:33:14 +00003566 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003567 x86_subreg_8bit)>,
Dan Gohman0bfa1bf2008-08-20 21:27:32 +00003568 Requires<[In32BitMode]>;
3569def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman62417622009-04-27 16:33:14 +00003570 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003571 x86_subreg_8bit)>,
3572 Requires<[In32BitMode]>;
3573
3574// h-register tricks
3575def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman62417622009-04-27 16:33:14 +00003576 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003577 x86_subreg_8bit_hi)>,
3578 Requires<[In32BitMode]>;
3579def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman62417622009-04-27 16:33:14 +00003580 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003581 x86_subreg_8bit_hi)>,
3582 Requires<[In32BitMode]>;
3583def : Pat<(srl_su GR16:$src, (i8 8)),
3584 (EXTRACT_SUBREG
3585 (MOVZX32rr8
Dan Gohman62417622009-04-27 16:33:14 +00003586 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003587 x86_subreg_8bit_hi)),
3588 x86_subreg_16bit)>,
3589 Requires<[In32BitMode]>;
Evan Chengcb219f02009-05-29 01:44:43 +00003590def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3591 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3592 x86_subreg_8bit_hi))>,
3593 Requires<[In32BitMode]>;
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003594def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman62417622009-04-27 16:33:14 +00003595 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman21e3dfb2009-04-13 16:09:41 +00003596 x86_subreg_8bit_hi))>,
Dan Gohman8a1510d2008-08-06 18:27:21 +00003597 Requires<[In32BitMode]>;
Dan Gohman11ba3b12008-07-30 18:09:17 +00003598
Evan Chengcfa260b2006-01-06 02:31:59 +00003599// (shl x, 1) ==> (add x, x)
Evan Cheng069287d2006-05-16 07:21:53 +00003600def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3601def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3602def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00003603
Evan Chengeb9f8922008-08-30 02:03:58 +00003604// (shl x (and y, 31)) ==> (shl x, y)
3605def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3606 (SHL8rCL GR8:$src1)>;
3607def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3608 (SHL16rCL GR16:$src1)>;
3609def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3610 (SHL32rCL GR32:$src1)>;
3611def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3612 (SHL8mCL addr:$dst)>;
3613def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3614 (SHL16mCL addr:$dst)>;
3615def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3616 (SHL32mCL addr:$dst)>;
3617
3618def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3619 (SHR8rCL GR8:$src1)>;
3620def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3621 (SHR16rCL GR16:$src1)>;
3622def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3623 (SHR32rCL GR32:$src1)>;
3624def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3625 (SHR8mCL addr:$dst)>;
3626def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3627 (SHR16mCL addr:$dst)>;
3628def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3629 (SHR32mCL addr:$dst)>;
3630
3631def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3632 (SAR8rCL GR8:$src1)>;
3633def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3634 (SAR16rCL GR16:$src1)>;
3635def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3636 (SAR32rCL GR32:$src1)>;
3637def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3638 (SAR8mCL addr:$dst)>;
3639def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3640 (SAR16mCL addr:$dst)>;
3641def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3642 (SAR32mCL addr:$dst)>;
3643
Evan Cheng956044c2006-01-19 23:26:24 +00003644// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003645def : Pat<(or (srl GR32:$src1, CL:$amt),
3646 (shl GR32:$src2, (sub 32, CL:$amt))),
3647 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng68b951a2006-01-19 01:56:29 +00003648
Evan Cheng21d54432006-01-20 01:13:30 +00003649def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003650 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3651 (SHRD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003652
Dan Gohman74feef22008-10-17 01:23:35 +00003653def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3654 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3655 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3656
3657def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3658 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3659 addr:$dst),
3660 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3661
3662def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3663 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3664
3665def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3666 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3667 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3668
Evan Cheng956044c2006-01-19 23:26:24 +00003669// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003670def : Pat<(or (shl GR32:$src1, CL:$amt),
3671 (srl GR32:$src2, (sub 32, CL:$amt))),
3672 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003673
Evan Cheng21d54432006-01-20 01:13:30 +00003674def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003675 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3676 (SHLD32mrCL addr:$dst, GR32:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003677
Dan Gohman74feef22008-10-17 01:23:35 +00003678def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3679 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3680 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3681
3682def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3683 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3684 addr:$dst),
3685 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3686
3687def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3688 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3689
3690def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3691 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3692 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3693
Evan Cheng956044c2006-01-19 23:26:24 +00003694// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003695def : Pat<(or (srl GR16:$src1, CL:$amt),
3696 (shl GR16:$src2, (sub 16, CL:$amt))),
3697 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng956044c2006-01-19 23:26:24 +00003698
Evan Cheng21d54432006-01-20 01:13:30 +00003699def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003700 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3701 (SHRD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003702
Dan Gohman74feef22008-10-17 01:23:35 +00003703def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3704 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3705 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3706
3707def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3708 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3709 addr:$dst),
3710 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3711
3712def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3713 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3714
3715def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3716 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3717 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3718
Evan Cheng956044c2006-01-19 23:26:24 +00003719// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
Evan Cheng069287d2006-05-16 07:21:53 +00003720def : Pat<(or (shl GR16:$src1, CL:$amt),
3721 (srl GR16:$src2, (sub 16, CL:$amt))),
3722 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
Evan Cheng21d54432006-01-20 01:13:30 +00003723
3724def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
Evan Cheng069287d2006-05-16 07:21:53 +00003725 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3726 (SHLD16mrCL addr:$dst, GR16:$src2)>;
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003727
Dan Gohman74feef22008-10-17 01:23:35 +00003728def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3729 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3730 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3731
3732def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3733 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3734 addr:$dst),
3735 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3736
3737def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3738 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3739
3740def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3741 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3742 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3743
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003744//===----------------------------------------------------------------------===//
Dan Gohman076aee32009-03-04 19:44:21 +00003745// EFLAGS-defining Patterns
Bill Wendlingd350e022008-12-12 21:15:41 +00003746//===----------------------------------------------------------------------===//
3747
Dan Gohman076aee32009-03-04 19:44:21 +00003748// Register-Register Addition with EFLAGS result
3749def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003750 (implicit EFLAGS)),
3751 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003752def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003753 (implicit EFLAGS)),
3754 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003755def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003756 (implicit EFLAGS)),
3757 (ADD32rr GR32:$src1, GR32:$src2)>;
3758
Dan Gohman076aee32009-03-04 19:44:21 +00003759// Register-Memory Addition with EFLAGS result
3760def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003761 (implicit EFLAGS)),
3762 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003763def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003764 (implicit EFLAGS)),
3765 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003766def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003767 (implicit EFLAGS)),
3768 (ADD32rm GR32:$src1, addr:$src2)>;
3769
Dan Gohman076aee32009-03-04 19:44:21 +00003770// Register-Integer Addition with EFLAGS result
3771def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003772 (implicit EFLAGS)),
3773 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003774def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003775 (implicit EFLAGS)),
3776 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003777def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003778 (implicit EFLAGS)),
3779 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003780def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003781 (implicit EFLAGS)),
3782 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003783def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003784 (implicit EFLAGS)),
3785 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3786
Dan Gohman076aee32009-03-04 19:44:21 +00003787// Memory-Register Addition with EFLAGS result
3788def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003789 addr:$dst),
3790 (implicit EFLAGS)),
3791 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003792def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003793 addr:$dst),
3794 (implicit EFLAGS)),
3795 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003796def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003797 addr:$dst),
3798 (implicit EFLAGS)),
3799 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesenca11dae2009-05-18 17:44:15 +00003800
3801// Memory-Integer Addition with EFLAGS result
Dan Gohman076aee32009-03-04 19:44:21 +00003802def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003803 addr:$dst),
3804 (implicit EFLAGS)),
3805 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003806def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003807 addr:$dst),
3808 (implicit EFLAGS)),
3809 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003810def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003811 addr:$dst),
3812 (implicit EFLAGS)),
3813 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003814def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003815 addr:$dst),
3816 (implicit EFLAGS)),
3817 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003818def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003819 addr:$dst),
3820 (implicit EFLAGS)),
3821 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3822
Dan Gohman076aee32009-03-04 19:44:21 +00003823// Register-Register Subtraction with EFLAGS result
3824def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003825 (implicit EFLAGS)),
3826 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003827def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003828 (implicit EFLAGS)),
3829 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003830def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003831 (implicit EFLAGS)),
3832 (SUB32rr GR32:$src1, GR32:$src2)>;
3833
Dan Gohman076aee32009-03-04 19:44:21 +00003834// Register-Memory Subtraction with EFLAGS result
3835def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003836 (implicit EFLAGS)),
3837 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003838def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003839 (implicit EFLAGS)),
3840 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003841def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003842 (implicit EFLAGS)),
3843 (SUB32rm GR32:$src1, addr:$src2)>;
3844
Dan Gohman076aee32009-03-04 19:44:21 +00003845// Register-Integer Subtraction with EFLAGS result
3846def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003847 (implicit EFLAGS)),
3848 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003849def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003850 (implicit EFLAGS)),
3851 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003852def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003853 (implicit EFLAGS)),
3854 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003855def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003856 (implicit EFLAGS)),
3857 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003858def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003859 (implicit EFLAGS)),
3860 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3861
Dan Gohman076aee32009-03-04 19:44:21 +00003862// Memory-Register Subtraction with EFLAGS result
3863def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003864 addr:$dst),
3865 (implicit EFLAGS)),
3866 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003867def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003868 addr:$dst),
3869 (implicit EFLAGS)),
3870 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003871def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003872 addr:$dst),
3873 (implicit EFLAGS)),
3874 (SUB32mr addr:$dst, GR32:$src2)>;
3875
Dan Gohman076aee32009-03-04 19:44:21 +00003876// Memory-Integer Subtraction with EFLAGS result
3877def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003878 addr:$dst),
3879 (implicit EFLAGS)),
3880 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003881def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003882 addr:$dst),
3883 (implicit EFLAGS)),
3884 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003885def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003886 addr:$dst),
3887 (implicit EFLAGS)),
3888 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003889def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003890 addr:$dst),
3891 (implicit EFLAGS)),
3892 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003893def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003894 addr:$dst),
3895 (implicit EFLAGS)),
3896 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3897
3898
Dan Gohman076aee32009-03-04 19:44:21 +00003899// Register-Register Signed Integer Multiply with EFLAGS result
3900def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003901 (implicit EFLAGS)),
3902 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003903def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003904 (implicit EFLAGS)),
3905 (IMUL32rr GR32:$src1, GR32:$src2)>;
3906
Dan Gohman076aee32009-03-04 19:44:21 +00003907// Register-Memory Signed Integer Multiply with EFLAGS result
3908def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003909 (implicit EFLAGS)),
3910 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003911def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingd350e022008-12-12 21:15:41 +00003912 (implicit EFLAGS)),
3913 (IMUL32rm GR32:$src1, addr:$src2)>;
3914
Dan Gohman076aee32009-03-04 19:44:21 +00003915// Register-Integer Signed Integer Multiply with EFLAGS result
3916def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003917 (implicit EFLAGS)),
3918 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003919def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003920 (implicit EFLAGS)),
3921 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003922def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003923 (implicit EFLAGS)),
3924 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003925def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003926 (implicit EFLAGS)),
3927 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3928
Dan Gohman076aee32009-03-04 19:44:21 +00003929// Memory-Integer Signed Integer Multiply with EFLAGS result
3930def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003931 (implicit EFLAGS)),
3932 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003933def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003934 (implicit EFLAGS)),
3935 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003936def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003937 (implicit EFLAGS)),
3938 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman076aee32009-03-04 19:44:21 +00003939def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingd350e022008-12-12 21:15:41 +00003940 (implicit EFLAGS)),
3941 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3942
Dan Gohman076aee32009-03-04 19:44:21 +00003943// Optimize multiply by 2 with EFLAGS result.
Evan Cheng6a86bd72009-01-27 03:30:42 +00003944let AddedComplexity = 2 in {
Dan Gohman076aee32009-03-04 19:44:21 +00003945def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00003946 (implicit EFLAGS)),
3947 (ADD16rr GR16:$src1, GR16:$src1)>;
3948
Dan Gohman076aee32009-03-04 19:44:21 +00003949def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng6a86bd72009-01-27 03:30:42 +00003950 (implicit EFLAGS)),
3951 (ADD32rr GR32:$src1, GR32:$src1)>;
3952}
3953
Dan Gohman076aee32009-03-04 19:44:21 +00003954// INC and DEC with EFLAGS result. Note that these do not set CF.
3955def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3956 (INC8r GR8:$src)>;
3957def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3958 (implicit EFLAGS)),
3959 (INC8m addr:$dst)>;
3960def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3961 (DEC8r GR8:$src)>;
3962def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3963 (implicit EFLAGS)),
3964 (DEC8m addr:$dst)>;
3965
3966def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003967 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003968def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3969 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003970 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003971def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003972 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003973def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3974 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003975 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003976
3977def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003978 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003979def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3980 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003981 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003982def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003983 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003984def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3985 (implicit EFLAGS)),
Dan Gohman1f4af262009-03-05 21:32:23 +00003986 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman076aee32009-03-04 19:44:21 +00003987
Bill Wendlingd350e022008-12-12 21:15:41 +00003988//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00003989// Floating Point Stack Support
3990//===----------------------------------------------------------------------===//
3991
3992include "X86InstrFPStack.td"
3993
3994//===----------------------------------------------------------------------===//
Evan Chengc64a1a92007-07-31 08:04:03 +00003995// X86-64 Support
3996//===----------------------------------------------------------------------===//
3997
Chris Lattner36fe6d22008-01-10 05:50:42 +00003998include "X86Instr64bit.td"
Evan Chengc64a1a92007-07-31 08:04:03 +00003999
4000//===----------------------------------------------------------------------===//
Evan Cheng4e4c71e2006-02-21 20:00:20 +00004001// XMM Floating point support (requires SSE / SSE2)
4002//===----------------------------------------------------------------------===//
4003
4004include "X86InstrSSE.td"
Evan Cheng80f54042008-04-25 18:19:54 +00004005
4006//===----------------------------------------------------------------------===//
4007// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4008//===----------------------------------------------------------------------===//
4009
4010include "X86InstrMMX.td"