blob: eaafe0a7ce2a7bf2249cf4394f1ad6c91087876a [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
20def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
24def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
Evan Cheng621216e2007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng950aac02007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029
Dan Gohman99a12192009-03-04 19:44:21 +000030// Unary and binary operator instructions that set EFLAGS as a side-effect.
31def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
32 [SDTCisInt<0>]>;
33def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
34 [SDTCisSameAs<0, 1>,
35 SDTCisSameAs<0, 2>,
36 SDTCisInt<0>]>;
Evan Cheng621216e2007-09-29 00:00:36 +000037def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000038 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040
Evan Cheng621216e2007-09-29 00:00:36 +000041def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000042 [SDTCisVT<0, i8>,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000044
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000045def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
46 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000047def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000048
Dale Johannesenf160d802008-10-02 18:53:47 +000049def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
50 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000051def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052
Sean Callanan2c8a2592009-06-23 23:25:37 +000053def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
54def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
55 SDTCisVT<1, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000056
Dan Gohman3329ffe2008-05-29 19:57:41 +000057def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000058
59def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
60
61def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
62
63def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
64
Rafael Espindolaaf759ab2009-04-17 14:35:58 +000065def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066
Rafael Espindolabca99f72009-04-08 21:14:34 +000067def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068
69def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
70
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000071def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
72
Evan Cheng48679f42007-12-14 02:13:44 +000073def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
74def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000075def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
76def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
77
Evan Cheng621216e2007-09-29 00:00:36 +000078def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000080def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
81
Evan Cheng621216e2007-09-29 00:00:36 +000082def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000084 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000085def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000087def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
89 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000090def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
91 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
92 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000093def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
94 [SDNPHasChain, SDNPMayStore,
95 SDNPMayLoad, SDNPMemOperand]>;
96def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
97 [SDNPHasChain, SDNPMayStore,
98 SDNPMayLoad, SDNPMemOperand]>;
99def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
100 [SDNPHasChain, SDNPMayStore,
101 SDNPMayLoad, SDNPMemOperand]>;
102def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
103 [SDNPHasChain, SDNPMayStore,
104 SDNPMayLoad, SDNPMemOperand]>;
105def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
106 [SDNPHasChain, SDNPMayStore,
107 SDNPMayLoad, SDNPMemOperand]>;
108def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
109 [SDNPHasChain, SDNPMayStore,
110 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000111def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
112 [SDNPHasChain, SDNPMayStore,
113 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000114def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
115 [SDNPHasChain, SDNPOptInFlag]>;
116
117def X86callseq_start :
118 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
119 [SDNPHasChain, SDNPOutFlag]>;
120def X86callseq_end :
121 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000122 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123
124def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
125 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
126
127def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
128 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
129
130def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000131 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000133 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
134 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135
136def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000137 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138
139def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
140def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
141
142def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000143 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000144def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
145 SDT_X86SegmentBaseAddress, []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000146
147def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
148 [SDNPHasChain]>;
149
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000150def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
151 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152
Dan Gohman99a12192009-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 Wendlingae034ed2008-12-12 00:56:36 +0000159
Evan Chengc3495762009-03-30 21:36:47 +0000160def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
161
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000162//===----------------------------------------------------------------------===//
163// X86 Operand Definitions.
164//
165
Chris Lattner357a0ca2009-06-20 19:34:09 +0000166def i32imm_pcrel : Operand<i32> {
167 let PrintMethod = "print_pcrel_imm";
168}
169
170
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171// *mem - Operand definitions for the funky X86 addressing mode operands.
172//
173class X86MemOperand<string printMethod> : Operand<iPTR> {
174 let PrintMethod = printMethod;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000175 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm, i8imm);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176}
177
178def i8mem : X86MemOperand<"printi8mem">;
179def i16mem : X86MemOperand<"printi16mem">;
180def i32mem : X86MemOperand<"printi32mem">;
181def i64mem : X86MemOperand<"printi64mem">;
182def i128mem : X86MemOperand<"printi128mem">;
David Greene6b75fca2009-06-30 19:24:59 +0000183def i256mem : X86MemOperand<"printi256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000184def f32mem : X86MemOperand<"printf32mem">;
185def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000186def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000187def f128mem : X86MemOperand<"printf128mem">;
David Greene6b75fca2009-06-30 19:24:59 +0000188def f256mem : X86MemOperand<"printf256mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000189
Dan Gohman744d4622009-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
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000197def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000198 let PrintMethod = "printlea32mem";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000199 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
200}
201
202def SSECC : Operand<i8> {
203 let PrintMethod = "printSSECC";
204}
205
206def piclabel: Operand<i32> {
207 let PrintMethod = "printPICLabel";
208}
209
210// 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 Lattner357a0ca2009-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}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000220
Evan Chengd11052b2009-07-21 06:00:18 +0000221def brtarget8 : Operand<OtherVT> {
222 let PrintMethod = "print_pcrel_imm";
223}
224
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225//===----------------------------------------------------------------------===//
226// X86 Complex Pattern Definitions.
227//
228
229// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000230def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman946223f2009-05-11 18:02:53 +0000232 [add, sub, mul, shl, or, frameindex], []>;
Chris Lattnerf1940742009-06-20 20:38:48 +0000233def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
234 [tglobaltlsaddr], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000235
236//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000237// X86 Instruction Predicate Definitions.
238def HasMMX : Predicate<"Subtarget->hasMMX()">;
239def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
240def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
241def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
242def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000243def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
244def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene8bf22bc2009-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 Johannesene0e0fd02007-09-23 14:52:20 +0000249def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
250def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +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 Cheng13559d62008-09-26 23:41:32 +0000256def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000257def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000258def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000259
260//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000261// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262//
263
Evan Cheng86ab7d32007-07-31 08:04:03 +0000264include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000265
266//===----------------------------------------------------------------------===//
267// Pattern fragments...
268//
269
270// X86 specific condition code. These correspond to CondCode in
271// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-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
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000283def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-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)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000288
289def i16immSExt8 : PatLeaf<(i16 imm), [{
290 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
291 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000292 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000293}]>;
294
295def i32immSExt8 : PatLeaf<(i32 imm), [{
296 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
297 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000298 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000299}]>;
300
301// Helper fragments for loads.
Evan Chengb3e25ea2008-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 Gohman2a174122008-10-15 06:50:19 +0000304def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000305 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000306 if (const Value *Src = LD->getSrcValue())
307 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000308 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000309 return false;
Dan Gohman8335c412008-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 Cheng8b765e92008-05-13 00:54:02 +0000315 return false;
316}]>;
317
Dan Gohman2a174122008-10-15 06:50:19 +0000318def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000319 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000320 if (const Value *Src = LD->getSrcValue())
321 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000322 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000323 return false;
Evan Cheng56ec77b2008-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 Gohman2a174122008-10-15 06:50:19 +0000330def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000331 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000332 if (const Value *Src = LD->getSrcValue())
333 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000334 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000335 return false;
Dan Gohman8335c412008-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 Cheng8b765e92008-05-13 00:54:02 +0000341 return false;
342}]>;
343
Dan Gohman2a174122008-10-15 06:50:19 +0000344def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000345 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000346 if (const Value *Src = LD->getSrcValue())
347 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000348 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000349 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000350 if (LD->isVolatile())
351 return false;
Evan Cheng1e5e5452008-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
sampo9cc09a32009-01-26 01:24:32 +0000360def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-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;
sampo9cc09a32009-01-26 01:24:32 +0000364 return false;
365}]>;
366
Chris Lattnera7c2d8a2009-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 Lattner12208612009-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 Wangdc97d5a2009-04-27 07:22:10 +0000377 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-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 Wangdc97d5a2009-04-27 07:22:10 +0000384 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000385 return false;
386 return true;
387}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388
Chris Lattner12208612009-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 Wangdc97d5a2009-04-27 07:22:10 +0000392 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-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 Wangdc97d5a2009-04-27 07:22:10 +0000399 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-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 Wangdc97d5a2009-04-27 07:22:10 +0000406 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000407 return false;
408 return true;
409}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410
Dan Gohmanf17a25c2007-07-18 16:29:46 +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))>;
414
415def 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))>;
421
422def 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))>;
428
Chris Lattner21da6382008-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 Cheng9123cfa2008-03-04 00:40:35 +0000432 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000433}]>;
Dan Gohman744d4622009-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 Lattner21da6382008-02-19 17:37:35 +0000442
Dan Gohman921581d2008-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
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000472// Instruction list...
473//
474
475// 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 Lattnerb56cc342008-03-11 03:23:40 +0000478// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
479// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000480let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000481def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
482 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000483 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000484 Requires<[In32BitMode]>;
485def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
486 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000487 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000488 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000489}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000490
491// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000492let neverHasSideEffects = 1 in
493 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494
Evan Cheng0729ccf2008-01-05 00:41:47 +0000495// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000496let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000497 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman70a8a112009-04-27 15:13:28 +0000498 "call\t$label\n\t"
499 "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000500
501//===----------------------------------------------------------------------===//
502// Control Flow Instructions...
503//
504
505// Return instructions.
506let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000507 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000508 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000509 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000510 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000511 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
512 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000513 [(X86retflag imm:$amt)]>;
514}
515
516// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000517let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-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>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000520
Sean Callananc0608152009-07-22 01:05:20 +0000521let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000522 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000523 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
524}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525
Owen Andersonf8053082007-11-12 07:39:39 +0000526// Indirect branches
527let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000528 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000530 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531 [(brind (loadi32 addr:$dst))]>;
532}
533
534// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000535let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000536// Short conditional jumps
537def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
538def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
539def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
540def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
541def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
542def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
543def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
544def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
545def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
546def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
547def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
548def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
549def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
550def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
551def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
552def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
553
554def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
555
Dan Gohman91888f02007-07-31 20:11:57 +0000556def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000557 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000558def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000559 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000560def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000561 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000562def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000563 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000564def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000565 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000566def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000567 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568
Dan Gohman91888f02007-07-31 20:11:57 +0000569def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000570 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000571def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000572 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000573def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000574 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000575def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000576 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577
Dan Gohman91888f02007-07-31 20:11:57 +0000578def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000579 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000580def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000581 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000582def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000583 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000584def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000585 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000586def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000587 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000588def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000589 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000590} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000591
592//===----------------------------------------------------------------------===//
593// Call Instructions...
594//
Evan Cheng37e7c752007-07-21 00:34:19 +0000595let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000596 // All calls clobber the non-callee saved registers. ESP is marked as
597 // a use to prevent stack-pointer assignments that appear immediately
598 // before calls from potentially appearing dead. Uses for argument
599 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
601 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000602 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
603 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000604 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000605 def CALLpcrel32 : Ii32<0xE8, RawFrm,
606 (outs), (ins i32imm_pcrel:$dst,variable_ops),
607 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000608 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000609 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000610 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000611 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612 }
613
614// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000615
Chris Lattnerb56cc342008-03-11 03:23:40 +0000616def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000617 "#TAILCALL",
618 []>;
619
Evan Cheng37e7c752007-07-21 00:34:19 +0000620let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000621def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000622 "#TC_RETURN $dst $offset",
623 []>;
624
625let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000626def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000627 "#TC_RETURN $dst $offset",
628 []>;
629
630let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000631
Chris Lattner357a0ca2009-06-20 19:34:09 +0000632 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000633 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000634let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000635 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
636 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000637let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000638 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000639 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000640
641//===----------------------------------------------------------------------===//
642// Miscellaneous Instructions...
643//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000644let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000645def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000646 (outs), (ins), "leave", []>;
647
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000648let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
649let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000650def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000651
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000652let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000653def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000654}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000655
Bill Wendling4c2638c2009-06-15 19:39:04 +0000656let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
657def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000658 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000659def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000660 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000661def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000662 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000663}
664
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000665let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000666def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000667let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000668def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000669
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670let isTwoAddress = 1 in // GR32 = bswap GR32
671 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000672 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000673 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000674 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
675
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676
Evan Cheng48679f42007-12-14 02:13:44 +0000677// Bit scan instructions.
678let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000679def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000680 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000681 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000682def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000683 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000684 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
685 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000686def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000687 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000688 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000689def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000690 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000691 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
692 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000693
Evan Cheng4e33de92007-12-14 18:49:43 +0000694def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000695 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000696 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000697def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000698 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000699 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
700 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000701def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000702 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000703 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000704def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000705 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000706 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
707 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000708} // Defs = [EFLAGS]
709
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000710let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000712 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000713 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000714let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000715def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000716 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000717 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
719
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000720let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000721def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000722 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000723def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000724 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000725def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000726 [(X86rep_movs i32)]>, REP;
727}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000729let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000730def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000731 [(X86rep_stos i8)]>, REP;
732let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000733def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000734 [(X86rep_stos i16)]>, REP, OpSize;
735let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000736def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000737 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000738
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000739let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000740def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000741 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000742
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000743let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000744def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000745}
746
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747//===----------------------------------------------------------------------===//
748// Input/Output Instructions...
749//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000750let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000751def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000752 "in{b}\t{%dx, %al|%AL, %DX}", []>;
753let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000754def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000755 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
756let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000757def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000758 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000760let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000761def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000762 "in{b}\t{$port, %al|%AL, $port}", []>;
763let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000764def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000765 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
766let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000767def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000768 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000769
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000770let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000771def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000772 "out{b}\t{%al, %dx|%DX, %AL}", []>;
773let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000774def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000775 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
776let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000777def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000778 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000780let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000781def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000782 "out{b}\t{%al, $port|$port, %AL}", []>;
783let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000784def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000785 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
786let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000787def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000788 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789
790//===----------------------------------------------------------------------===//
791// Move Instructions...
792//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000793let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000794def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000795 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000796def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000797 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000798def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000799 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000800}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000801let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000802def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000803 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000805def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000806 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000808def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000809 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810 [(set GR32:$dst, imm:$src)]>;
811}
Evan Chengb783fa32007-07-19 01:14:50 +0000812def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000813 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000815def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000816 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000818def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000819 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 [(store (i32 imm:$src), addr:$dst)]>;
821
Dan Gohman5574cc72008-12-03 18:15:48 +0000822let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000823def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000824 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000825 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000826def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000828 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000829def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000830 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000831 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000832}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833
Evan Chengb783fa32007-07-19 01:14:50 +0000834def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000835 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000837def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000838 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000840def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000841 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000843
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000844// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
845// that they can be used for copying and storing h registers, which can't be
846// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000847let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000848def MOV8rr_NOREX : I<0x88, MRMDestReg,
849 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000850 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000851let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000852def MOV8mr_NOREX : I<0x88, MRMDestMem,
853 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
854 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000855let mayLoad = 1,
856 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000857def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
858 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
859 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000860
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861//===----------------------------------------------------------------------===//
862// Fixed-Register Multiplication and Division Instructions...
863//
864
865// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000866let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000867def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
869 // This probably ought to be moved to a def : Pat<> if the
870 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000871 [(set AL, (mul AL, GR8:$src)),
872 (implicit EFLAGS)]>; // AL,AH = AL*GR8
873
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000874let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000875def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
876 "mul{w}\t$src",
877 []>, OpSize; // AX,DX = AX*GR16
878
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000879let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000880def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
881 "mul{l}\t$src",
882 []>; // EAX,EDX = EAX*GR32
883
Evan Cheng55687072007-09-14 21:48:26 +0000884let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000885def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000886 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
888 // This probably ought to be moved to a def : Pat<> if the
889 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000890 [(set AL, (mul AL, (loadi8 addr:$src))),
891 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
892
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000893let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000894let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000895def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000896 "mul{w}\t$src",
897 []>, OpSize; // AX,DX = AX*[mem16]
898
Evan Cheng55687072007-09-14 21:48:26 +0000899let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000900def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000901 "mul{l}\t$src",
902 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000903}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000905let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000906let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000907def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
908 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000909let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000910def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000911 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000912let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000913def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
914 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000915let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000916let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000917def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000918 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000919let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000920def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000921 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
922let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000923def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000924 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000925}
Dan Gohmand44572d2008-11-18 21:29:14 +0000926} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927
928// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000929let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000930def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000931 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000932let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000933def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000934 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000935let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000936def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000937 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000938let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000939let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000940def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000941 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000942let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000943def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000944 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000945let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000946def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000947 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000948}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949
950// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000951let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000952def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000953 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000954let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000955def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000956 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000957let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000958def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000959 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000960let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000961let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000962def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000963 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000964let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000965def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000966 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000967let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000968def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000969 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000970}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971
972//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000973// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974//
975let isTwoAddress = 1 in {
976
977// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000978let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000979let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000981 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000984 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000987 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000988 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000990 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000993 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000994 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000996 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000999 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001000 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001002 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001005 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001006 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001008 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001011 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001012 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001014 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001017 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001018 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001020 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001021 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001023 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001024 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001026 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001027 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001029 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001030 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001032 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001035 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001036 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001038 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001041 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001042 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001044 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001047 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001048 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001050 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001051 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001053 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001054 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001056 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001059 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001060 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001062 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001065 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001066 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001068 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001069 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001071 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001072 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001074 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001077 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001078 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001080 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001083 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001084 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001086 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001088def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001089 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001090 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001092 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001095 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001096 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001098 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001101 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001102 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001103 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001104 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001107 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001108 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001110 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001113 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001114 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001116 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001119 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001120 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001122 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001123 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001125 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001126 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001127 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001128 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001131 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001132 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001134 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001137 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001138 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001140 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001141 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001142def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001143 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001144 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001146 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001147 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001148def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1149 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1150 "cmovo\t{$src2, $dst|$dst, $src2}",
1151 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1152 X86_COND_O, EFLAGS))]>,
1153 TB, OpSize;
1154def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1155 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1156 "cmovo\t{$src2, $dst|$dst, $src2}",
1157 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1158 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001159 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001160def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1161 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1162 "cmovno\t{$src2, $dst|$dst, $src2}",
1163 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1164 X86_COND_NO, EFLAGS))]>,
1165 TB, OpSize;
1166def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1167 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1168 "cmovno\t{$src2, $dst|$dst, $src2}",
1169 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1170 X86_COND_NO, EFLAGS))]>,
1171 TB;
1172} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001173
1174def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1175 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1176 "cmovb\t{$src2, $dst|$dst, $src2}",
1177 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1178 X86_COND_B, EFLAGS))]>,
1179 TB, OpSize;
1180def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1181 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1182 "cmovb\t{$src2, $dst|$dst, $src2}",
1183 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1184 X86_COND_B, EFLAGS))]>,
1185 TB;
1186def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1187 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1188 "cmovae\t{$src2, $dst|$dst, $src2}",
1189 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1190 X86_COND_AE, EFLAGS))]>,
1191 TB, OpSize;
1192def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1193 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1194 "cmovae\t{$src2, $dst|$dst, $src2}",
1195 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1196 X86_COND_AE, EFLAGS))]>,
1197 TB;
1198def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1199 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1200 "cmove\t{$src2, $dst|$dst, $src2}",
1201 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1202 X86_COND_E, EFLAGS))]>,
1203 TB, OpSize;
1204def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1205 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1206 "cmove\t{$src2, $dst|$dst, $src2}",
1207 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1208 X86_COND_E, EFLAGS))]>,
1209 TB;
1210def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1211 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1212 "cmovne\t{$src2, $dst|$dst, $src2}",
1213 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1214 X86_COND_NE, EFLAGS))]>,
1215 TB, OpSize;
1216def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1217 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1218 "cmovne\t{$src2, $dst|$dst, $src2}",
1219 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1220 X86_COND_NE, EFLAGS))]>,
1221 TB;
1222def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1223 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1224 "cmovbe\t{$src2, $dst|$dst, $src2}",
1225 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1226 X86_COND_BE, EFLAGS))]>,
1227 TB, OpSize;
1228def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1229 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1230 "cmovbe\t{$src2, $dst|$dst, $src2}",
1231 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1232 X86_COND_BE, EFLAGS))]>,
1233 TB;
1234def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1235 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1236 "cmova\t{$src2, $dst|$dst, $src2}",
1237 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1238 X86_COND_A, EFLAGS))]>,
1239 TB, OpSize;
1240def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1241 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1242 "cmova\t{$src2, $dst|$dst, $src2}",
1243 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1244 X86_COND_A, EFLAGS))]>,
1245 TB;
1246def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1247 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1248 "cmovl\t{$src2, $dst|$dst, $src2}",
1249 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1250 X86_COND_L, EFLAGS))]>,
1251 TB, OpSize;
1252def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1253 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1254 "cmovl\t{$src2, $dst|$dst, $src2}",
1255 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1256 X86_COND_L, EFLAGS))]>,
1257 TB;
1258def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1259 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1260 "cmovge\t{$src2, $dst|$dst, $src2}",
1261 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1262 X86_COND_GE, EFLAGS))]>,
1263 TB, OpSize;
1264def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1265 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1266 "cmovge\t{$src2, $dst|$dst, $src2}",
1267 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1268 X86_COND_GE, EFLAGS))]>,
1269 TB;
1270def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1271 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1272 "cmovle\t{$src2, $dst|$dst, $src2}",
1273 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1274 X86_COND_LE, EFLAGS))]>,
1275 TB, OpSize;
1276def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1277 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1278 "cmovle\t{$src2, $dst|$dst, $src2}",
1279 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1280 X86_COND_LE, EFLAGS))]>,
1281 TB;
1282def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1283 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1284 "cmovg\t{$src2, $dst|$dst, $src2}",
1285 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1286 X86_COND_G, EFLAGS))]>,
1287 TB, OpSize;
1288def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1289 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1290 "cmovg\t{$src2, $dst|$dst, $src2}",
1291 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1292 X86_COND_G, EFLAGS))]>,
1293 TB;
1294def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1295 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1296 "cmovs\t{$src2, $dst|$dst, $src2}",
1297 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1298 X86_COND_S, EFLAGS))]>,
1299 TB, OpSize;
1300def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1301 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1302 "cmovs\t{$src2, $dst|$dst, $src2}",
1303 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1304 X86_COND_S, EFLAGS))]>,
1305 TB;
1306def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1307 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1308 "cmovns\t{$src2, $dst|$dst, $src2}",
1309 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1310 X86_COND_NS, EFLAGS))]>,
1311 TB, OpSize;
1312def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1313 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1314 "cmovns\t{$src2, $dst|$dst, $src2}",
1315 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1316 X86_COND_NS, EFLAGS))]>,
1317 TB;
1318def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1319 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1320 "cmovp\t{$src2, $dst|$dst, $src2}",
1321 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1322 X86_COND_P, EFLAGS))]>,
1323 TB, OpSize;
1324def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1325 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1326 "cmovp\t{$src2, $dst|$dst, $src2}",
1327 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1328 X86_COND_P, EFLAGS))]>,
1329 TB;
1330def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1331 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1332 "cmovnp\t{$src2, $dst|$dst, $src2}",
1333 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1334 X86_COND_NP, EFLAGS))]>,
1335 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001336def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1337 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1338 "cmovnp\t{$src2, $dst|$dst, $src2}",
1339 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1340 X86_COND_NP, EFLAGS))]>,
1341 TB;
1342def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1343 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1344 "cmovo\t{$src2, $dst|$dst, $src2}",
1345 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1346 X86_COND_O, EFLAGS))]>,
1347 TB, OpSize;
1348def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1349 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1350 "cmovo\t{$src2, $dst|$dst, $src2}",
1351 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1352 X86_COND_O, EFLAGS))]>,
1353 TB;
1354def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1355 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1356 "cmovno\t{$src2, $dst|$dst, $src2}",
1357 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1358 X86_COND_NO, EFLAGS))]>,
1359 TB, OpSize;
1360def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1361 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1362 "cmovno\t{$src2, $dst|$dst, $src2}",
1363 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1364 X86_COND_NO, EFLAGS))]>,
1365 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001366} // Uses = [EFLAGS]
1367
1368
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369// unary instructions
1370let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001371let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001372def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001373 [(set GR8:$dst, (ineg GR8:$src)),
1374 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001375def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001376 [(set GR16:$dst, (ineg GR16:$src)),
1377 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001378def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001379 [(set GR32:$dst, (ineg GR32:$src)),
1380 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001382 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001383 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1384 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001385 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001386 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1387 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001388 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001389 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1390 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001391}
Evan Cheng55687072007-09-14 21:48:26 +00001392} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393
Evan Chengc6cee682009-01-21 02:09:05 +00001394// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1395let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001396def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001397 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001398def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001400def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001401 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001402}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001404 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001405 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001406 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001407 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001408 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1410}
1411} // CodeSize
1412
1413// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001414let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001415let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001416def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001417 [(set GR8:$dst, (add GR8:$src, 1)),
1418 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001420def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001421 [(set GR16:$dst, (add GR16:$src, 1)),
1422 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001423 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001424def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001425 [(set GR32:$dst, (add GR32:$src, 1)),
1426 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001427}
1428let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001429 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001430 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1431 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001432 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001433 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1434 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001435 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001436 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001437 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1438 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001439 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440}
1441
1442let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001443def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001444 [(set GR8:$dst, (add GR8:$src, -1)),
1445 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001446let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001447def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001448 [(set GR16:$dst, (add GR16:$src, -1)),
1449 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001450 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001451def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001452 [(set GR32:$dst, (add GR32:$src, -1)),
1453 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001454}
1455
1456let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001457 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001458 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1459 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001460 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001461 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1462 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001463 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001464 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001465 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1466 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001467 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001468}
Evan Cheng55687072007-09-14 21:48:26 +00001469} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001470
1471// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001472let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1474def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001475 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001476 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001477 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1478 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001479def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001480 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001482 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1483 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001484def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001485 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001487 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1488 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489}
1490
1491def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001492 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001493 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001494 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001495 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001496def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001497 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001498 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001499 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001500 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001502 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001503 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001504 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001505 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001506
1507def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001508 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001509 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001510 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1511 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001512def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001513 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001515 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1516 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001518 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001519 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001520 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1521 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001523 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001524 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001525 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1526 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001527 OpSize;
1528def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001529 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001530 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001531 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1532 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533
1534let isTwoAddress = 0 in {
1535 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001536 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001537 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001538 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1539 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001541 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001543 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1544 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001545 OpSize;
1546 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001547 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001548 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001549 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1550 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001552 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001554 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1555 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001557 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001559 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1560 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561 OpSize;
1562 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001563 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001564 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001565 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1566 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001568 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001569 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001570 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1571 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 OpSize;
1573 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001574 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001575 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001576 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1577 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578}
1579
1580
1581let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001582def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001583 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001584 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1585 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001586def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001587 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001588 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1589 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001590def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001591 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001592 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1593 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001594}
Evan Chengb783fa32007-07-19 01:14:50 +00001595def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001596 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001597 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1598 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001599def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001600 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001601 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1602 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001603def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001604 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001605 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1606 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001607
Evan Chengb783fa32007-07-19 01:14:50 +00001608def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001609 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001610 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1611 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001612def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001613 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001614 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1615 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001616def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001617 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001618 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1619 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620
Evan Chengb783fa32007-07-19 01:14:50 +00001621def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001622 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001623 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1624 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001625def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001626 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001627 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1628 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001629let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001630 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001631 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001632 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1633 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001634 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001635 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001636 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1637 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001638 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001639 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001640 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1641 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001642 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001643 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001644 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1645 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001646 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001648 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1649 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001651 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001652 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001653 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1654 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001655 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001656 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001657 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1658 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001660 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001661 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001662 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1663 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001664} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665
1666
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001667let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001668 def XOR8rr : I<0x30, MRMDestReg,
1669 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1670 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001671 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1672 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001673 def XOR16rr : I<0x31, MRMDestReg,
1674 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1675 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001676 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1677 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001678 def XOR32rr : I<0x31, MRMDestReg,
1679 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1680 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001681 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1682 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001683} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684
1685def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001686 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001687 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001688 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1689 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001690def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001691 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001692 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001693 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1694 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001695 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001696def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001697 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001698 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001699 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1700 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001702def XOR8ri : Ii8<0x80, MRM6r,
1703 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1704 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001705 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1706 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001707def XOR16ri : Ii16<0x81, MRM6r,
1708 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1709 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001710 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1711 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001712def XOR32ri : Ii32<0x81, MRM6r,
1713 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1714 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001715 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1716 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001717def XOR16ri8 : Ii8<0x83, MRM6r,
1718 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1719 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001720 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1721 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001722 OpSize;
1723def XOR32ri8 : Ii8<0x83, MRM6r,
1724 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1725 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001726 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1727 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001728
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001729let isTwoAddress = 0 in {
1730 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001731 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001732 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001733 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1734 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001735 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001736 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001737 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001738 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1739 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740 OpSize;
1741 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001742 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001743 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001744 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1745 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001746 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001747 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001748 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001749 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1750 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001751 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001752 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001753 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001754 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1755 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001756 OpSize;
1757 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001758 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001760 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1761 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001763 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001765 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1766 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001767 OpSize;
1768 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001769 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001770 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001771 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1772 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001773} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001774} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775
1776// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001777let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001778let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001779def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001780 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001781 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001782def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001783 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001784 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001785def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001786 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001787 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001788} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001789
Evan Chengb783fa32007-07-19 01:14:50 +00001790def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001791 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1793let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001794def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001797def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001798 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001800// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1801// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001802} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803
1804let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001805 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001806 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001807 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001808 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001809 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001810 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001811 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001812 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001813 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001814 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1815 }
Evan Chengb783fa32007-07-19 01:14:50 +00001816 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001817 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001818 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001819 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1822 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001823 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001824 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001825 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1826
1827 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001828 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001831 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1834 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001835 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1838}
1839
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001840let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001841def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001842 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001843 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001844def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001845 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001846 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001847def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001848 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001849 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1850}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001851
Evan Chengb783fa32007-07-19 01:14:50 +00001852def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001853 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001855def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001856 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001858def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1861
1862// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001863def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001864 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001865 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001866def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001868 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001869def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001870 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1872
1873let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001874 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001875 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001876 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001877 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001878 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001879 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001880 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001881 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001882 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001883 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001884 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1885 }
Evan Chengb783fa32007-07-19 01:14:50 +00001886 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001889 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1892 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001893 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1896
1897 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001898 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001900 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001901 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001904 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001905 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001906 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1907}
1908
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001909let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001910def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001911 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001912 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001913def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001914 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001915 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001916def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001917 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001918 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1919}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001920
Evan Chengb783fa32007-07-19 01:14:50 +00001921def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001924def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1927 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001928def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001930 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1931
1932// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001933def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001935 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001936def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001937 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001938 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001939def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001941 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1942
1943let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001944 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001945 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001946 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001947 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001948 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001949 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001950 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001951 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001952 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001953 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1954 }
Evan Chengb783fa32007-07-19 01:14:50 +00001955 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001956 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001957 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001958 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1961 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001962 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001963 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1965
1966 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001967 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001970 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001971 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1973 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001974 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1977}
1978
1979// Rotate instructions
1980// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001981let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001982def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001983 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001984 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001985def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001986 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001987 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001988def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001989 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001990 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1991}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992
Evan Chengb783fa32007-07-19 01:14:50 +00001993def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001994 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001995 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001996def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001997 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001998 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001999def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2002
2003// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002004def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002005 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002006 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002007def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002010def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002011 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002012 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2013
2014let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002015 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002016 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002017 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002018 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002019 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002020 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002021 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002022 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002023 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002024 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2025 }
Evan Chengb783fa32007-07-19 01:14:50 +00002026 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002029 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002030 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002031 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2032 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002033 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002034 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002035 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2036
2037 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002038 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002039 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002040 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002041 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002042 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002043 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2044 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002045 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2048}
2049
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002050let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002051def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002052 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002053 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002054def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002055 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002056 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002057def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002058 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002059 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2060}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061
Evan Chengb783fa32007-07-19 01:14:50 +00002062def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002063 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002064 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002065def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002068def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2071
2072// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002073def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002074 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002075 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002076def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002077 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002079def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2082
2083let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002084 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002085 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002086 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002087 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002088 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002089 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002090 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002091 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002092 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002093 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2094 }
Evan Chengb783fa32007-07-19 01:14:50 +00002095 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002096 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002097 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002098 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002099 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002100 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2101 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002102 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002103 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2105
2106 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002107 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002108 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002110 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2113 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002114 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002115 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002116 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2117}
2118
2119
2120
2121// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002122let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002123def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002124 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002125 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002126def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002127 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002128 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002129def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002130 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002131 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002132 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002133def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002134 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002135 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002136 TB, OpSize;
2137}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138
2139let isCommutable = 1 in { // These instructions commute to each other.
2140def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002141 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002143 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2144 (i8 imm:$src3)))]>,
2145 TB;
2146def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002147 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002148 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002149 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2150 (i8 imm:$src3)))]>,
2151 TB;
2152def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002153 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2156 (i8 imm:$src3)))]>,
2157 TB, OpSize;
2158def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002159 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002160 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002161 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2162 (i8 imm:$src3)))]>,
2163 TB, OpSize;
2164}
2165
2166let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002167 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002168 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002169 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002170 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002171 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002172 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002173 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002175 addr:$dst)]>, TB;
2176 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002177 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002178 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002179 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002180 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2181 (i8 imm:$src3)), addr:$dst)]>,
2182 TB;
2183 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002184 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2187 (i8 imm:$src3)), addr:$dst)]>,
2188 TB;
2189
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002190 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002191 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002192 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002194 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002195 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002196 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002197 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002198 addr:$dst)]>, TB, OpSize;
2199 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002200 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002201 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002202 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002203 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2204 (i8 imm:$src3)), addr:$dst)]>,
2205 TB, OpSize;
2206 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002207 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002208 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002209 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2210 (i8 imm:$src3)), addr:$dst)]>,
2211 TB, OpSize;
2212}
Evan Cheng55687072007-09-14 21:48:26 +00002213} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214
2215
2216// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002217let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002218let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002219// Register-Register Addition
2220def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2221 (ins GR8 :$src1, GR8 :$src2),
2222 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002223 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002224 (implicit EFLAGS)]>;
2225
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002227// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002228def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2229 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002231 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2232 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002233def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2234 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002235 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002236 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2237 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002238} // end isConvertibleToThreeAddress
2239} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002240
2241// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002242def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2243 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002244 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002245 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2246 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002247def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2248 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002249 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002250 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2251 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002252def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2253 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002254 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002255 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2256 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257
Bill Wendlingae034ed2008-12-12 00:56:36 +00002258// Register-Integer Addition
2259def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2260 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002261 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2262 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002263
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002264let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002265// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002266def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2267 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002268 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002269 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2270 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002271def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2272 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002273 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002274 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2275 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002276def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2277 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002278 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002279 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2280 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002281def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2282 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002283 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002284 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2285 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002286}
2287
2288let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002289 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002290 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002291 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002292 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2293 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002294 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002295 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002296 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2297 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002298 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002299 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002300 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2301 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002302 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002303 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002304 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2305 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002306 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002307 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002308 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2309 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002310 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002311 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002312 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2313 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002314 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002315 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002316 [(store (add (load addr:$dst), i16immSExt8:$src2),
2317 addr:$dst),
2318 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002319 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002320 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002321 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002322 addr:$dst),
2323 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002324}
2325
Evan Cheng259471d2007-10-05 17:59:57 +00002326let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002328def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002329 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002330 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002331def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2332 (ins GR16:$src1, GR16:$src2),
2333 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002334 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002335def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2336 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002337 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002338 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002339}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002340def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2341 (ins GR8:$src1, i8mem:$src2),
2342 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002343 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002344def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2345 (ins GR16:$src1, i16mem:$src2),
2346 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002347 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002348 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002349def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2350 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002351 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002352 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2353def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002354 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002355 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002356def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2357 (ins GR16:$src1, i16imm:$src2),
2358 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002359 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002360def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2361 (ins GR16:$src1, i16i8imm:$src2),
2362 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002363 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2364 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002365def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2366 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002367 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002368 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002369def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2370 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002372 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002373
2374let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002375 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002376 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002377 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2378 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002379 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002380 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2381 OpSize;
2382 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002383 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002384 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2385 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002386 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002387 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2388 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002389 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002390 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2391 OpSize;
2392 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002393 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002394 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2395 OpSize;
2396 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002397 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002398 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2399 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002400 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002401 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2402}
Evan Cheng259471d2007-10-05 17:59:57 +00002403} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002404
Bill Wendlingae034ed2008-12-12 00:56:36 +00002405// Register-Register Subtraction
2406def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2407 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002408 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2409 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002410def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2411 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002412 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2413 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002414def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2415 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002416 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2417 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002418
2419// Register-Memory Subtraction
2420def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2421 (ins GR8 :$src1, i8mem :$src2),
2422 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002423 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2424 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002425def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2426 (ins GR16:$src1, i16mem:$src2),
2427 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002428 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2429 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002430def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2431 (ins GR32:$src1, i32mem:$src2),
2432 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002433 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2434 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002435
2436// Register-Integer Subtraction
2437def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2438 (ins GR8:$src1, i8imm:$src2),
2439 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002440 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2441 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002442def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2443 (ins GR16:$src1, i16imm:$src2),
2444 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002445 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2446 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002447def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2448 (ins GR32:$src1, i32imm:$src2),
2449 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002450 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2451 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002452def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2453 (ins GR16:$src1, i16i8imm:$src2),
2454 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002455 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2456 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002457def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2458 (ins GR32:$src1, i32i8imm:$src2),
2459 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002460 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2461 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002462
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002463let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002464 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002465 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002466 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002467 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2468 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002469 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002470 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002471 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2472 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002473 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002474 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002475 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2476 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002477
2478 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002479 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002480 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002481 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2482 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002483 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002484 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002485 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2486 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002487 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002488 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002489 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2490 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002491 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002492 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002493 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002494 addr:$dst),
2495 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002496 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002497 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002498 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002499 addr:$dst),
2500 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002501}
2502
Evan Cheng259471d2007-10-05 17:59:57 +00002503let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002504def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2505 (ins GR8:$src1, GR8:$src2),
2506 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002507 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002508def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2509 (ins GR16:$src1, GR16:$src2),
2510 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002511 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002512def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2513 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002514 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002515 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002516
2517let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002518 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2519 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002520 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002521 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2522 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002523 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002524 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002525 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002526 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002527 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002528 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002529 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002530 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002531 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2532 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002533 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002534 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002535 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2536 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002537 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002538 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002539 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002540 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002541 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002542 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002543 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002544 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002545}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002546def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2547 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002548 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002549def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2550 (ins GR16:$src1, i16mem:$src2),
2551 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002552 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002553 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002554def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2555 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002556 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002557 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002558def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2559 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002560 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002561def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2562 (ins GR16:$src1, i16imm:$src2),
2563 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002564 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002565def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2566 (ins GR16:$src1, i16i8imm:$src2),
2567 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002568 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2569 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002570def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2571 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002572 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002573 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002574def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2575 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002576 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002577 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002578} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002579} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002580
Evan Cheng55687072007-09-14 21:48:26 +00002581let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002582let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002583// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002584def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002585 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002586 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2587 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002588def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002589 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002590 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2591 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002592}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002593
Bill Wendlingf5399032008-12-12 21:15:41 +00002594// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002595def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2596 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002597 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002598 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2599 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002600def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002601 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002602 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2603 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002604} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002605} // end Two Address instructions
2606
2607// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002608let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002609// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002610def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002611 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002612 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002613 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2614 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002615def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002616 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002617 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002618 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2619 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002620def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002621 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002622 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002623 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2624 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002625def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002626 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002627 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002628 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2629 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002630
Bill Wendlingf5399032008-12-12 21:15:41 +00002631// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002632def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002633 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002634 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002635 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2636 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002637def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002638 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002639 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002640 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2641 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002642def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002643 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002644 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002645 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002646 i16immSExt8:$src2)),
2647 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002648def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002649 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002650 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002651 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002652 i32immSExt8:$src2)),
2653 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002654} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002655
2656//===----------------------------------------------------------------------===//
2657// Test instructions are just like AND, except they don't generate a result.
2658//
Evan Cheng950aac02007-09-25 01:57:46 +00002659let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002660let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002661def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002662 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002663 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002664 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002665def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002666 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002667 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002668 (implicit EFLAGS)]>,
2669 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002670def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002671 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002672 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002673 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002674}
2675
Evan Chengb783fa32007-07-19 01:14:50 +00002676def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002677 "test{b}\t{$src2, $src1|$src1, $src2}",
2678 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2679 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002680def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002681 "test{w}\t{$src2, $src1|$src1, $src2}",
2682 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2683 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002684def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002685 "test{l}\t{$src2, $src1|$src1, $src2}",
2686 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2687 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002688
2689def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002690 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002691 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002692 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002693 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002694def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002695 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002696 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002697 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002698 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002699def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002700 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002701 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002702 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002703 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002704
Evan Cheng621216e2007-09-29 00:00:36 +00002705def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002706 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002707 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002708 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2709 (implicit EFLAGS)]>;
2710def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002711 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002712 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002713 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2714 (implicit EFLAGS)]>, OpSize;
2715def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002716 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002717 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002718 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002719 (implicit EFLAGS)]>;
2720} // Defs = [EFLAGS]
2721
2722
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002723// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002724let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002725def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002726let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002727def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002728
Evan Cheng950aac02007-09-25 01:57:46 +00002729let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002730def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002731 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002732 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002733 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002734 TB; // GR8 = ==
2735def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002736 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002737 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002738 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002739 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002740
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002741def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002742 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002743 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002744 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002745 TB; // GR8 = !=
2746def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002747 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002748 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002749 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002750 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002751
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002752def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002753 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002754 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002755 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002756 TB; // GR8 = < signed
2757def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002758 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002759 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002760 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002761 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002762
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002763def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002764 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002765 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002766 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002767 TB; // GR8 = >= signed
2768def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002769 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002770 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002771 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002772 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002773
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002774def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002775 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002776 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002777 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002778 TB; // GR8 = <= signed
2779def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002780 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002781 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002782 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002783 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002784
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002785def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002786 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002787 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002788 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002789 TB; // GR8 = > signed
2790def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002791 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002792 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002793 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002794 TB; // [mem8] = > signed
2795
2796def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002797 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002798 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002799 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002800 TB; // GR8 = < unsign
2801def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002802 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002803 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002804 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002805 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002806
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002807def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002808 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002809 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002810 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002811 TB; // GR8 = >= unsign
2812def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002813 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002814 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002815 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002816 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002817
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002818def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002819 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002820 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002821 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002822 TB; // GR8 = <= unsign
2823def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002824 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002825 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002826 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002827 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002828
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002829def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002830 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002831 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002832 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002833 TB; // GR8 = > signed
2834def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002835 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002836 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002837 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002838 TB; // [mem8] = > signed
2839
2840def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002841 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002842 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002843 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002844 TB; // GR8 = <sign bit>
2845def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002846 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002847 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002848 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002849 TB; // [mem8] = <sign bit>
2850def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002851 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002852 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002853 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854 TB; // GR8 = !<sign bit>
2855def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002856 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002857 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002858 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002859 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002860
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002861def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002862 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002863 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002864 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002865 TB; // GR8 = parity
2866def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002867 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002868 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002869 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002870 TB; // [mem8] = parity
2871def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002872 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002873 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002874 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002875 TB; // GR8 = not parity
2876def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002877 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002878 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002879 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002880 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002881
2882def SETOr : I<0x90, MRM0r,
2883 (outs GR8 :$dst), (ins),
2884 "seto\t$dst",
2885 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2886 TB; // GR8 = overflow
2887def SETOm : I<0x90, MRM0m,
2888 (outs), (ins i8mem:$dst),
2889 "seto\t$dst",
2890 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2891 TB; // [mem8] = overflow
2892def SETNOr : I<0x91, MRM0r,
2893 (outs GR8 :$dst), (ins),
2894 "setno\t$dst",
2895 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2896 TB; // GR8 = not overflow
2897def SETNOm : I<0x91, MRM0m,
2898 (outs), (ins i8mem:$dst),
2899 "setno\t$dst",
2900 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2901 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002902} // Uses = [EFLAGS]
2903
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002904
2905// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002906let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002907def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002908 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002909 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002910 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002911def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002912 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002913 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002914 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002915def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002916 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002917 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002918 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002919def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002920 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002921 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002922 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2923 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002924def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002925 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002926 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002927 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2928 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002929def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002930 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002931 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002932 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2933 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002934def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002935 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002936 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002937 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2938 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002939def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002940 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002941 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002942 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2943 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002944def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002945 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002946 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002947 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2948 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002949def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002950 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002951 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002952 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002953def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002954 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002955 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002956 [(X86cmp GR16:$src1, imm:$src2),
2957 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002958def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002959 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002960 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002961 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002962def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002963 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002964 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002965 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2966 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002967def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002968 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002969 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002970 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2971 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002972def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002973 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002974 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002975 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2976 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002977def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002978 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002979 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002980 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2981 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002982def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002983 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002984 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002985 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2986 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002987def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002988 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002989 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002990 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2991 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002992def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002993 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002994 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002995 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002996 (implicit EFLAGS)]>;
2997} // Defs = [EFLAGS]
2998
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002999// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003000// TODO: BTC, BTR, and BTS
3001let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003002def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003003 "bt{w}\t{$src2, $src1|$src1, $src2}",
3004 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003005 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003006def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003007 "bt{l}\t{$src2, $src1|$src1, $src2}",
3008 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003009 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003010
3011// Unlike with the register+register form, the memory+register form of the
3012// bt instruction does not ignore the high bits of the index. From ISel's
3013// perspective, this is pretty bizarre. Disable these instructions for now.
3014//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3015// "bt{w}\t{$src2, $src1|$src1, $src2}",
3016// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3017// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3018//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3019// "bt{l}\t{$src2, $src1|$src1, $src2}",
3020// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3021// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003022
3023def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3024 "bt{w}\t{$src2, $src1|$src1, $src2}",
3025 [(X86bt GR16:$src1, i16immSExt8:$src2),
3026 (implicit EFLAGS)]>, OpSize, TB;
3027def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3028 "bt{l}\t{$src2, $src1|$src1, $src2}",
3029 [(X86bt GR32:$src1, i32immSExt8:$src2),
3030 (implicit EFLAGS)]>, TB;
3031// Note that these instructions don't need FastBTMem because that
3032// only applies when the other operand is in a register. When it's
3033// an immediate, bt is still fast.
3034def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3035 "bt{w}\t{$src2, $src1|$src1, $src2}",
3036 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3037 (implicit EFLAGS)]>, OpSize, TB;
3038def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3039 "bt{l}\t{$src2, $src1|$src1, $src2}",
3040 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3041 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003042} // Defs = [EFLAGS]
3043
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003044// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003045// Use movsbl intead of movsbw; we don't care about the high 16 bits
3046// of the register here. This has a smaller encoding and avoids a
3047// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003048def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003049 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3050 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003051def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003052 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3053 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003054def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003055 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003056 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003057def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003058 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003059 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003060def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003061 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003062 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003063def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003064 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003065 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3066
Dan Gohman9203ab42008-07-30 18:09:17 +00003067// Use movzbl intead of movzbw; we don't care about the high 16 bits
3068// of the register here. This has a smaller encoding and avoids a
3069// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003070def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003071 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3072 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003073def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003074 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3075 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003076def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003077 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003078 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003079def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003080 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003081 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003082def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003083 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003084 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003085def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003086 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003087 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3088
Dan Gohman744d4622009-04-13 16:09:41 +00003089// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3090// except that they use GR32_NOREX for the output operand register class
3091// instead of GR32. This allows them to operate on h registers on x86-64.
3092def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3093 (outs GR32_NOREX:$dst), (ins GR8:$src),
3094 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3095 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003096let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003097def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3098 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3099 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3100 []>, TB;
3101
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003102let neverHasSideEffects = 1 in {
3103 let Defs = [AX], Uses = [AL] in
3104 def CBW : I<0x98, RawFrm, (outs), (ins),
3105 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3106 let Defs = [EAX], Uses = [AX] in
3107 def CWDE : I<0x98, RawFrm, (outs), (ins),
3108 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003110 let Defs = [AX,DX], Uses = [AX] in
3111 def CWD : I<0x99, RawFrm, (outs), (ins),
3112 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3113 let Defs = [EAX,EDX], Uses = [EAX] in
3114 def CDQ : I<0x99, RawFrm, (outs), (ins),
3115 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3116}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003117
3118//===----------------------------------------------------------------------===//
3119// Alias Instructions
3120//===----------------------------------------------------------------------===//
3121
3122// Alias instructions that map movr0 to xor.
3123// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00003124let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003125def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003126 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003127 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003128// Use xorl instead of xorw since we don't care about the high 16 bits,
3129// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003130def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003131 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3132 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003133def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003134 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003135 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003136}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003137
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003138//===----------------------------------------------------------------------===//
3139// Thread Local Storage Instructions
3140//
3141
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003142// All calls clobber the non-callee saved registers. ESP is marked as
3143// a use to prevent stack-pointer assignments that appear immediately
3144// before calls from potentially appearing dead.
3145let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3146 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3147 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3148 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003149 Uses = [ESP] in
3150def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3151 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003152 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003153 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003154 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003155
sampo9cc09a32009-01-26 01:24:32 +00003156let AddedComplexity = 5 in
3157def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3158 "movl\t%gs:$src, $dst",
3159 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3160
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003161let AddedComplexity = 5 in
3162def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3163 "movl\t%fs:$src, $dst",
3164 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3165
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003166//===----------------------------------------------------------------------===//
3167// DWARF Pseudo Instructions
3168//
3169
Evan Chengb783fa32007-07-19 01:14:50 +00003170def DWARF_LOC : I<0, Pseudo, (outs),
3171 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Chris Lattner64b54552009-07-10 22:34:11 +00003172 ".loc\t$file $line $col",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003173 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3174 (i32 imm:$file))]>;
3175
3176//===----------------------------------------------------------------------===//
3177// EH Pseudo Instructions
3178//
3179let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003180 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003181def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003182 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003183 [(X86ehret GR32:$addr)]>;
3184
3185}
3186
3187//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003188// Atomic support
3189//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003190
Evan Cheng3e171562008-04-19 01:20:30 +00003191// Atomic swap. These are just normal xchg instructions. But since a memory
3192// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003193let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003194def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3195 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3196 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3197def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3198 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3199 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3200 OpSize;
3201def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3202 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3203 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3204}
3205
Evan Chengd49dbb82008-04-18 20:55:36 +00003206// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003207let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003208def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003209 "lock\n\t"
3210 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003211 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003212}
Dale Johannesenf160d802008-10-02 18:53:47 +00003213let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003214def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003215 "lock\n\t"
3216 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003217 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3218}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003219
3220let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003221def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003222 "lock\n\t"
3223 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003224 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003225}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003226let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003227def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003228 "lock\n\t"
3229 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003230 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003231}
3232
Evan Chengd49dbb82008-04-18 20:55:36 +00003233// Atomic exchange and add
3234let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3235def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003236 "lock\n\t"
3237 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003238 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003239 TB, LOCK;
3240def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003241 "lock\n\t"
3242 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003243 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003244 TB, OpSize, LOCK;
3245def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003246 "lock\n\t"
3247 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003248 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003249 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003250}
3251
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003252// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003253let Constraints = "$val = $dst", Defs = [EFLAGS],
3254 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003255def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003256 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003257 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003258def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003259 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003260 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003261def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003262 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003263 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003264def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003265 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003266 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003267def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003268 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003269 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003270def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003271 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003272 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003273def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003274 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003275 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003276def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003277 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003278 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003279
3280def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003281 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003282 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003283def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003284 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003285 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003286def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003287 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003288 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003289def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003290 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003291 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003292def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003293 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003294 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003295def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003296 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003297 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003298def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003299 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003300 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003301def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003302 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003303 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003304
3305def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003306 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003307 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003308def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003309 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003310 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003311def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003312 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003313 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003314def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003315 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003316 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003317}
3318
Dale Johannesenf160d802008-10-02 18:53:47 +00003319let Constraints = "$val1 = $dst1, $val2 = $dst2",
3320 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3321 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003322 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003323 usesCustomDAGSchedInserter = 1 in {
3324def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3325 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003326 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003327def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3328 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003329 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003330def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3331 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003332 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003333def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3334 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003335 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003336def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3337 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003338 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003339def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3340 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003341 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003342def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3343 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003344 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003345}
3346
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003347//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003348// Non-Instruction Patterns
3349//===----------------------------------------------------------------------===//
3350
Bill Wendlingfef06052008-09-16 21:48:12 +00003351// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003352def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3353def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003354def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003355def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3356def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3357
3358def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3359 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3360def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3361 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3362def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3363 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3364def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3365 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3366
3367def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3368 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3369def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3370 (MOV32mi addr:$dst, texternalsym:$src)>;
3371
3372// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003373// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003374def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003375 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003376
3377def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003378 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003379def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003380 (TAILCALL)>;
3381
3382def : Pat<(X86tcret GR32:$dst, imm:$off),
3383 (TCRETURNri GR32:$dst, imm:$off)>;
3384
3385def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3386 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3387
3388def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3389 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003390
3391def : Pat<(X86call (i32 tglobaladdr:$dst)),
3392 (CALLpcrel32 tglobaladdr:$dst)>;
3393def : Pat<(X86call (i32 texternalsym:$dst)),
3394 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003395def : Pat<(X86call (i32 imm:$dst)),
3396 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003397
3398// X86 specific add which produces a flag.
3399def : Pat<(addc GR32:$src1, GR32:$src2),
3400 (ADD32rr GR32:$src1, GR32:$src2)>;
3401def : Pat<(addc GR32:$src1, (load addr:$src2)),
3402 (ADD32rm GR32:$src1, addr:$src2)>;
3403def : Pat<(addc GR32:$src1, imm:$src2),
3404 (ADD32ri GR32:$src1, imm:$src2)>;
3405def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3406 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3407
3408def : Pat<(subc GR32:$src1, GR32:$src2),
3409 (SUB32rr GR32:$src1, GR32:$src2)>;
3410def : Pat<(subc GR32:$src1, (load addr:$src2)),
3411 (SUB32rm GR32:$src1, addr:$src2)>;
3412def : Pat<(subc GR32:$src1, imm:$src2),
3413 (SUB32ri GR32:$src1, imm:$src2)>;
3414def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3415 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3416
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003417// Comparisons.
3418
3419// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003420def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003421 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003422def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003423 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003424def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003425 (TEST32rr GR32:$src1, GR32:$src1)>;
3426
Dan Gohman0a3c5222009-01-07 01:00:24 +00003427// Conditional moves with folded loads with operands swapped and conditions
3428// inverted.
3429def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3430 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3431def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3432 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3433def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3434 (CMOVB16rm GR16:$src2, addr:$src1)>;
3435def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3436 (CMOVB32rm GR32:$src2, addr:$src1)>;
3437def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3438 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3439def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3440 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3441def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3442 (CMOVE16rm GR16:$src2, addr:$src1)>;
3443def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3444 (CMOVE32rm GR32:$src2, addr:$src1)>;
3445def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3446 (CMOVA16rm GR16:$src2, addr:$src1)>;
3447def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3448 (CMOVA32rm GR32:$src2, addr:$src1)>;
3449def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3450 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3451def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3452 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3453def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3454 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3455def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3456 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3457def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3458 (CMOVL16rm GR16:$src2, addr:$src1)>;
3459def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3460 (CMOVL32rm GR32:$src2, addr:$src1)>;
3461def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3462 (CMOVG16rm GR16:$src2, addr:$src1)>;
3463def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3464 (CMOVG32rm GR32:$src2, addr:$src1)>;
3465def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3466 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3467def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3468 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3469def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3470 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3471def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3472 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3473def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3474 (CMOVP16rm GR16:$src2, addr:$src1)>;
3475def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3476 (CMOVP32rm GR32:$src2, addr:$src1)>;
3477def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3478 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3479def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3480 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3481def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3482 (CMOVS16rm GR16:$src2, addr:$src1)>;
3483def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3484 (CMOVS32rm GR32:$src2, addr:$src1)>;
3485def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3486 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3487def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3488 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3489def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3490 (CMOVO16rm GR16:$src2, addr:$src1)>;
3491def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3492 (CMOVO32rm GR32:$src2, addr:$src1)>;
3493
Duncan Sands082524c2008-01-23 20:39:46 +00003494// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003495def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3496def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3497def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3498
3499// extload bool -> extload byte
3500def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003501def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3502 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003503def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003504def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3505 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003506def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3507def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3508
Dan Gohmandd612bb2008-08-20 21:27:32 +00003509// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003510def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3511 Requires<[In32BitMode]>;
3512def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3513 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003514def : Pat<(i32 (anyext GR16:$src)),
3515 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003516
Evan Chengf2abee72007-12-13 00:43:27 +00003517// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003518def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3519 (MOVZX32rm8 addr:$src)>;
3520def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3521 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003522
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003523//===----------------------------------------------------------------------===//
3524// Some peepholes
3525//===----------------------------------------------------------------------===//
3526
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003527// Odd encoding trick: -128 fits into an 8-bit immediate field while
3528// +128 doesn't, so in this special case use a sub instead of an add.
3529def : Pat<(add GR16:$src1, 128),
3530 (SUB16ri8 GR16:$src1, -128)>;
3531def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3532 (SUB16mi8 addr:$dst, -128)>;
3533def : Pat<(add GR32:$src1, 128),
3534 (SUB32ri8 GR32:$src1, -128)>;
3535def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3536 (SUB32mi8 addr:$dst, -128)>;
3537
Dan Gohman9203ab42008-07-30 18:09:17 +00003538// r & (2^16-1) ==> movz
3539def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003540 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003541// r & (2^8-1) ==> movz
3542def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003543 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003544 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003545 Requires<[In32BitMode]>;
3546// r & (2^8-1) ==> movz
3547def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003548 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003549 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003550 Requires<[In32BitMode]>;
3551
3552// sext_inreg patterns
3553def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003554 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003555def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003556 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003557 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003558 Requires<[In32BitMode]>;
3559def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003560 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003561 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003562 Requires<[In32BitMode]>;
3563
3564// trunc patterns
3565def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003566 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003567def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003568 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003569 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003570 Requires<[In32BitMode]>;
3571def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003572 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003573 x86_subreg_8bit)>,
3574 Requires<[In32BitMode]>;
3575
3576// h-register tricks
3577def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003578 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003579 x86_subreg_8bit_hi)>,
3580 Requires<[In32BitMode]>;
3581def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003582 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003583 x86_subreg_8bit_hi)>,
3584 Requires<[In32BitMode]>;
3585def : Pat<(srl_su GR16:$src, (i8 8)),
3586 (EXTRACT_SUBREG
3587 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003588 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003589 x86_subreg_8bit_hi)),
3590 x86_subreg_16bit)>,
3591 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003592def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3593 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3594 x86_subreg_8bit_hi))>,
3595 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003596def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003597 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003598 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003599 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003600
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003601// (shl x, 1) ==> (add x, x)
3602def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3603def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3604def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3605
Evan Cheng76a64c72008-08-30 02:03:58 +00003606// (shl x (and y, 31)) ==> (shl x, y)
3607def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3608 (SHL8rCL GR8:$src1)>;
3609def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3610 (SHL16rCL GR16:$src1)>;
3611def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3612 (SHL32rCL GR32:$src1)>;
3613def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3614 (SHL8mCL addr:$dst)>;
3615def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3616 (SHL16mCL addr:$dst)>;
3617def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3618 (SHL32mCL addr:$dst)>;
3619
3620def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3621 (SHR8rCL GR8:$src1)>;
3622def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3623 (SHR16rCL GR16:$src1)>;
3624def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3625 (SHR32rCL GR32:$src1)>;
3626def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3627 (SHR8mCL addr:$dst)>;
3628def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3629 (SHR16mCL addr:$dst)>;
3630def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3631 (SHR32mCL addr:$dst)>;
3632
3633def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3634 (SAR8rCL GR8:$src1)>;
3635def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3636 (SAR16rCL GR16:$src1)>;
3637def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3638 (SAR32rCL GR32:$src1)>;
3639def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3640 (SAR8mCL addr:$dst)>;
3641def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3642 (SAR16mCL addr:$dst)>;
3643def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3644 (SAR32mCL addr:$dst)>;
3645
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003646// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3647def : Pat<(or (srl GR32:$src1, CL:$amt),
3648 (shl GR32:$src2, (sub 32, CL:$amt))),
3649 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3650
3651def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3652 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3653 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3654
Dan Gohman921581d2008-10-17 01:23:35 +00003655def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3656 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3657 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3658
3659def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3660 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3661 addr:$dst),
3662 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3663
3664def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3665 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3666
3667def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3668 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3669 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3670
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003671// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3672def : Pat<(or (shl GR32:$src1, CL:$amt),
3673 (srl GR32:$src2, (sub 32, CL:$amt))),
3674 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3675
3676def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3677 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3678 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3679
Dan Gohman921581d2008-10-17 01:23:35 +00003680def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3681 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3682 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3683
3684def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3685 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3686 addr:$dst),
3687 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3688
3689def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3690 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3691
3692def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3693 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3694 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3695
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003696// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3697def : Pat<(or (srl GR16:$src1, CL:$amt),
3698 (shl GR16:$src2, (sub 16, CL:$amt))),
3699 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3700
3701def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3702 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3703 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3704
Dan Gohman921581d2008-10-17 01:23:35 +00003705def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3706 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3707 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3708
3709def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3710 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3711 addr:$dst),
3712 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3713
3714def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3715 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3716
3717def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3718 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3719 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3720
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003721// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3722def : Pat<(or (shl GR16:$src1, CL:$amt),
3723 (srl GR16:$src2, (sub 16, CL:$amt))),
3724 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3725
3726def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3727 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3728 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3729
Dan Gohman921581d2008-10-17 01:23:35 +00003730def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3731 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3732 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3733
3734def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3735 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3736 addr:$dst),
3737 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3738
3739def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3740 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3741
3742def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3743 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3744 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3745
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003746//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003747// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003748//===----------------------------------------------------------------------===//
3749
Dan Gohman99a12192009-03-04 19:44:21 +00003750// Register-Register Addition with EFLAGS result
3751def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003752 (implicit EFLAGS)),
3753 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003754def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003755 (implicit EFLAGS)),
3756 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003757def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003758 (implicit EFLAGS)),
3759 (ADD32rr GR32:$src1, GR32:$src2)>;
3760
Dan Gohman99a12192009-03-04 19:44:21 +00003761// Register-Memory Addition with EFLAGS result
3762def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003763 (implicit EFLAGS)),
3764 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003765def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003766 (implicit EFLAGS)),
3767 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003768def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003769 (implicit EFLAGS)),
3770 (ADD32rm GR32:$src1, addr:$src2)>;
3771
Dan Gohman99a12192009-03-04 19:44:21 +00003772// Register-Integer Addition with EFLAGS result
3773def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003774 (implicit EFLAGS)),
3775 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003776def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003777 (implicit EFLAGS)),
3778 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003779def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003780 (implicit EFLAGS)),
3781 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003782def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003783 (implicit EFLAGS)),
3784 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003785def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003786 (implicit EFLAGS)),
3787 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3788
Dan Gohman99a12192009-03-04 19:44:21 +00003789// Memory-Register Addition with EFLAGS result
3790def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003791 addr:$dst),
3792 (implicit EFLAGS)),
3793 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003794def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003795 addr:$dst),
3796 (implicit EFLAGS)),
3797 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003798def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003799 addr:$dst),
3800 (implicit EFLAGS)),
3801 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003802
3803// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003804def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003805 addr:$dst),
3806 (implicit EFLAGS)),
3807 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003808def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003809 addr:$dst),
3810 (implicit EFLAGS)),
3811 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003812def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003813 addr:$dst),
3814 (implicit EFLAGS)),
3815 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003816def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003817 addr:$dst),
3818 (implicit EFLAGS)),
3819 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003820def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003821 addr:$dst),
3822 (implicit EFLAGS)),
3823 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3824
Dan Gohman99a12192009-03-04 19:44:21 +00003825// Register-Register Subtraction with EFLAGS result
3826def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003827 (implicit EFLAGS)),
3828 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003829def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003830 (implicit EFLAGS)),
3831 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003832def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003833 (implicit EFLAGS)),
3834 (SUB32rr GR32:$src1, GR32:$src2)>;
3835
Dan Gohman99a12192009-03-04 19:44:21 +00003836// Register-Memory Subtraction with EFLAGS result
3837def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003838 (implicit EFLAGS)),
3839 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003840def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003841 (implicit EFLAGS)),
3842 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003843def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003844 (implicit EFLAGS)),
3845 (SUB32rm GR32:$src1, addr:$src2)>;
3846
Dan Gohman99a12192009-03-04 19:44:21 +00003847// Register-Integer Subtraction with EFLAGS result
3848def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003849 (implicit EFLAGS)),
3850 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003851def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003852 (implicit EFLAGS)),
3853 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003854def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003855 (implicit EFLAGS)),
3856 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003857def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003858 (implicit EFLAGS)),
3859 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003860def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003861 (implicit EFLAGS)),
3862 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3863
Dan Gohman99a12192009-03-04 19:44:21 +00003864// Memory-Register Subtraction with EFLAGS result
3865def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003866 addr:$dst),
3867 (implicit EFLAGS)),
3868 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003869def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003870 addr:$dst),
3871 (implicit EFLAGS)),
3872 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003873def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003874 addr:$dst),
3875 (implicit EFLAGS)),
3876 (SUB32mr addr:$dst, GR32:$src2)>;
3877
Dan Gohman99a12192009-03-04 19:44:21 +00003878// Memory-Integer Subtraction with EFLAGS result
3879def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003880 addr:$dst),
3881 (implicit EFLAGS)),
3882 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003883def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003884 addr:$dst),
3885 (implicit EFLAGS)),
3886 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003887def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003888 addr:$dst),
3889 (implicit EFLAGS)),
3890 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003891def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003892 addr:$dst),
3893 (implicit EFLAGS)),
3894 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003895def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003896 addr:$dst),
3897 (implicit EFLAGS)),
3898 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3899
3900
Dan Gohman99a12192009-03-04 19:44:21 +00003901// Register-Register Signed Integer Multiply with EFLAGS result
3902def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003903 (implicit EFLAGS)),
3904 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003905def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003906 (implicit EFLAGS)),
3907 (IMUL32rr GR32:$src1, GR32:$src2)>;
3908
Dan Gohman99a12192009-03-04 19:44:21 +00003909// Register-Memory Signed Integer Multiply with EFLAGS result
3910def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003911 (implicit EFLAGS)),
3912 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003913def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003914 (implicit EFLAGS)),
3915 (IMUL32rm GR32:$src1, addr:$src2)>;
3916
Dan Gohman99a12192009-03-04 19:44:21 +00003917// Register-Integer Signed Integer Multiply with EFLAGS result
3918def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003919 (implicit EFLAGS)),
3920 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003921def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003922 (implicit EFLAGS)),
3923 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003924def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003925 (implicit EFLAGS)),
3926 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003927def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003928 (implicit EFLAGS)),
3929 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3930
Dan Gohman99a12192009-03-04 19:44:21 +00003931// Memory-Integer Signed Integer Multiply with EFLAGS result
3932def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003933 (implicit EFLAGS)),
3934 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003935def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003936 (implicit EFLAGS)),
3937 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003938def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003939 (implicit EFLAGS)),
3940 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003941def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003942 (implicit EFLAGS)),
3943 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3944
Dan Gohman99a12192009-03-04 19:44:21 +00003945// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003946let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003947def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003948 (implicit EFLAGS)),
3949 (ADD16rr GR16:$src1, GR16:$src1)>;
3950
Dan Gohman99a12192009-03-04 19:44:21 +00003951def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003952 (implicit EFLAGS)),
3953 (ADD32rr GR32:$src1, GR32:$src1)>;
3954}
3955
Dan Gohman99a12192009-03-04 19:44:21 +00003956// INC and DEC with EFLAGS result. Note that these do not set CF.
3957def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3958 (INC8r GR8:$src)>;
3959def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3960 (implicit EFLAGS)),
3961 (INC8m addr:$dst)>;
3962def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3963 (DEC8r GR8:$src)>;
3964def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3965 (implicit EFLAGS)),
3966 (DEC8m addr:$dst)>;
3967
3968def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003969 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003970def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3971 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003972 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003973def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003974 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003975def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3976 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003977 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003978
3979def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003980 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003981def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3982 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003983 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003984def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003985 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003986def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3987 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003988 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003989
Bill Wendlingf5399032008-12-12 21:15:41 +00003990//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003991// Floating Point Stack Support
3992//===----------------------------------------------------------------------===//
3993
3994include "X86InstrFPStack.td"
3995
3996//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003997// X86-64 Support
3998//===----------------------------------------------------------------------===//
3999
Chris Lattner2de8d2b2008-01-10 05:50:42 +00004000include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00004001
4002//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004003// XMM Floating point support (requires SSE / SSE2)
4004//===----------------------------------------------------------------------===//
4005
4006include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00004007
4008//===----------------------------------------------------------------------===//
4009// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4010//===----------------------------------------------------------------------===//
4011
4012include "X86InstrMMX.td"