blob: 0e40965a4c1f8b926f49ea72f6a240ff6b48b673 [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
Sean Callananf94a0542009-07-23 23:39:34 +0000492let neverHasSideEffects = 1 in {
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000493 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Sean Callananf94a0542009-07-23 23:39:34 +0000494 def NOOPL : I<0x1f, MRM0m, (outs), (ins i32mem:$zero),
495 "nopl\t$zero", []>, TB;
496}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000497
Evan Cheng0729ccf2008-01-05 00:41:47 +0000498// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000499let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000500 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman70a8a112009-04-27 15:13:28 +0000501 "call\t$label\n\t"
502 "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000503
504//===----------------------------------------------------------------------===//
505// Control Flow Instructions...
506//
507
508// Return instructions.
509let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000510 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000511 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000512 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000513 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000514 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
515 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516 [(X86retflag imm:$amt)]>;
517}
518
519// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000520let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000521 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
522 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000523
Sean Callananc0608152009-07-22 01:05:20 +0000524let isBranch = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000525 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Sean Callananc0608152009-07-22 01:05:20 +0000526 def JMP8 : IBr<0xEB, (ins brtarget8:$dst), "jmp\t$dst", []>;
527}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528
Owen Andersonf8053082007-11-12 07:39:39 +0000529// Indirect branches
530let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000531 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000533 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534 [(brind (loadi32 addr:$dst))]>;
535}
536
537// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000538let Uses = [EFLAGS] in {
Evan Chengd11052b2009-07-21 06:00:18 +0000539// Short conditional jumps
540def JO8 : IBr<0x70, (ins brtarget8:$dst), "jo\t$dst", []>;
541def JNO8 : IBr<0x71, (ins brtarget8:$dst), "jno\t$dst", []>;
542def JB8 : IBr<0x72, (ins brtarget8:$dst), "jb\t$dst", []>;
543def JAE8 : IBr<0x73, (ins brtarget8:$dst), "jae\t$dst", []>;
544def JE8 : IBr<0x74, (ins brtarget8:$dst), "je\t$dst", []>;
545def JNE8 : IBr<0x75, (ins brtarget8:$dst), "jne\t$dst", []>;
546def JBE8 : IBr<0x76, (ins brtarget8:$dst), "jbe\t$dst", []>;
547def JA8 : IBr<0x77, (ins brtarget8:$dst), "ja\t$dst", []>;
548def JS8 : IBr<0x78, (ins brtarget8:$dst), "js\t$dst", []>;
549def JNS8 : IBr<0x79, (ins brtarget8:$dst), "jns\t$dst", []>;
550def JP8 : IBr<0x7A, (ins brtarget8:$dst), "jp\t$dst", []>;
551def JNP8 : IBr<0x7B, (ins brtarget8:$dst), "jnp\t$dst", []>;
552def JL8 : IBr<0x7C, (ins brtarget8:$dst), "jl\t$dst", []>;
553def JGE8 : IBr<0x7D, (ins brtarget8:$dst), "jge\t$dst", []>;
554def JLE8 : IBr<0x7E, (ins brtarget8:$dst), "jle\t$dst", []>;
555def JG8 : IBr<0x7F, (ins brtarget8:$dst), "jg\t$dst", []>;
556
557def JCXZ8 : IBr<0xE3, (ins brtarget8:$dst), "jcxz\t$dst", []>;
558
Dan Gohman91888f02007-07-31 20:11:57 +0000559def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000560 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000561def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000562 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000563def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000564 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000565def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000566 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000567def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000568 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000569def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000570 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000571
Dan Gohman91888f02007-07-31 20:11:57 +0000572def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000573 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000574def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000575 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000576def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000577 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000578def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000579 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580
Dan Gohman91888f02007-07-31 20:11:57 +0000581def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000582 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000583def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000584 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000585def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000586 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000587def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000588 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000589def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000590 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000591def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000592 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000593} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594
595//===----------------------------------------------------------------------===//
596// Call Instructions...
597//
Evan Cheng37e7c752007-07-21 00:34:19 +0000598let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000599 // All calls clobber the non-callee saved registers. ESP is marked as
600 // a use to prevent stack-pointer assignments that appear immediately
601 // before calls from potentially appearing dead. Uses for argument
602 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
604 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000605 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
606 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000607 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000608 def CALLpcrel32 : Ii32<0xE8, RawFrm,
609 (outs), (ins i32imm_pcrel:$dst,variable_ops),
610 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000611 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000612 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000613 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000614 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615 }
616
617// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000618
Chris Lattnerb56cc342008-03-11 03:23:40 +0000619def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000620 "#TAILCALL",
621 []>;
622
Evan Cheng37e7c752007-07-21 00:34:19 +0000623let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000624def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000625 "#TC_RETURN $dst $offset",
626 []>;
627
628let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000629def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000630 "#TC_RETURN $dst $offset",
631 []>;
632
633let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000634
Chris Lattner357a0ca2009-06-20 19:34:09 +0000635 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000636 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000637let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000638 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
639 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000640let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000641 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000642 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000643
644//===----------------------------------------------------------------------===//
645// Miscellaneous Instructions...
646//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000647let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000649 (outs), (ins), "leave", []>;
650
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000651let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
652let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000653def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000654
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000655let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000656def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000657}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658
Bill Wendling4c2638c2009-06-15 19:39:04 +0000659let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
660def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000661 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000662def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000663 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000664def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000665 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000666}
667
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000668let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000669def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000670let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000671def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000672
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673let isTwoAddress = 1 in // GR32 = bswap GR32
674 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000675 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000676 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
678
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679
Evan Cheng48679f42007-12-14 02:13:44 +0000680// Bit scan instructions.
681let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000682def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$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 GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000685def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000686 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000687 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
688 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000689def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$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 GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000692def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000693 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000694 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
695 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000696
Evan Cheng4e33de92007-12-14 18:49:43 +0000697def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$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 GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000700def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000701 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000702 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
703 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000704def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$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 GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000707def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000708 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000709 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
710 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000711} // Defs = [EFLAGS]
712
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000713let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000715 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000716 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000717let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000719 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000720 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
722
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000723let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000724def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000725 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000726def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000727 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000728def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000729 [(X86rep_movs i32)]>, REP;
730}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000732let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000733def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000734 [(X86rep_stos i8)]>, REP;
735let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000736def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000737 [(X86rep_stos i16)]>, REP, OpSize;
738let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000739def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000740 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000742let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000743def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000744 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000746let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000747def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000748}
749
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000750//===----------------------------------------------------------------------===//
751// Input/Output Instructions...
752//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000753let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000754def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000755 "in{b}\t{%dx, %al|%AL, %DX}", []>;
756let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000757def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000758 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
759let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000760def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000761 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000763let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000764def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000765 "in{b}\t{$port, %al|%AL, $port}", []>;
766let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000767def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000768 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
769let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000770def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000771 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000773let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000774def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000775 "out{b}\t{%al, %dx|%DX, %AL}", []>;
776let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000777def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000778 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
779let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000780def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000781 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000783let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000784def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000785 "out{b}\t{%al, $port|$port, %AL}", []>;
786let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000787def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000788 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
789let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000790def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000791 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792
793//===----------------------------------------------------------------------===//
794// Move Instructions...
795//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000796let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000797def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000798 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000799def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000800 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000801def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000802 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000803}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000804let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000805def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000806 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000808def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000809 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000811def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000812 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813 [(set GR32:$dst, imm:$src)]>;
814}
Evan Chengb783fa32007-07-19 01:14:50 +0000815def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000816 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000818def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000819 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000821def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000822 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 [(store (i32 imm:$src), addr:$dst)]>;
824
Dan Gohman5574cc72008-12-03 18:15:48 +0000825let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000826def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000828 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000829def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000830 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000831 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000832def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000833 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000834 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000835}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836
Evan Chengb783fa32007-07-19 01:14:50 +0000837def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000838 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000840def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000841 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000843def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000844 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000846
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000847// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
848// that they can be used for copying and storing h registers, which can't be
849// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000850let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000851def MOV8rr_NOREX : I<0x88, MRMDestReg,
852 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000853 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000854let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000855def MOV8mr_NOREX : I<0x88, MRMDestMem,
856 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
857 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000858let mayLoad = 1,
859 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000860def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
861 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
862 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000863
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864//===----------------------------------------------------------------------===//
865// Fixed-Register Multiplication and Division Instructions...
866//
867
868// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000869let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000870def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
872 // This probably ought to be moved to a def : Pat<> if the
873 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000874 [(set AL, (mul AL, GR8:$src)),
875 (implicit EFLAGS)]>; // AL,AH = AL*GR8
876
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000877let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000878def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
879 "mul{w}\t$src",
880 []>, OpSize; // AX,DX = AX*GR16
881
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000882let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000883def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
884 "mul{l}\t$src",
885 []>; // EAX,EDX = EAX*GR32
886
Evan Cheng55687072007-09-14 21:48:26 +0000887let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000888def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000889 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
891 // This probably ought to be moved to a def : Pat<> if the
892 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000893 [(set AL, (mul AL, (loadi8 addr:$src))),
894 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
895
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000896let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000897let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000898def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000899 "mul{w}\t$src",
900 []>, OpSize; // AX,DX = AX*[mem16]
901
Evan Cheng55687072007-09-14 21:48:26 +0000902let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000903def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000904 "mul{l}\t$src",
905 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000906}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000908let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000909let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000910def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
911 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000912let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000913def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000914 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000915let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000916def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
917 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000918let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000919let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000920def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000921 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000922let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000923def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000924 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
925let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000926def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000927 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000928}
Dan Gohmand44572d2008-11-18 21:29:14 +0000929} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930
931// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000932let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000933def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000934 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000935let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000936def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000937 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000938let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000939def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000940 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000941let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000942let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000943def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000944 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000945let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000946def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000947 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000948let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000949def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000950 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000951}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952
953// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000954let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000955def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000956 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000957let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000958def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000959 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000960let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000961def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000962 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000963let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000964let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000965def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000966 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000967let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000968def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000969 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000970let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000971def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000972 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000973}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974
975//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000976// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977//
978let isTwoAddress = 1 in {
979
980// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000981let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000982let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000984 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000985 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000987 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000990 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000991 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000993 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000996 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000997 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000999 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001002 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001003 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001005 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001008 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001009 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001011 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001014 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001015 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001017 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001020 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001021 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001023 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001026 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001027 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001028 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001029 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001032 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001033 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001035 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001038 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001039 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001041 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001044 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001045 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001047 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001050 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001051 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001053 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001056 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001057 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001059 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001062 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001063 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001065 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001066 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001068 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001069 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001071 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001074 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001075 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001077 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001080 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001081 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001083 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001084 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001086 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001087 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001088 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001089 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001092 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001093 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001095 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001098 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001099 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001101 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001103def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001104 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001105 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001107 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001110 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001111 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001113 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001114 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001116 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001117 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001119 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001120 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001122 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001123 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001125 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001127def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001128 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001129 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001131 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001132 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001134 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001135 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001137 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001138 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001140 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001141 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001142 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001143 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001144 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001146 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001147 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001149 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001151def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1152 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1153 "cmovo\t{$src2, $dst|$dst, $src2}",
1154 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1155 X86_COND_O, EFLAGS))]>,
1156 TB, OpSize;
1157def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1158 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1159 "cmovo\t{$src2, $dst|$dst, $src2}",
1160 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1161 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001162 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001163def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1164 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1165 "cmovno\t{$src2, $dst|$dst, $src2}",
1166 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1167 X86_COND_NO, EFLAGS))]>,
1168 TB, OpSize;
1169def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1170 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1171 "cmovno\t{$src2, $dst|$dst, $src2}",
1172 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1173 X86_COND_NO, EFLAGS))]>,
1174 TB;
1175} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001176
1177def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1178 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1179 "cmovb\t{$src2, $dst|$dst, $src2}",
1180 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1181 X86_COND_B, EFLAGS))]>,
1182 TB, OpSize;
1183def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1184 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1185 "cmovb\t{$src2, $dst|$dst, $src2}",
1186 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1187 X86_COND_B, EFLAGS))]>,
1188 TB;
1189def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1190 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1191 "cmovae\t{$src2, $dst|$dst, $src2}",
1192 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1193 X86_COND_AE, EFLAGS))]>,
1194 TB, OpSize;
1195def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1196 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1197 "cmovae\t{$src2, $dst|$dst, $src2}",
1198 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1199 X86_COND_AE, EFLAGS))]>,
1200 TB;
1201def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1202 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1203 "cmove\t{$src2, $dst|$dst, $src2}",
1204 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1205 X86_COND_E, EFLAGS))]>,
1206 TB, OpSize;
1207def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1208 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1209 "cmove\t{$src2, $dst|$dst, $src2}",
1210 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1211 X86_COND_E, EFLAGS))]>,
1212 TB;
1213def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1214 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1215 "cmovne\t{$src2, $dst|$dst, $src2}",
1216 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1217 X86_COND_NE, EFLAGS))]>,
1218 TB, OpSize;
1219def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1220 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1221 "cmovne\t{$src2, $dst|$dst, $src2}",
1222 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1223 X86_COND_NE, EFLAGS))]>,
1224 TB;
1225def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1226 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1227 "cmovbe\t{$src2, $dst|$dst, $src2}",
1228 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1229 X86_COND_BE, EFLAGS))]>,
1230 TB, OpSize;
1231def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1232 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1233 "cmovbe\t{$src2, $dst|$dst, $src2}",
1234 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1235 X86_COND_BE, EFLAGS))]>,
1236 TB;
1237def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1238 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1239 "cmova\t{$src2, $dst|$dst, $src2}",
1240 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1241 X86_COND_A, EFLAGS))]>,
1242 TB, OpSize;
1243def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1244 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1245 "cmova\t{$src2, $dst|$dst, $src2}",
1246 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1247 X86_COND_A, EFLAGS))]>,
1248 TB;
1249def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1250 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1251 "cmovl\t{$src2, $dst|$dst, $src2}",
1252 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1253 X86_COND_L, EFLAGS))]>,
1254 TB, OpSize;
1255def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1256 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1257 "cmovl\t{$src2, $dst|$dst, $src2}",
1258 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1259 X86_COND_L, EFLAGS))]>,
1260 TB;
1261def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1262 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1263 "cmovge\t{$src2, $dst|$dst, $src2}",
1264 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1265 X86_COND_GE, EFLAGS))]>,
1266 TB, OpSize;
1267def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1268 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1269 "cmovge\t{$src2, $dst|$dst, $src2}",
1270 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1271 X86_COND_GE, EFLAGS))]>,
1272 TB;
1273def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1274 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1275 "cmovle\t{$src2, $dst|$dst, $src2}",
1276 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1277 X86_COND_LE, EFLAGS))]>,
1278 TB, OpSize;
1279def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1280 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1281 "cmovle\t{$src2, $dst|$dst, $src2}",
1282 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1283 X86_COND_LE, EFLAGS))]>,
1284 TB;
1285def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1286 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1287 "cmovg\t{$src2, $dst|$dst, $src2}",
1288 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1289 X86_COND_G, EFLAGS))]>,
1290 TB, OpSize;
1291def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1292 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1293 "cmovg\t{$src2, $dst|$dst, $src2}",
1294 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1295 X86_COND_G, EFLAGS))]>,
1296 TB;
1297def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1298 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1299 "cmovs\t{$src2, $dst|$dst, $src2}",
1300 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1301 X86_COND_S, EFLAGS))]>,
1302 TB, OpSize;
1303def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1304 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1305 "cmovs\t{$src2, $dst|$dst, $src2}",
1306 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1307 X86_COND_S, EFLAGS))]>,
1308 TB;
1309def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1310 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1311 "cmovns\t{$src2, $dst|$dst, $src2}",
1312 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1313 X86_COND_NS, EFLAGS))]>,
1314 TB, OpSize;
1315def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1316 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1317 "cmovns\t{$src2, $dst|$dst, $src2}",
1318 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1319 X86_COND_NS, EFLAGS))]>,
1320 TB;
1321def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1322 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1323 "cmovp\t{$src2, $dst|$dst, $src2}",
1324 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1325 X86_COND_P, EFLAGS))]>,
1326 TB, OpSize;
1327def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1328 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1329 "cmovp\t{$src2, $dst|$dst, $src2}",
1330 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1331 X86_COND_P, EFLAGS))]>,
1332 TB;
1333def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1334 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1335 "cmovnp\t{$src2, $dst|$dst, $src2}",
1336 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1337 X86_COND_NP, EFLAGS))]>,
1338 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001339def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1340 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1341 "cmovnp\t{$src2, $dst|$dst, $src2}",
1342 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1343 X86_COND_NP, EFLAGS))]>,
1344 TB;
1345def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1346 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1347 "cmovo\t{$src2, $dst|$dst, $src2}",
1348 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1349 X86_COND_O, EFLAGS))]>,
1350 TB, OpSize;
1351def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1352 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1353 "cmovo\t{$src2, $dst|$dst, $src2}",
1354 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1355 X86_COND_O, EFLAGS))]>,
1356 TB;
1357def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1358 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1359 "cmovno\t{$src2, $dst|$dst, $src2}",
1360 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1361 X86_COND_NO, EFLAGS))]>,
1362 TB, OpSize;
1363def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1364 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1365 "cmovno\t{$src2, $dst|$dst, $src2}",
1366 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1367 X86_COND_NO, EFLAGS))]>,
1368 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001369} // Uses = [EFLAGS]
1370
1371
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372// unary instructions
1373let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001374let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001375def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001376 [(set GR8:$dst, (ineg GR8:$src)),
1377 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001378def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001379 [(set GR16:$dst, (ineg GR16:$src)),
1380 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001381def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001382 [(set GR32:$dst, (ineg GR32:$src)),
1383 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001385 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001386 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1387 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001388 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001389 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1390 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001391 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001392 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1393 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001394}
Evan Cheng55687072007-09-14 21:48:26 +00001395} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001396
Evan Chengc6cee682009-01-21 02:09:05 +00001397// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1398let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001399def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001401def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001402 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001403def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001405}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001407 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001409 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001410 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001411 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1413}
1414} // CodeSize
1415
1416// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001417let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001419def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001420 [(set GR8:$dst, (add GR8:$src, 1)),
1421 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001423def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001424 [(set GR16:$dst, (add GR16:$src, 1)),
1425 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001427def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001428 [(set GR32:$dst, (add GR32:$src, 1)),
1429 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001430}
1431let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001432 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001433 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1434 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001435 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001436 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1437 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001438 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001439 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001440 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1441 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001442 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001443}
1444
1445let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001446def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001447 [(set GR8:$dst, (add GR8:$src, -1)),
1448 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001449let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001450def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001451 [(set GR16:$dst, (add GR16:$src, -1)),
1452 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001453 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001454def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001455 [(set GR32:$dst, (add GR32:$src, -1)),
1456 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001457}
1458
1459let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001460 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001461 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1462 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001463 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001464 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1465 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001466 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001467 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001468 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1469 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001470 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471}
Evan Cheng55687072007-09-14 21:48:26 +00001472} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473
1474// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001475let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1477def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001478 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001479 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001480 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1481 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001482def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001483 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001484 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001485 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1486 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001487def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001488 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001489 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001490 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1491 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001492}
1493
1494def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001495 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001496 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001497 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001498 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001499def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001500 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001501 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001502 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001503 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001504def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001505 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001507 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001508 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001509
1510def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001511 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001512 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001513 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1514 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001515def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001516 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001517 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001518 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1519 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001520def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001521 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001522 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001523 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1524 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001526 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001527 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001528 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1529 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530 OpSize;
1531def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001532 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001533 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001534 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1535 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001536
1537let isTwoAddress = 0 in {
1538 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001539 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001540 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001541 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1542 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001544 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001545 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001546 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1547 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548 OpSize;
1549 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001550 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001552 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1553 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001555 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001557 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1558 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001559 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001560 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001561 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001562 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1563 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564 OpSize;
1565 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001566 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001568 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1569 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001570 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001571 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001572 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001573 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1574 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575 OpSize;
1576 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001577 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001578 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001579 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1580 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581}
1582
1583
1584let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001585def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001586 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001587 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1588 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001589def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001590 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001591 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1592 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001593def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001594 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001595 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1596 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001597}
Evan Chengb783fa32007-07-19 01:14:50 +00001598def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001599 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001600 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1601 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001602def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001603 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001604 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1605 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001606def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001607 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001608 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1609 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001610
Evan Chengb783fa32007-07-19 01:14:50 +00001611def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001612 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001613 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1614 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001615def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001616 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001617 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1618 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001619def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001620 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001621 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1622 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623
Evan Chengb783fa32007-07-19 01:14:50 +00001624def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001625 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001626 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1627 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001628def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001629 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001630 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1631 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001633 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001634 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001635 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1636 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001637 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001638 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001639 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1640 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001641 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001642 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001643 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1644 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001645 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001646 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001647 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1648 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001649 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001650 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001651 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1652 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001654 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001656 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1657 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001658 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001659 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001660 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1661 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001662 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001663 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001665 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1666 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001667} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001668
1669
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001670let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001671 def XOR8rr : I<0x30, MRMDestReg,
1672 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1673 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001674 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1675 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001676 def XOR16rr : I<0x31, MRMDestReg,
1677 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1678 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001679 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1680 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001681 def XOR32rr : I<0x31, MRMDestReg,
1682 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1683 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001684 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1685 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001686} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687
1688def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001689 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001690 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001691 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1692 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001693def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001694 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001695 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001696 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1697 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001698 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001700 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001701 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001702 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1703 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001704
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001705def XOR8ri : Ii8<0x80, MRM6r,
1706 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1707 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001708 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1709 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001710def XOR16ri : Ii16<0x81, MRM6r,
1711 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1712 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001713 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1714 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001715def XOR32ri : Ii32<0x81, MRM6r,
1716 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1717 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001718 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1719 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001720def XOR16ri8 : Ii8<0x83, MRM6r,
1721 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1722 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001723 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1724 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001725 OpSize;
1726def XOR32ri8 : Ii8<0x83, MRM6r,
1727 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1728 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001729 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1730 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001731
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001732let isTwoAddress = 0 in {
1733 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001734 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001736 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1737 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001739 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001741 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1742 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001743 OpSize;
1744 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001745 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001746 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001747 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1748 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001749 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001750 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001751 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001752 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1753 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001754 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001755 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001757 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1758 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001759 OpSize;
1760 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001761 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001762 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001763 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1764 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001765 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001766 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001767 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001768 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1769 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770 OpSize;
1771 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001772 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001774 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1775 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001776} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001777} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001778
1779// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001780let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001781let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001782def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001783 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001784 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001785def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001786 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001787 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001788def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001789 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001790 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001791} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792
Evan Chengb783fa32007-07-19 01:14:50 +00001793def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001795 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1796let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001797def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001798 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001800def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001801 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001803// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1804// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001805} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806
1807let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001808 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001809 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001810 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001811 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001812 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001813 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001814 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001815 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001816 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001817 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1818 }
Evan Chengb783fa32007-07-19 01:14:50 +00001819 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001822 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001823 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1825 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001826 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001827 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001828 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1829
1830 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001831 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001834 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1837 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001838 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001839 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1841}
1842
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001843let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001844def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001845 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001846 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001847def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001848 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001849 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001850def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001851 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001852 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1853}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854
Evan Chengb783fa32007-07-19 01:14:50 +00001855def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001856 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001858def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001861def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001862 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001863 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1864
1865// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001866def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001868 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001869def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001870 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001872def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001873 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001874 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1875
1876let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001877 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001878 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001879 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001880 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001881 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001882 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001883 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001884 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001885 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001886 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001887 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1888 }
Evan Chengb783fa32007-07-19 01:14:50 +00001889 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001892 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001894 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1895 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001896 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001897 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1899
1900 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001901 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001904 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001905 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001906 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001907 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1910}
1911
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001912let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001913def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001914 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001915 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001916def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001917 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001918 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001919def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001920 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001921 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1922}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923
Evan Chengb783fa32007-07-19 01:14:50 +00001924def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001927def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1930 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001931def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001932 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001933 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1934
1935// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001936def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001937 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001938 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001939def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001941 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001942def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001943 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001944 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1945
1946let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001947 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001948 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001949 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001950 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001951 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001952 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001953 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001954 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001955 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001956 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1957 }
Evan Chengb783fa32007-07-19 01:14:50 +00001958 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001961 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1964 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001965 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1968
1969 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001970 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001971 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001973 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001974 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1976 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001977 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001978 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001979 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1980}
1981
1982// Rotate instructions
1983// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001984let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001985def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001986 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001987 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001988def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001989 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001990 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001991def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001992 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001993 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1994}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001995
Evan Chengb783fa32007-07-19 01:14:50 +00001996def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001997 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001998 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001999def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002002def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002003 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002004 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
2005
2006// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002007def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002010def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002011 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002012 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002013def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
2016
2017let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002018 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002019 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002020 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002021 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002022 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002023 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002024 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002025 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002026 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002027 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
2028 }
Evan Chengb783fa32007-07-19 01:14:50 +00002029 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002030 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002031 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002032 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2035 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002036 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002037 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002038 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2039
2040 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002041 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002042 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002043 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002044 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2047 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002048 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002049 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2051}
2052
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002053let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002054def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002055 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002056 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002057def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002058 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002059 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002060def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002061 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002062 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2063}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002064
Evan Chengb783fa32007-07-19 01:14:50 +00002065def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002068def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002071def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002072 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002073 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2074
2075// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002076def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002077 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002079def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002082def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002083 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2085
2086let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002087 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002088 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002089 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002090 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002091 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002092 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002093 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002094 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002095 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002096 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2097 }
Evan Chengb783fa32007-07-19 01:14:50 +00002098 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002099 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002100 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002101 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002102 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2104 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002105 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002106 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2108
2109 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002110 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002113 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002114 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002115 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2116 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002117 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002118 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2120}
2121
2122
2123
2124// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002125let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002126def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002127 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002128 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002129def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002130 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002131 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002132def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002133 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002135 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002136def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002137 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002139 TB, OpSize;
2140}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002141
2142let isCommutable = 1 in { // These instructions commute to each other.
2143def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002144 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002145 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002146 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2147 (i8 imm:$src3)))]>,
2148 TB;
2149def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002150 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2153 (i8 imm:$src3)))]>,
2154 TB;
2155def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002156 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2159 (i8 imm:$src3)))]>,
2160 TB, OpSize;
2161def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002162 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002163 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2165 (i8 imm:$src3)))]>,
2166 TB, OpSize;
2167}
2168
2169let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002170 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002171 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002172 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002173 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002174 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002175 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002176 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002177 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002178 addr:$dst)]>, TB;
2179 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002180 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002181 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002182 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002183 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2184 (i8 imm:$src3)), addr:$dst)]>,
2185 TB;
2186 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002187 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002188 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002189 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2190 (i8 imm:$src3)), addr:$dst)]>,
2191 TB;
2192
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002193 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002194 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002195 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002197 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002198 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002199 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002200 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002201 addr:$dst)]>, TB, OpSize;
2202 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002203 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002204 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002205 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2207 (i8 imm:$src3)), addr:$dst)]>,
2208 TB, OpSize;
2209 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002210 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002211 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002212 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2213 (i8 imm:$src3)), addr:$dst)]>,
2214 TB, OpSize;
2215}
Evan Cheng55687072007-09-14 21:48:26 +00002216} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002217
2218
2219// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002220let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002221let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002222// Register-Register Addition
2223def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2224 (ins GR8 :$src1, GR8 :$src2),
2225 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002226 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002227 (implicit EFLAGS)]>;
2228
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002229let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002230// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002231def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2232 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002233 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002234 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2235 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002236def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2237 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002238 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002239 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2240 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002241} // end isConvertibleToThreeAddress
2242} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002243
2244// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002245def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2246 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002247 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002248 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2249 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002250def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2251 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002253 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2254 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002255def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2256 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002258 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2259 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002260
Bill Wendlingae034ed2008-12-12 00:56:36 +00002261// Register-Integer Addition
2262def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2263 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002264 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2265 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002266
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002268// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002269def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2270 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002271 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002272 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2273 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002274def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2275 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002276 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002277 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2278 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002279def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2280 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002281 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002282 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2283 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002284def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2285 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002287 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2288 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289}
2290
2291let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002292 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002293 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002294 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002295 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2296 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002297 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002298 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002299 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2300 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002301 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002302 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002303 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2304 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002305 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002306 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002307 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2308 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002309 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002310 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002311 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2312 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002313 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002314 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002315 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2316 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002317 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002318 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002319 [(store (add (load addr:$dst), i16immSExt8:$src2),
2320 addr:$dst),
2321 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002322 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002323 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002324 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002325 addr:$dst),
2326 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327}
2328
Evan Cheng259471d2007-10-05 17:59:57 +00002329let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002330let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002331def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002332 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002333 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002334def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2335 (ins GR16:$src1, GR16:$src2),
2336 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002337 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002338def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2339 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002340 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002341 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002342}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002343def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2344 (ins GR8:$src1, i8mem:$src2),
2345 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002346 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002347def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2348 (ins GR16:$src1, i16mem:$src2),
2349 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002350 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002351 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002352def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2353 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002354 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002355 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2356def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002357 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002358 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002359def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2360 (ins GR16:$src1, i16imm:$src2),
2361 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002362 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002363def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2364 (ins GR16:$src1, i16i8imm:$src2),
2365 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002366 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2367 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002368def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2369 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002370 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002371 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002372def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2373 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002374 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002375 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002376
2377let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002378 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002379 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002380 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2381 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002382 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002383 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2384 OpSize;
2385 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002386 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002387 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2388 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002389 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002390 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2391 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002392 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002393 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2394 OpSize;
2395 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002396 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002397 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2398 OpSize;
2399 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$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 (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2402 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002403 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002404 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2405}
Evan Cheng259471d2007-10-05 17:59:57 +00002406} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002407
Bill Wendlingae034ed2008-12-12 00:56:36 +00002408// Register-Register Subtraction
2409def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2410 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002411 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2412 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002413def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2414 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002415 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2416 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002417def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2418 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002419 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2420 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002421
2422// Register-Memory Subtraction
2423def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2424 (ins GR8 :$src1, i8mem :$src2),
2425 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002426 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2427 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002428def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2429 (ins GR16:$src1, i16mem:$src2),
2430 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002431 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2432 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002433def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2434 (ins GR32:$src1, i32mem:$src2),
2435 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002436 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2437 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002438
2439// Register-Integer Subtraction
2440def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2441 (ins GR8:$src1, i8imm:$src2),
2442 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002443 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2444 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002445def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2446 (ins GR16:$src1, i16imm:$src2),
2447 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002448 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2449 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002450def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2451 (ins GR32:$src1, i32imm:$src2),
2452 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002453 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2454 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002455def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2456 (ins GR16:$src1, i16i8imm:$src2),
2457 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002458 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2459 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002460def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2461 (ins GR32:$src1, i32i8imm:$src2),
2462 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002463 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2464 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002465
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002466let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002467 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002468 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002469 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002470 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2471 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002472 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002473 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002474 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2475 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002476 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002477 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002478 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2479 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002480
2481 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002482 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002483 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002484 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2485 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002486 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002487 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002488 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2489 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002490 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002491 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002492 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2493 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002494 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002495 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002496 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002497 addr:$dst),
2498 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002499 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002500 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002501 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002502 addr:$dst),
2503 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002504}
2505
Evan Cheng259471d2007-10-05 17:59:57 +00002506let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002507def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2508 (ins GR8:$src1, GR8:$src2),
2509 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002510 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002511def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2512 (ins GR16:$src1, GR16:$src2),
2513 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002514 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002515def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2516 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002517 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002518 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002519
2520let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002521 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2522 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002523 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002524 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2525 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002526 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002527 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002528 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002529 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002530 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002531 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002532 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002533 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002534 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2535 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002536 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002537 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002538 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2539 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002540 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002541 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002542 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$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 (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002545 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002546 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002547 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002548}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002549def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2550 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002551 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002552def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2553 (ins GR16:$src1, i16mem:$src2),
2554 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002555 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002556 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002557def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2558 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002559 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002560 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002561def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2562 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002563 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002564def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2565 (ins GR16:$src1, i16imm:$src2),
2566 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002567 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002568def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2569 (ins GR16:$src1, i16i8imm:$src2),
2570 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002571 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2572 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002573def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2574 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002575 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002576 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002577def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2578 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002579 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002580 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002581} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002582} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002583
Evan Cheng55687072007-09-14 21:48:26 +00002584let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002585let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002586// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002587def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002588 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002589 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2590 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002591def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002592 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002593 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2594 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002595}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002596
Bill Wendlingf5399032008-12-12 21:15:41 +00002597// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002598def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2599 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002600 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002601 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2602 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002603def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002604 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002605 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2606 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002607} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002608} // end Two Address instructions
2609
2610// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002611let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002612// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002613def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002614 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002615 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002616 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2617 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002618def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002619 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002620 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002621 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2622 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002623def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002624 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002625 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002626 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2627 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002628def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002629 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002630 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002631 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2632 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002633
Bill Wendlingf5399032008-12-12 21:15:41 +00002634// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002635def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002636 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002637 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002638 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2639 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002640def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002641 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002642 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002643 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2644 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002645def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002646 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002647 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002648 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002649 i16immSExt8:$src2)),
2650 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002651def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002652 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002653 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002654 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002655 i32immSExt8:$src2)),
2656 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002657} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002658
2659//===----------------------------------------------------------------------===//
2660// Test instructions are just like AND, except they don't generate a result.
2661//
Evan Cheng950aac02007-09-25 01:57:46 +00002662let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002663let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002664def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002665 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002666 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002667 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002668def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002669 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002670 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002671 (implicit EFLAGS)]>,
2672 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002673def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002674 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002675 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002676 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002677}
2678
Evan Chengb783fa32007-07-19 01:14:50 +00002679def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002680 "test{b}\t{$src2, $src1|$src1, $src2}",
2681 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2682 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002683def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002684 "test{w}\t{$src2, $src1|$src1, $src2}",
2685 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2686 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002687def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002688 "test{l}\t{$src2, $src1|$src1, $src2}",
2689 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2690 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002691
2692def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002693 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002694 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002695 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002696 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002697def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002698 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002699 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002700 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002701 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002702def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002703 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002704 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002705 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002706 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002707
Evan Cheng621216e2007-09-29 00:00:36 +00002708def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002709 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002710 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002711 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2712 (implicit EFLAGS)]>;
2713def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002714 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002715 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002716 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2717 (implicit EFLAGS)]>, OpSize;
2718def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002719 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002720 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002721 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002722 (implicit EFLAGS)]>;
2723} // Defs = [EFLAGS]
2724
2725
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002726// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002727let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002728def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002729let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002730def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002731
Evan Cheng950aac02007-09-25 01:57:46 +00002732let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002733def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002734 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002735 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002736 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002737 TB; // GR8 = ==
2738def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002739 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002740 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002741 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002742 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002743
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002744def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002745 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002746 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002747 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002748 TB; // GR8 = !=
2749def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002750 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002751 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002752 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002753 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002754
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002755def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002756 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002757 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002758 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002759 TB; // GR8 = < signed
2760def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002761 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002762 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002763 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002764 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002765
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002766def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002767 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002768 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002769 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002770 TB; // GR8 = >= signed
2771def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002772 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002773 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002774 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002775 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002776
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002777def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002778 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002779 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002780 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002781 TB; // GR8 = <= signed
2782def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002783 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002784 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002785 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002786 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002787
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002788def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002789 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002790 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002791 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002792 TB; // GR8 = > signed
2793def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002794 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002795 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002796 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002797 TB; // [mem8] = > signed
2798
2799def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002800 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002801 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002802 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002803 TB; // GR8 = < unsign
2804def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002805 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002806 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002807 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002808 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002809
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002810def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002811 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002812 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002813 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002814 TB; // GR8 = >= unsign
2815def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002816 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002817 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002818 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002819 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002820
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002821def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002822 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002823 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002824 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002825 TB; // GR8 = <= unsign
2826def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002827 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002828 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002829 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002830 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002831
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002832def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002833 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002834 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002835 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002836 TB; // GR8 = > signed
2837def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002838 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002839 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002840 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002841 TB; // [mem8] = > signed
2842
2843def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002844 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002845 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002846 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002847 TB; // GR8 = <sign bit>
2848def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002849 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002850 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002851 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002852 TB; // [mem8] = <sign bit>
2853def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002854 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002855 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002856 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002857 TB; // GR8 = !<sign bit>
2858def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002859 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002860 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002861 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002862 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002863
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002864def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002865 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002866 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002867 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002868 TB; // GR8 = parity
2869def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002870 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002871 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002872 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002873 TB; // [mem8] = parity
2874def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002875 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002876 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002877 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002878 TB; // GR8 = not parity
2879def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002880 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002881 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002882 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002884
2885def SETOr : I<0x90, MRM0r,
2886 (outs GR8 :$dst), (ins),
2887 "seto\t$dst",
2888 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2889 TB; // GR8 = overflow
2890def SETOm : I<0x90, MRM0m,
2891 (outs), (ins i8mem:$dst),
2892 "seto\t$dst",
2893 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2894 TB; // [mem8] = overflow
2895def SETNOr : I<0x91, MRM0r,
2896 (outs GR8 :$dst), (ins),
2897 "setno\t$dst",
2898 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2899 TB; // GR8 = not overflow
2900def SETNOm : I<0x91, MRM0m,
2901 (outs), (ins i8mem:$dst),
2902 "setno\t$dst",
2903 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2904 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002905} // Uses = [EFLAGS]
2906
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002907
2908// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002909let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002910def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002911 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002912 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002913 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002914def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002915 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002916 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002917 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002918def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002919 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002920 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002921 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002922def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002923 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002924 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002925 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2926 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002927def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002928 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002929 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002930 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2931 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002932def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002933 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002934 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002935 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2936 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002937def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002938 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002939 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002940 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2941 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002942def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002943 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002944 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002945 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2946 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002947def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002948 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002949 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002950 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2951 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002952def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002953 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002954 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002955 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002956def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002957 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002958 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002959 [(X86cmp GR16:$src1, imm:$src2),
2960 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002961def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002962 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002963 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002964 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002965def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002966 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002967 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002968 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2969 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002970def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002971 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002972 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002973 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2974 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002975def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002976 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002977 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002978 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2979 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002980def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002981 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002982 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002983 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2984 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002985def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002986 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002987 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002988 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2989 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002990def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002991 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002992 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002993 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2994 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002995def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002996 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002997 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002998 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002999 (implicit EFLAGS)]>;
3000} // Defs = [EFLAGS]
3001
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003002// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003003// TODO: BTC, BTR, and BTS
3004let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003005def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003006 "bt{w}\t{$src2, $src1|$src1, $src2}",
3007 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003008 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00003009def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003010 "bt{l}\t{$src2, $src1|$src1, $src2}",
3011 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00003012 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00003013
3014// Unlike with the register+register form, the memory+register form of the
3015// bt instruction does not ignore the high bits of the index. From ISel's
3016// perspective, this is pretty bizarre. Disable these instructions for now.
3017//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
3018// "bt{w}\t{$src2, $src1|$src1, $src2}",
3019// [(X86bt (loadi16 addr:$src1), GR16:$src2),
3020// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
3021//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
3022// "bt{l}\t{$src2, $src1|$src1, $src2}",
3023// [(X86bt (loadi32 addr:$src1), GR32:$src2),
3024// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00003025
3026def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
3027 "bt{w}\t{$src2, $src1|$src1, $src2}",
3028 [(X86bt GR16:$src1, i16immSExt8:$src2),
3029 (implicit EFLAGS)]>, OpSize, TB;
3030def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3031 "bt{l}\t{$src2, $src1|$src1, $src2}",
3032 [(X86bt GR32:$src1, i32immSExt8:$src2),
3033 (implicit EFLAGS)]>, TB;
3034// Note that these instructions don't need FastBTMem because that
3035// only applies when the other operand is in a register. When it's
3036// an immediate, bt is still fast.
3037def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3038 "bt{w}\t{$src2, $src1|$src1, $src2}",
3039 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3040 (implicit EFLAGS)]>, OpSize, TB;
3041def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3042 "bt{l}\t{$src2, $src1|$src1, $src2}",
3043 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3044 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003045} // Defs = [EFLAGS]
3046
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003047// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003048// Use movsbl intead of movsbw; we don't care about the high 16 bits
3049// of the register here. This has a smaller encoding and avoids a
3050// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003051def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003052 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3053 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003054def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003055 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3056 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003057def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$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, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003060def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003061 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003062 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003063def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$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, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003066def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003067 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003068 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3069
Dan Gohman9203ab42008-07-30 18:09:17 +00003070// Use movzbl intead of movzbw; we don't care about the high 16 bits
3071// of the register here. This has a smaller encoding and avoids a
3072// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003073def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003074 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3075 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003076def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003077 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3078 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003079def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$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, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003082def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003083 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003084 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003085def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$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, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003088def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003089 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003090 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3091
Dan Gohman744d4622009-04-13 16:09:41 +00003092// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3093// except that they use GR32_NOREX for the output operand register class
3094// instead of GR32. This allows them to operate on h registers on x86-64.
3095def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3096 (outs GR32_NOREX:$dst), (ins GR8:$src),
3097 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3098 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003099let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003100def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3101 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3102 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3103 []>, TB;
3104
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003105let neverHasSideEffects = 1 in {
3106 let Defs = [AX], Uses = [AL] in
3107 def CBW : I<0x98, RawFrm, (outs), (ins),
3108 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3109 let Defs = [EAX], Uses = [AX] in
3110 def CWDE : I<0x98, RawFrm, (outs), (ins),
3111 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003112
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003113 let Defs = [AX,DX], Uses = [AX] in
3114 def CWD : I<0x99, RawFrm, (outs), (ins),
3115 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3116 let Defs = [EAX,EDX], Uses = [EAX] in
3117 def CDQ : I<0x99, RawFrm, (outs), (ins),
3118 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3119}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003120
3121//===----------------------------------------------------------------------===//
3122// Alias Instructions
3123//===----------------------------------------------------------------------===//
3124
3125// Alias instructions that map movr0 to xor.
3126// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00003127let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003128def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003129 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003130 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003131// Use xorl instead of xorw since we don't care about the high 16 bits,
3132// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003133def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003134 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3135 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003136def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003137 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003138 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003139}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003140
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003141//===----------------------------------------------------------------------===//
3142// Thread Local Storage Instructions
3143//
3144
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003145// All calls clobber the non-callee saved registers. ESP is marked as
3146// a use to prevent stack-pointer assignments that appear immediately
3147// before calls from potentially appearing dead.
3148let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3149 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3150 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3151 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003152 Uses = [ESP] in
3153def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3154 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003155 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003156 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003157 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003158
sampo9cc09a32009-01-26 01:24:32 +00003159let AddedComplexity = 5 in
3160def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3161 "movl\t%gs:$src, $dst",
3162 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3163
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003164let AddedComplexity = 5 in
3165def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3166 "movl\t%fs:$src, $dst",
3167 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3168
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003169//===----------------------------------------------------------------------===//
3170// DWARF Pseudo Instructions
3171//
3172
Evan Chengb783fa32007-07-19 01:14:50 +00003173def DWARF_LOC : I<0, Pseudo, (outs),
3174 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Chris Lattner64b54552009-07-10 22:34:11 +00003175 ".loc\t$file $line $col",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003176 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3177 (i32 imm:$file))]>;
3178
3179//===----------------------------------------------------------------------===//
3180// EH Pseudo Instructions
3181//
3182let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003183 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003184def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003185 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003186 [(X86ehret GR32:$addr)]>;
3187
3188}
3189
3190//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003191// Atomic support
3192//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003193
Evan Cheng3e171562008-04-19 01:20:30 +00003194// Atomic swap. These are just normal xchg instructions. But since a memory
3195// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003196let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003197def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3198 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3199 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3200def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3201 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3202 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3203 OpSize;
3204def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3205 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3206 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3207}
3208
Evan Chengd49dbb82008-04-18 20:55:36 +00003209// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003210let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003211def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003212 "lock\n\t"
3213 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003214 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003215}
Dale Johannesenf160d802008-10-02 18:53:47 +00003216let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003217def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003218 "lock\n\t"
3219 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003220 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3221}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003222
3223let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003224def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003225 "lock\n\t"
3226 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003227 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003228}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003229let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003230def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003231 "lock\n\t"
3232 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003233 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003234}
3235
Evan Chengd49dbb82008-04-18 20:55:36 +00003236// Atomic exchange and add
3237let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3238def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003239 "lock\n\t"
3240 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003241 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003242 TB, LOCK;
3243def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003244 "lock\n\t"
3245 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003246 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003247 TB, OpSize, LOCK;
3248def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003249 "lock\n\t"
3250 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003251 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003252 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003253}
3254
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003255// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003256let Constraints = "$val = $dst", Defs = [EFLAGS],
3257 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003258def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003259 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003260 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003261def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003262 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003263 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003264def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003265 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003266 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003267def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003268 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003269 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003270def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003271 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003272 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003273def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003274 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003275 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003276def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003277 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003278 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003279def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003280 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003281 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003282
3283def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003284 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003285 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003286def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003287 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003288 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003289def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003290 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003291 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003292def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003293 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003294 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003295def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003296 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003297 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003298def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003299 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003300 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003301def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003302 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003303 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003304def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003305 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003306 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003307
3308def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003309 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003310 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003311def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003312 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003313 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003314def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003315 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003316 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003317def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003318 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003319 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003320}
3321
Dale Johannesenf160d802008-10-02 18:53:47 +00003322let Constraints = "$val1 = $dst1, $val2 = $dst2",
3323 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3324 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003325 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003326 usesCustomDAGSchedInserter = 1 in {
3327def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3328 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003329 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003330def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3331 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003332 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003333def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3334 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003335 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003336def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3337 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003338 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003339def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3340 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003341 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003342def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3343 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003344 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003345def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3346 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003347 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003348}
3349
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003350//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003351// Non-Instruction Patterns
3352//===----------------------------------------------------------------------===//
3353
Bill Wendlingfef06052008-09-16 21:48:12 +00003354// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003355def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3356def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003357def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003358def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3359def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3360
3361def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3362 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3363def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3364 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3365def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3366 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3367def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3368 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3369
3370def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3371 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3372def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3373 (MOV32mi addr:$dst, texternalsym:$src)>;
3374
3375// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003376// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003377def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003378 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003379
3380def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003381 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003382def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003383 (TAILCALL)>;
3384
3385def : Pat<(X86tcret GR32:$dst, imm:$off),
3386 (TCRETURNri GR32:$dst, imm:$off)>;
3387
3388def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3389 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3390
3391def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3392 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003393
3394def : Pat<(X86call (i32 tglobaladdr:$dst)),
3395 (CALLpcrel32 tglobaladdr:$dst)>;
3396def : Pat<(X86call (i32 texternalsym:$dst)),
3397 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003398def : Pat<(X86call (i32 imm:$dst)),
3399 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003400
3401// X86 specific add which produces a flag.
3402def : Pat<(addc GR32:$src1, GR32:$src2),
3403 (ADD32rr GR32:$src1, GR32:$src2)>;
3404def : Pat<(addc GR32:$src1, (load addr:$src2)),
3405 (ADD32rm GR32:$src1, addr:$src2)>;
3406def : Pat<(addc GR32:$src1, imm:$src2),
3407 (ADD32ri GR32:$src1, imm:$src2)>;
3408def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3409 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3410
3411def : Pat<(subc GR32:$src1, GR32:$src2),
3412 (SUB32rr GR32:$src1, GR32:$src2)>;
3413def : Pat<(subc GR32:$src1, (load addr:$src2)),
3414 (SUB32rm GR32:$src1, addr:$src2)>;
3415def : Pat<(subc GR32:$src1, imm:$src2),
3416 (SUB32ri GR32:$src1, imm:$src2)>;
3417def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3418 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3419
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003420// Comparisons.
3421
3422// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003423def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003424 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003425def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003426 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003427def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003428 (TEST32rr GR32:$src1, GR32:$src1)>;
3429
Dan Gohman0a3c5222009-01-07 01:00:24 +00003430// Conditional moves with folded loads with operands swapped and conditions
3431// inverted.
3432def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3433 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3434def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3435 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3436def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3437 (CMOVB16rm GR16:$src2, addr:$src1)>;
3438def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3439 (CMOVB32rm GR32:$src2, addr:$src1)>;
3440def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3441 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3442def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3443 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3444def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3445 (CMOVE16rm GR16:$src2, addr:$src1)>;
3446def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3447 (CMOVE32rm GR32:$src2, addr:$src1)>;
3448def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3449 (CMOVA16rm GR16:$src2, addr:$src1)>;
3450def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3451 (CMOVA32rm GR32:$src2, addr:$src1)>;
3452def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3453 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3454def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3455 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3456def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3457 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3458def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3459 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3460def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3461 (CMOVL16rm GR16:$src2, addr:$src1)>;
3462def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3463 (CMOVL32rm GR32:$src2, addr:$src1)>;
3464def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3465 (CMOVG16rm GR16:$src2, addr:$src1)>;
3466def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3467 (CMOVG32rm GR32:$src2, addr:$src1)>;
3468def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3469 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3470def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3471 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3472def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3473 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3474def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3475 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3476def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3477 (CMOVP16rm GR16:$src2, addr:$src1)>;
3478def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3479 (CMOVP32rm GR32:$src2, addr:$src1)>;
3480def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3481 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3482def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3483 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3484def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3485 (CMOVS16rm GR16:$src2, addr:$src1)>;
3486def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3487 (CMOVS32rm GR32:$src2, addr:$src1)>;
3488def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3489 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3490def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3491 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3492def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3493 (CMOVO16rm GR16:$src2, addr:$src1)>;
3494def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3495 (CMOVO32rm GR32:$src2, addr:$src1)>;
3496
Duncan Sands082524c2008-01-23 20:39:46 +00003497// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003498def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3499def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3500def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3501
3502// extload bool -> extload byte
3503def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003504def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3505 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003506def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003507def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3508 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003509def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3510def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3511
Dan Gohmandd612bb2008-08-20 21:27:32 +00003512// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003513def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3514 Requires<[In32BitMode]>;
3515def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3516 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003517def : Pat<(i32 (anyext GR16:$src)),
3518 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003519
Evan Chengf2abee72007-12-13 00:43:27 +00003520// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003521def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3522 (MOVZX32rm8 addr:$src)>;
3523def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3524 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003525
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003526//===----------------------------------------------------------------------===//
3527// Some peepholes
3528//===----------------------------------------------------------------------===//
3529
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003530// Odd encoding trick: -128 fits into an 8-bit immediate field while
3531// +128 doesn't, so in this special case use a sub instead of an add.
3532def : Pat<(add GR16:$src1, 128),
3533 (SUB16ri8 GR16:$src1, -128)>;
3534def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3535 (SUB16mi8 addr:$dst, -128)>;
3536def : Pat<(add GR32:$src1, 128),
3537 (SUB32ri8 GR32:$src1, -128)>;
3538def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3539 (SUB32mi8 addr:$dst, -128)>;
3540
Dan Gohman9203ab42008-07-30 18:09:17 +00003541// r & (2^16-1) ==> movz
3542def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003543 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003544// r & (2^8-1) ==> movz
3545def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003546 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003547 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003548 Requires<[In32BitMode]>;
3549// r & (2^8-1) ==> movz
3550def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003551 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003552 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003553 Requires<[In32BitMode]>;
3554
3555// sext_inreg patterns
3556def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003557 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003558def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003559 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003560 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003561 Requires<[In32BitMode]>;
3562def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003563 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003564 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003565 Requires<[In32BitMode]>;
3566
3567// trunc patterns
3568def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003569 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003570def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003571 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003572 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003573 Requires<[In32BitMode]>;
3574def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003575 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003576 x86_subreg_8bit)>,
3577 Requires<[In32BitMode]>;
3578
3579// h-register tricks
3580def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003581 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003582 x86_subreg_8bit_hi)>,
3583 Requires<[In32BitMode]>;
3584def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003585 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003586 x86_subreg_8bit_hi)>,
3587 Requires<[In32BitMode]>;
3588def : Pat<(srl_su GR16:$src, (i8 8)),
3589 (EXTRACT_SUBREG
3590 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003591 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003592 x86_subreg_8bit_hi)),
3593 x86_subreg_16bit)>,
3594 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003595def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3596 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3597 x86_subreg_8bit_hi))>,
3598 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003599def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003600 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003601 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003602 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003603
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003604// (shl x, 1) ==> (add x, x)
3605def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3606def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3607def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3608
Evan Cheng76a64c72008-08-30 02:03:58 +00003609// (shl x (and y, 31)) ==> (shl x, y)
3610def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3611 (SHL8rCL GR8:$src1)>;
3612def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3613 (SHL16rCL GR16:$src1)>;
3614def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3615 (SHL32rCL GR32:$src1)>;
3616def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3617 (SHL8mCL addr:$dst)>;
3618def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3619 (SHL16mCL addr:$dst)>;
3620def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3621 (SHL32mCL addr:$dst)>;
3622
3623def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3624 (SHR8rCL GR8:$src1)>;
3625def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3626 (SHR16rCL GR16:$src1)>;
3627def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3628 (SHR32rCL GR32:$src1)>;
3629def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3630 (SHR8mCL addr:$dst)>;
3631def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3632 (SHR16mCL addr:$dst)>;
3633def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3634 (SHR32mCL addr:$dst)>;
3635
3636def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3637 (SAR8rCL GR8:$src1)>;
3638def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3639 (SAR16rCL GR16:$src1)>;
3640def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3641 (SAR32rCL GR32:$src1)>;
3642def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3643 (SAR8mCL addr:$dst)>;
3644def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3645 (SAR16mCL addr:$dst)>;
3646def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3647 (SAR32mCL addr:$dst)>;
3648
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003649// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3650def : Pat<(or (srl GR32:$src1, CL:$amt),
3651 (shl GR32:$src2, (sub 32, CL:$amt))),
3652 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3653
3654def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3655 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3656 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3657
Dan Gohman921581d2008-10-17 01:23:35 +00003658def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3659 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3660 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3661
3662def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3663 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3664 addr:$dst),
3665 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3666
3667def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3668 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3669
3670def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3671 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3672 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3673
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003674// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3675def : Pat<(or (shl GR32:$src1, CL:$amt),
3676 (srl GR32:$src2, (sub 32, CL:$amt))),
3677 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3678
3679def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3680 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3681 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3682
Dan Gohman921581d2008-10-17 01:23:35 +00003683def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3684 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3685 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3686
3687def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3688 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3689 addr:$dst),
3690 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3691
3692def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3693 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3694
3695def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3696 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3697 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3698
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003699// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3700def : Pat<(or (srl GR16:$src1, CL:$amt),
3701 (shl GR16:$src2, (sub 16, CL:$amt))),
3702 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3703
3704def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3705 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3706 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3707
Dan Gohman921581d2008-10-17 01:23:35 +00003708def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3709 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3710 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3711
3712def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3713 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3714 addr:$dst),
3715 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3716
3717def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3718 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3719
3720def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3721 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3722 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3723
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003724// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3725def : Pat<(or (shl GR16:$src1, CL:$amt),
3726 (srl GR16:$src2, (sub 16, CL:$amt))),
3727 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3728
3729def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3730 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3731 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3732
Dan Gohman921581d2008-10-17 01:23:35 +00003733def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3734 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3735 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3736
3737def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3738 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3739 addr:$dst),
3740 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3741
3742def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3743 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3744
3745def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3746 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3747 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3748
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003749//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003750// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003751//===----------------------------------------------------------------------===//
3752
Dan Gohman99a12192009-03-04 19:44:21 +00003753// Register-Register Addition with EFLAGS result
3754def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003755 (implicit EFLAGS)),
3756 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003757def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003758 (implicit EFLAGS)),
3759 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003760def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003761 (implicit EFLAGS)),
3762 (ADD32rr GR32:$src1, GR32:$src2)>;
3763
Dan Gohman99a12192009-03-04 19:44:21 +00003764// Register-Memory Addition with EFLAGS result
3765def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003766 (implicit EFLAGS)),
3767 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003768def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003769 (implicit EFLAGS)),
3770 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003771def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003772 (implicit EFLAGS)),
3773 (ADD32rm GR32:$src1, addr:$src2)>;
3774
Dan Gohman99a12192009-03-04 19:44:21 +00003775// Register-Integer Addition with EFLAGS result
3776def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003777 (implicit EFLAGS)),
3778 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003779def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003780 (implicit EFLAGS)),
3781 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003782def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003783 (implicit EFLAGS)),
3784 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003785def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003786 (implicit EFLAGS)),
3787 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003788def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003789 (implicit EFLAGS)),
3790 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3791
Dan Gohman99a12192009-03-04 19:44:21 +00003792// Memory-Register Addition with EFLAGS result
3793def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003794 addr:$dst),
3795 (implicit EFLAGS)),
3796 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003797def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003798 addr:$dst),
3799 (implicit EFLAGS)),
3800 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003801def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003802 addr:$dst),
3803 (implicit EFLAGS)),
3804 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003805
3806// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003807def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003808 addr:$dst),
3809 (implicit EFLAGS)),
3810 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003811def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003812 addr:$dst),
3813 (implicit EFLAGS)),
3814 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003815def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003816 addr:$dst),
3817 (implicit EFLAGS)),
3818 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003819def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003820 addr:$dst),
3821 (implicit EFLAGS)),
3822 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003823def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003824 addr:$dst),
3825 (implicit EFLAGS)),
3826 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3827
Dan Gohman99a12192009-03-04 19:44:21 +00003828// Register-Register Subtraction with EFLAGS result
3829def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003830 (implicit EFLAGS)),
3831 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003832def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003833 (implicit EFLAGS)),
3834 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003835def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003836 (implicit EFLAGS)),
3837 (SUB32rr GR32:$src1, GR32:$src2)>;
3838
Dan Gohman99a12192009-03-04 19:44:21 +00003839// Register-Memory Subtraction with EFLAGS result
3840def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003841 (implicit EFLAGS)),
3842 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003843def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003844 (implicit EFLAGS)),
3845 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003846def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003847 (implicit EFLAGS)),
3848 (SUB32rm GR32:$src1, addr:$src2)>;
3849
Dan Gohman99a12192009-03-04 19:44:21 +00003850// Register-Integer Subtraction with EFLAGS result
3851def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003852 (implicit EFLAGS)),
3853 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003854def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003855 (implicit EFLAGS)),
3856 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003857def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003858 (implicit EFLAGS)),
3859 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003860def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003861 (implicit EFLAGS)),
3862 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003863def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003864 (implicit EFLAGS)),
3865 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3866
Dan Gohman99a12192009-03-04 19:44:21 +00003867// Memory-Register Subtraction with EFLAGS result
3868def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003869 addr:$dst),
3870 (implicit EFLAGS)),
3871 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003872def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003873 addr:$dst),
3874 (implicit EFLAGS)),
3875 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003876def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003877 addr:$dst),
3878 (implicit EFLAGS)),
3879 (SUB32mr addr:$dst, GR32:$src2)>;
3880
Dan Gohman99a12192009-03-04 19:44:21 +00003881// Memory-Integer Subtraction with EFLAGS result
3882def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003883 addr:$dst),
3884 (implicit EFLAGS)),
3885 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003886def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003887 addr:$dst),
3888 (implicit EFLAGS)),
3889 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003890def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003891 addr:$dst),
3892 (implicit EFLAGS)),
3893 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003894def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003895 addr:$dst),
3896 (implicit EFLAGS)),
3897 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003898def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003899 addr:$dst),
3900 (implicit EFLAGS)),
3901 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3902
3903
Dan Gohman99a12192009-03-04 19:44:21 +00003904// Register-Register Signed Integer Multiply with EFLAGS result
3905def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003906 (implicit EFLAGS)),
3907 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003908def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003909 (implicit EFLAGS)),
3910 (IMUL32rr GR32:$src1, GR32:$src2)>;
3911
Dan Gohman99a12192009-03-04 19:44:21 +00003912// Register-Memory Signed Integer Multiply with EFLAGS result
3913def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003914 (implicit EFLAGS)),
3915 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003916def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003917 (implicit EFLAGS)),
3918 (IMUL32rm GR32:$src1, addr:$src2)>;
3919
Dan Gohman99a12192009-03-04 19:44:21 +00003920// Register-Integer Signed Integer Multiply with EFLAGS result
3921def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003922 (implicit EFLAGS)),
3923 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003924def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003925 (implicit EFLAGS)),
3926 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003927def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003928 (implicit EFLAGS)),
3929 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003930def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003931 (implicit EFLAGS)),
3932 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3933
Dan Gohman99a12192009-03-04 19:44:21 +00003934// Memory-Integer Signed Integer Multiply with EFLAGS result
3935def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003936 (implicit EFLAGS)),
3937 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003938def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003939 (implicit EFLAGS)),
3940 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003941def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003942 (implicit EFLAGS)),
3943 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003944def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003945 (implicit EFLAGS)),
3946 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3947
Dan Gohman99a12192009-03-04 19:44:21 +00003948// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003949let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003950def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003951 (implicit EFLAGS)),
3952 (ADD16rr GR16:$src1, GR16:$src1)>;
3953
Dan Gohman99a12192009-03-04 19:44:21 +00003954def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003955 (implicit EFLAGS)),
3956 (ADD32rr GR32:$src1, GR32:$src1)>;
3957}
3958
Dan Gohman99a12192009-03-04 19:44:21 +00003959// INC and DEC with EFLAGS result. Note that these do not set CF.
3960def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3961 (INC8r GR8:$src)>;
3962def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3963 (implicit EFLAGS)),
3964 (INC8m addr:$dst)>;
3965def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3966 (DEC8r GR8:$src)>;
3967def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3968 (implicit EFLAGS)),
3969 (DEC8m addr:$dst)>;
3970
3971def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003972 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003973def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3974 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003975 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003976def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003977 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003978def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3979 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003980 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003981
3982def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003983 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003984def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3985 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003986 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003987def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003988 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003989def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3990 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003991 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003992
Bill Wendlingf5399032008-12-12 21:15:41 +00003993//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003994// Floating Point Stack Support
3995//===----------------------------------------------------------------------===//
3996
3997include "X86InstrFPStack.td"
3998
3999//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00004000// X86-64 Support
4001//===----------------------------------------------------------------------===//
4002
Chris Lattner2de8d2b2008-01-10 05:50:42 +00004003include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00004004
4005//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004006// XMM Floating point support (requires SSE / SSE2)
4007//===----------------------------------------------------------------------===//
4008
4009include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00004010
4011//===----------------------------------------------------------------------===//
4012// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
4013//===----------------------------------------------------------------------===//
4014
4015include "X86InstrMMX.td"