blob: 03df10db61c5480290626edbb233854216a05299 [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
221//===----------------------------------------------------------------------===//
222// X86 Complex Pattern Definitions.
223//
224
225// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000226def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000227def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman946223f2009-05-11 18:02:53 +0000228 [add, sub, mul, shl, or, frameindex], []>;
Chris Lattnerf1940742009-06-20 20:38:48 +0000229def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
230 [tglobaltlsaddr], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231
232//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233// X86 Instruction Predicate Definitions.
234def HasMMX : Predicate<"Subtarget->hasMMX()">;
235def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
236def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
237def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
238def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000239def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
240def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene8bf22bc2009-06-26 22:46:54 +0000241def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
242def HasAVX : Predicate<"Subtarget->hasAVX()">;
243def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
244def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000245def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
246def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
248def In64BitMode : Predicate<"Subtarget->is64Bit()">;
249def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
250def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
251def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000252def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000253def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000254def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255
256//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000257// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000258//
259
Evan Cheng86ab7d32007-07-31 08:04:03 +0000260include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000261
262//===----------------------------------------------------------------------===//
263// Pattern fragments...
264//
265
266// X86 specific condition code. These correspond to CondCode in
267// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000268def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
269def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
270def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
271def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
272def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
273def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
274def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
275def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
276def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
277def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000278def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000279def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000281def X86_COND_O : PatLeaf<(i8 13)>;
282def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
283def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284
285def i16immSExt8 : PatLeaf<(i16 imm), [{
286 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
287 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000288 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000289}]>;
290
291def i32immSExt8 : PatLeaf<(i32 imm), [{
292 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
293 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000294 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295}]>;
296
297// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000298// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
299// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000300def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000301 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000302 if (const Value *Src = LD->getSrcValue())
303 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000304 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000305 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000306 ISD::LoadExtType ExtType = LD->getExtensionType();
307 if (ExtType == ISD::NON_EXTLOAD)
308 return true;
309 if (ExtType == ISD::EXTLOAD)
310 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000311 return false;
312}]>;
313
Dan Gohman2a174122008-10-15 06:50:19 +0000314def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000315 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000316 if (const Value *Src = LD->getSrcValue())
317 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000318 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000319 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000320 ISD::LoadExtType ExtType = LD->getExtensionType();
321 if (ExtType == ISD::EXTLOAD)
322 return LD->getAlignment() >= 2 && !LD->isVolatile();
323 return false;
324}]>;
325
Dan Gohman2a174122008-10-15 06:50:19 +0000326def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000327 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000328 if (const Value *Src = LD->getSrcValue())
329 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000330 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000331 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000332 ISD::LoadExtType ExtType = LD->getExtensionType();
333 if (ExtType == ISD::NON_EXTLOAD)
334 return true;
335 if (ExtType == ISD::EXTLOAD)
336 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000337 return false;
338}]>;
339
Dan Gohman2a174122008-10-15 06:50:19 +0000340def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000341 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000342 if (const Value *Src = LD->getSrcValue())
343 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000344 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000345 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000346 if (LD->isVolatile())
347 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000348 ISD::LoadExtType ExtType = LD->getExtensionType();
349 if (ExtType == ISD::NON_EXTLOAD)
350 return true;
351 if (ExtType == ISD::EXTLOAD)
352 return LD->getAlignment() >= 4;
353 return false;
354}]>;
355
sampo9cc09a32009-01-26 01:24:32 +0000356def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000357 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
358 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
359 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000360 return false;
361}]>;
362
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000363def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
364 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
365 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
366 return PT->getAddressSpace() == 257;
367 return false;
368}]>;
369
Chris Lattner12208612009-04-10 00:16:23 +0000370def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
371 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
372 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000373 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000374 return false;
375 return true;
376}]>;
377def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
378 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
379 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000380 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000381 return false;
382 return true;
383}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000384
Chris Lattner12208612009-04-10 00:16:23 +0000385def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
386 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
387 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000388 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000389 return false;
390 return true;
391}]>;
392def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
393 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
394 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000395 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000396 return false;
397 return true;
398}]>;
399def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
400 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
401 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000402 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000403 return false;
404 return true;
405}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
408def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
409def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
410
411def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
412def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
413def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
414def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
415def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
416def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
417
418def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
419def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
420def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
421def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
422def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
423def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
424
Chris Lattner21da6382008-02-19 17:37:35 +0000425
426// An 'and' node with a single use.
427def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000428 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000429}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000430// An 'srl' node with a single use.
431def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
432 return N->hasOneUse();
433}]>;
434// An 'trunc' node with a single use.
435def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
436 return N->hasOneUse();
437}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000438
Dan Gohman921581d2008-10-17 01:23:35 +0000439// 'shld' and 'shrd' instruction patterns. Note that even though these have
440// the srl and shl in their patterns, the C++ code must still check for them,
441// because predicates are tested before children nodes are explored.
442
443def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
444 (or (srl node:$src1, node:$amt1),
445 (shl node:$src2, node:$amt2)), [{
446 assert(N->getOpcode() == ISD::OR);
447 return N->getOperand(0).getOpcode() == ISD::SRL &&
448 N->getOperand(1).getOpcode() == ISD::SHL &&
449 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
450 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
451 N->getOperand(0).getConstantOperandVal(1) ==
452 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
453}]>;
454
455def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
456 (or (shl node:$src1, node:$amt1),
457 (srl node:$src2, node:$amt2)), [{
458 assert(N->getOpcode() == ISD::OR);
459 return N->getOperand(0).getOpcode() == ISD::SHL &&
460 N->getOperand(1).getOpcode() == ISD::SRL &&
461 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
462 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
463 N->getOperand(0).getConstantOperandVal(1) ==
464 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
465}]>;
466
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000467//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468// Instruction list...
469//
470
471// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
472// a stack adjustment and the codegen must know that they may modify the stack
473// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000474// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
475// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000476let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000477def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
478 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000479 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000480 Requires<[In32BitMode]>;
481def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
482 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000483 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000484 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000485}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000486
487// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000488let neverHasSideEffects = 1 in
489 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000490
Evan Cheng0729ccf2008-01-05 00:41:47 +0000491// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000492let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000493 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman70a8a112009-04-27 15:13:28 +0000494 "call\t$label\n\t"
495 "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000496
497//===----------------------------------------------------------------------===//
498// Control Flow Instructions...
499//
500
501// Return instructions.
502let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000503 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000504 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000505 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000506 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000507 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
508 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509 [(X86retflag imm:$amt)]>;
510}
511
512// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000513let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000514 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
515 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000517let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000518 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519
Owen Andersonf8053082007-11-12 07:39:39 +0000520// Indirect branches
521let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000522 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000523 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000524 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525 [(brind (loadi32 addr:$dst))]>;
526}
527
528// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000529let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000530def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000531 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000532def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000533 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000534def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000535 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000536def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000537 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000538def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000539 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000540def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000541 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542
Dan Gohman91888f02007-07-31 20:11:57 +0000543def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000544 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000545def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000546 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000547def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000548 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000549def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000550 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000551
Dan Gohman91888f02007-07-31 20:11:57 +0000552def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000553 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000554def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000555 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000556def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000557 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000558def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000559 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000560def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000561 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000562def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000563 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000564} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000565
566//===----------------------------------------------------------------------===//
567// Call Instructions...
568//
Evan Cheng37e7c752007-07-21 00:34:19 +0000569let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000570 // All calls clobber the non-callee saved registers. ESP is marked as
571 // a use to prevent stack-pointer assignments that appear immediately
572 // before calls from potentially appearing dead. Uses for argument
573 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000574 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
575 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000576 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
577 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000578 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000579 def CALLpcrel32 : Ii32<0xE8, RawFrm,
580 (outs), (ins i32imm_pcrel:$dst,variable_ops),
581 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000582 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000583 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000584 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000585 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586 }
587
588// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000589
Chris Lattnerb56cc342008-03-11 03:23:40 +0000590def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000591 "#TAILCALL",
592 []>;
593
Evan Cheng37e7c752007-07-21 00:34:19 +0000594let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000595def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000596 "#TC_RETURN $dst $offset",
597 []>;
598
599let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000600def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000601 "#TC_RETURN $dst $offset",
602 []>;
603
604let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000605
Chris Lattner357a0ca2009-06-20 19:34:09 +0000606 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000607 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000608let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000609 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
610 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000611let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000612 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000613 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000614
615//===----------------------------------------------------------------------===//
616// Miscellaneous Instructions...
617//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000618let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000620 (outs), (ins), "leave", []>;
621
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000622let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
623let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000624def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000626let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000627def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000628}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000629
Bill Wendling4c2638c2009-06-15 19:39:04 +0000630let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
631def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000632 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000633def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000634 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000635def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000636 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000637}
638
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000639let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000640def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000641let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000642def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000643
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000644let isTwoAddress = 1 in // GR32 = bswap GR32
645 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000646 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000647 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
649
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000650
Evan Cheng48679f42007-12-14 02:13:44 +0000651// Bit scan instructions.
652let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000653def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000654 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000655 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000656def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000657 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000658 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
659 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000660def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000661 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000662 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000663def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000664 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000665 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
666 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000667
Evan Cheng4e33de92007-12-14 18:49:43 +0000668def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000669 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000670 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000671def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000672 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000673 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
674 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000675def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000676 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000677 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000678def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000679 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000680 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
681 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000682} // Defs = [EFLAGS]
683
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000684let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000685def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000686 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000687 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000688let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000689def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000690 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000691 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
693
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000694let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000695def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000696 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000697def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000698 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000699def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000700 [(X86rep_movs i32)]>, REP;
701}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000703let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000704def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000705 [(X86rep_stos i8)]>, REP;
706let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000707def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000708 [(X86rep_stos i16)]>, REP, OpSize;
709let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000710def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000711 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000713let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000714def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000715 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000717let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000718def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000719}
720
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721//===----------------------------------------------------------------------===//
722// Input/Output Instructions...
723//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000724let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000725def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000726 "in{b}\t{%dx, %al|%AL, %DX}", []>;
727let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000728def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000729 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
730let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000731def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000732 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000733
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000734let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000735def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000736 "in{b}\t{$port, %al|%AL, $port}", []>;
737let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000738def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000739 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
740let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000741def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000742 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000744let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000745def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000746 "out{b}\t{%al, %dx|%DX, %AL}", []>;
747let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000748def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000749 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
750let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000751def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000752 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000754let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000755def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000756 "out{b}\t{%al, $port|$port, %AL}", []>;
757let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000758def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000759 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
760let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000761def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000762 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763
764//===----------------------------------------------------------------------===//
765// Move Instructions...
766//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000767let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000768def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000769 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000770def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000771 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000772def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000773 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000774}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000775let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000776def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000777 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000779def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000780 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000781 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000782def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000783 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784 [(set GR32:$dst, imm:$src)]>;
785}
Evan Chengb783fa32007-07-19 01:14:50 +0000786def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000787 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000789def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000790 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000792def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000793 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000794 [(store (i32 imm:$src), addr:$dst)]>;
795
Dan Gohman5574cc72008-12-03 18:15:48 +0000796let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000797def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000798 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000799 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000800def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000801 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000802 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000803def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000804 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000805 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000806}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807
Evan Chengb783fa32007-07-19 01:14:50 +0000808def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000809 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000811def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000812 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000814def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000815 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000817
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000818// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
819// that they can be used for copying and storing h registers, which can't be
820// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000821let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000822def MOV8rr_NOREX : I<0x88, MRMDestReg,
823 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000824 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000825let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000826def MOV8mr_NOREX : I<0x88, MRMDestMem,
827 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
828 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000829let mayLoad = 1,
830 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000831def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
832 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
833 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000834
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835//===----------------------------------------------------------------------===//
836// Fixed-Register Multiplication and Division Instructions...
837//
838
839// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000840let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000841def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
843 // This probably ought to be moved to a def : Pat<> if the
844 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000845 [(set AL, (mul AL, GR8:$src)),
846 (implicit EFLAGS)]>; // AL,AH = AL*GR8
847
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000848let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000849def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
850 "mul{w}\t$src",
851 []>, OpSize; // AX,DX = AX*GR16
852
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000853let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000854def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
855 "mul{l}\t$src",
856 []>; // EAX,EDX = EAX*GR32
857
Evan Cheng55687072007-09-14 21:48:26 +0000858let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000859def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000860 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
862 // This probably ought to be moved to a def : Pat<> if the
863 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000864 [(set AL, (mul AL, (loadi8 addr:$src))),
865 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
866
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000867let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000868let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000869def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000870 "mul{w}\t$src",
871 []>, OpSize; // AX,DX = AX*[mem16]
872
Evan Cheng55687072007-09-14 21:48:26 +0000873let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000874def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000875 "mul{l}\t$src",
876 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000877}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000878
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000879let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000880let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000881def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
882 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000883let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000884def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000885 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000886let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000887def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
888 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000889let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000890let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000891def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000892 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000893let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000894def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000895 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
896let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000897def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000898 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000899}
Dan Gohmand44572d2008-11-18 21:29:14 +0000900} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901
902// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000903let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000904def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000905 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000906let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000907def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000908 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000909let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000910def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000911 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000912let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000913let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000914def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000915 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000916let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000917def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000918 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000919let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000920def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000921 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000922}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923
924// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000925let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000926def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000927 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000928let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000929def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000930 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000931let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000932def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000933 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000934let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000935let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000936def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000937 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000938let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000939def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000940 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000941let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000942def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000943 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000944}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945
946//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000947// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948//
949let isTwoAddress = 1 in {
950
951// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000952let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000953let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000955 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000956 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000958 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000961 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000964 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000967 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000968 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000970 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000972def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000973 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000974 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000976 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000979 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000980 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000982 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000985 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000986 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000988 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000991 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000992 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000994 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000995 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000997 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000998 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001000 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001003 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001004 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001006 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001009 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001010 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001012 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001015 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001016 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001017 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001018 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001021 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001022 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001024 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001027 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001028 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001030 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001033 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001034 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001036 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001038def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001039 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001040 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001042 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001045 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001046 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001048 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001049 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001051 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001052 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001054 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001057 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001058 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001060 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001063 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001064 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001066 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001069 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001070 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001072 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001075 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001076 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001078 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001080def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001081 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001082 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001084 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001087 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001088 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001090 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001092def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001093 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001094 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001096 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001099 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001100 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001101 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001102 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001103 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001105 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001106 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001107 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001108 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001110def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001111 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001112 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001114 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001116def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001117 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001118 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001120 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001122def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1123 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1124 "cmovo\t{$src2, $dst|$dst, $src2}",
1125 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1126 X86_COND_O, EFLAGS))]>,
1127 TB, OpSize;
1128def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1129 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1130 "cmovo\t{$src2, $dst|$dst, $src2}",
1131 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1132 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001133 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001134def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1135 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1136 "cmovno\t{$src2, $dst|$dst, $src2}",
1137 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1138 X86_COND_NO, EFLAGS))]>,
1139 TB, OpSize;
1140def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1141 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1142 "cmovno\t{$src2, $dst|$dst, $src2}",
1143 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1144 X86_COND_NO, EFLAGS))]>,
1145 TB;
1146} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001147
1148def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1149 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1150 "cmovb\t{$src2, $dst|$dst, $src2}",
1151 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1152 X86_COND_B, EFLAGS))]>,
1153 TB, OpSize;
1154def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1155 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1156 "cmovb\t{$src2, $dst|$dst, $src2}",
1157 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1158 X86_COND_B, EFLAGS))]>,
1159 TB;
1160def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1161 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1162 "cmovae\t{$src2, $dst|$dst, $src2}",
1163 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1164 X86_COND_AE, EFLAGS))]>,
1165 TB, OpSize;
1166def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1167 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1168 "cmovae\t{$src2, $dst|$dst, $src2}",
1169 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1170 X86_COND_AE, EFLAGS))]>,
1171 TB;
1172def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1173 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1174 "cmove\t{$src2, $dst|$dst, $src2}",
1175 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1176 X86_COND_E, EFLAGS))]>,
1177 TB, OpSize;
1178def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1179 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1180 "cmove\t{$src2, $dst|$dst, $src2}",
1181 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1182 X86_COND_E, EFLAGS))]>,
1183 TB;
1184def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1185 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1186 "cmovne\t{$src2, $dst|$dst, $src2}",
1187 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1188 X86_COND_NE, EFLAGS))]>,
1189 TB, OpSize;
1190def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1191 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1192 "cmovne\t{$src2, $dst|$dst, $src2}",
1193 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1194 X86_COND_NE, EFLAGS))]>,
1195 TB;
1196def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1197 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1198 "cmovbe\t{$src2, $dst|$dst, $src2}",
1199 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1200 X86_COND_BE, EFLAGS))]>,
1201 TB, OpSize;
1202def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1203 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1204 "cmovbe\t{$src2, $dst|$dst, $src2}",
1205 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1206 X86_COND_BE, EFLAGS))]>,
1207 TB;
1208def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1209 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1210 "cmova\t{$src2, $dst|$dst, $src2}",
1211 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1212 X86_COND_A, EFLAGS))]>,
1213 TB, OpSize;
1214def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1215 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1216 "cmova\t{$src2, $dst|$dst, $src2}",
1217 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1218 X86_COND_A, EFLAGS))]>,
1219 TB;
1220def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1221 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1222 "cmovl\t{$src2, $dst|$dst, $src2}",
1223 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1224 X86_COND_L, EFLAGS))]>,
1225 TB, OpSize;
1226def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1227 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1228 "cmovl\t{$src2, $dst|$dst, $src2}",
1229 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1230 X86_COND_L, EFLAGS))]>,
1231 TB;
1232def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1233 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1234 "cmovge\t{$src2, $dst|$dst, $src2}",
1235 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1236 X86_COND_GE, EFLAGS))]>,
1237 TB, OpSize;
1238def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1239 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1240 "cmovge\t{$src2, $dst|$dst, $src2}",
1241 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1242 X86_COND_GE, EFLAGS))]>,
1243 TB;
1244def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1245 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1246 "cmovle\t{$src2, $dst|$dst, $src2}",
1247 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1248 X86_COND_LE, EFLAGS))]>,
1249 TB, OpSize;
1250def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1251 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1252 "cmovle\t{$src2, $dst|$dst, $src2}",
1253 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1254 X86_COND_LE, EFLAGS))]>,
1255 TB;
1256def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1257 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1258 "cmovg\t{$src2, $dst|$dst, $src2}",
1259 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1260 X86_COND_G, EFLAGS))]>,
1261 TB, OpSize;
1262def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1263 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1264 "cmovg\t{$src2, $dst|$dst, $src2}",
1265 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1266 X86_COND_G, EFLAGS))]>,
1267 TB;
1268def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1269 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1270 "cmovs\t{$src2, $dst|$dst, $src2}",
1271 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1272 X86_COND_S, EFLAGS))]>,
1273 TB, OpSize;
1274def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1275 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1276 "cmovs\t{$src2, $dst|$dst, $src2}",
1277 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1278 X86_COND_S, EFLAGS))]>,
1279 TB;
1280def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1281 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1282 "cmovns\t{$src2, $dst|$dst, $src2}",
1283 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1284 X86_COND_NS, EFLAGS))]>,
1285 TB, OpSize;
1286def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1287 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1288 "cmovns\t{$src2, $dst|$dst, $src2}",
1289 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1290 X86_COND_NS, EFLAGS))]>,
1291 TB;
1292def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1293 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1294 "cmovp\t{$src2, $dst|$dst, $src2}",
1295 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1296 X86_COND_P, EFLAGS))]>,
1297 TB, OpSize;
1298def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1299 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1300 "cmovp\t{$src2, $dst|$dst, $src2}",
1301 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1302 X86_COND_P, EFLAGS))]>,
1303 TB;
1304def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1305 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1306 "cmovnp\t{$src2, $dst|$dst, $src2}",
1307 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1308 X86_COND_NP, EFLAGS))]>,
1309 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001310def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1311 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1312 "cmovnp\t{$src2, $dst|$dst, $src2}",
1313 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1314 X86_COND_NP, EFLAGS))]>,
1315 TB;
1316def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1317 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1318 "cmovo\t{$src2, $dst|$dst, $src2}",
1319 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1320 X86_COND_O, EFLAGS))]>,
1321 TB, OpSize;
1322def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1323 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1324 "cmovo\t{$src2, $dst|$dst, $src2}",
1325 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1326 X86_COND_O, EFLAGS))]>,
1327 TB;
1328def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1329 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1330 "cmovno\t{$src2, $dst|$dst, $src2}",
1331 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1332 X86_COND_NO, EFLAGS))]>,
1333 TB, OpSize;
1334def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1335 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1336 "cmovno\t{$src2, $dst|$dst, $src2}",
1337 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1338 X86_COND_NO, EFLAGS))]>,
1339 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001340} // Uses = [EFLAGS]
1341
1342
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343// unary instructions
1344let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001345let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001346def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001347 [(set GR8:$dst, (ineg GR8:$src)),
1348 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001349def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001350 [(set GR16:$dst, (ineg GR16:$src)),
1351 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001352def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001353 [(set GR32:$dst, (ineg GR32:$src)),
1354 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001356 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001357 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1358 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001359 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001360 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1361 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001362 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001363 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1364 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365}
Evan Cheng55687072007-09-14 21:48:26 +00001366} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367
Evan Chengc6cee682009-01-21 02:09:05 +00001368// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1369let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001370def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001372def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001374def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001375 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001376}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001378 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001379 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001380 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001382 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001383 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1384}
1385} // CodeSize
1386
1387// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001388let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001390def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001391 [(set GR8:$dst, (add GR8:$src, 1)),
1392 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001394def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001395 [(set GR16:$dst, (add GR16:$src, 1)),
1396 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001397 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001398def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001399 [(set GR32:$dst, (add GR32:$src, 1)),
1400 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001401}
1402let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001403 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001404 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1405 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001406 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001407 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1408 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001409 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001410 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001411 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1412 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001413 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001414}
1415
1416let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001417def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001418 [(set GR8:$dst, (add GR8:$src, -1)),
1419 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001420let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001421def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001422 [(set GR16:$dst, (add GR16:$src, -1)),
1423 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001424 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001425def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001426 [(set GR32:$dst, (add GR32:$src, -1)),
1427 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428}
1429
1430let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001431 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001432 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1433 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001434 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001435 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1436 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001437 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001438 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001439 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1440 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001441 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442}
Evan Cheng55687072007-09-14 21:48:26 +00001443} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001444
1445// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001446let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1448def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001449 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001451 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1452 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001453def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001454 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001455 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001456 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1457 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001458def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001459 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001460 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001461 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1462 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001463}
1464
1465def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001466 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001467 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001468 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001469 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001470def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001471 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001472 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001473 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001474 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001475def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001476 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001477 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001478 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001479 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001480
1481def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001482 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001483 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001484 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1485 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001487 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001488 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001489 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1490 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001491def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001492 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001493 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001494 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1495 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001496def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001497 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001498 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001499 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1500 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501 OpSize;
1502def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001503 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001504 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001505 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1506 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001507
1508let isTwoAddress = 0 in {
1509 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001510 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001511 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001512 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1513 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001514 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001515 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001516 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001517 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1518 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001519 OpSize;
1520 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001521 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001522 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001523 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1524 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001526 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001527 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001528 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1529 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001531 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001532 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001533 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1534 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001535 OpSize;
1536 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001537 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001538 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001539 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1540 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001541 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001542 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001543 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001544 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1545 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001546 OpSize;
1547 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001548 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001549 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001550 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1551 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001552}
1553
1554
1555let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001556def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001557 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001558 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1559 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001560def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001561 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001562 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1563 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001564def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001565 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001566 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1567 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001568}
Evan Chengb783fa32007-07-19 01:14:50 +00001569def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001570 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001571 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1572 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001573def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001574 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001575 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1576 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001577def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001578 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001579 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1580 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581
Evan Chengb783fa32007-07-19 01:14:50 +00001582def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001583 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001584 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1585 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001586def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001587 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001588 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1589 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001590def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001591 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001592 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1593 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001594
Evan Chengb783fa32007-07-19 01:14:50 +00001595def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001596 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001597 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1598 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001599def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001600 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001601 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1602 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001604 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001605 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001606 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1607 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001608 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001609 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001610 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1611 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001612 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001613 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001614 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1615 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001616 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001617 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001618 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1619 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001620 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001621 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001622 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1623 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001624 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001625 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001626 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001627 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1628 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001629 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001630 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001631 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1632 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001633 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001634 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001635 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001636 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1637 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001638} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639
1640
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001641let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001642 def XOR8rr : I<0x30, MRMDestReg,
1643 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1644 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001645 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1646 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001647 def XOR16rr : I<0x31, MRMDestReg,
1648 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1649 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001650 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1651 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001652 def XOR32rr : I<0x31, MRMDestReg,
1653 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1654 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001655 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1656 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001657} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001658
1659def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001660 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001661 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001662 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1663 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001664def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001665 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001666 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001667 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1668 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001669 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001670def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001671 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001672 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001673 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1674 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001675
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001676def XOR8ri : Ii8<0x80, MRM6r,
1677 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1678 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001679 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1680 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001681def XOR16ri : Ii16<0x81, MRM6r,
1682 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1683 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001684 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1685 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001686def XOR32ri : Ii32<0x81, MRM6r,
1687 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1688 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001689 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1690 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001691def XOR16ri8 : Ii8<0x83, MRM6r,
1692 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1693 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001694 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1695 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001696 OpSize;
1697def XOR32ri8 : Ii8<0x83, MRM6r,
1698 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1699 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001700 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1701 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001702
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703let isTwoAddress = 0 in {
1704 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001705 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001707 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1708 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001709 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001710 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001712 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1713 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001714 OpSize;
1715 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001716 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001717 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001718 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1719 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001720 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001721 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001722 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001723 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1724 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001726 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001727 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001728 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1729 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001730 OpSize;
1731 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001732 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001733 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001734 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1735 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001736 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001737 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001738 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001739 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1740 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741 OpSize;
1742 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001743 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001744 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001745 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1746 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001747} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001748} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001749
1750// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001751let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001752let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001753def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001754 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001755 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001756def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001757 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001758 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001759def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001760 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001761 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001762} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001763
Evan Chengb783fa32007-07-19 01:14:50 +00001764def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001765 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1767let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001768def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001771def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001772 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001773 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001774// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1775// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001776} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001777
1778let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001779 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001780 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001781 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001782 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001783 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001784 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001785 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001786 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001787 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001788 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1789 }
Evan Chengb783fa32007-07-19 01:14:50 +00001790 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001791 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001793 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001795 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1796 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001797 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001798 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1800
1801 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001802 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001803 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001804 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001805 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001807 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1808 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001809 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001810 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001811 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1812}
1813
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001814let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001815def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001816 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001817 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001818def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001819 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001820 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001821def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001822 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001823 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1824}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001825
Evan Chengb783fa32007-07-19 01:14:50 +00001826def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001827 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001828 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001829def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001830 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001831 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001832def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001833 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001834 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1835
1836// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001837def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001838 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001839 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001840def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001842 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001843def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001844 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1846
1847let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001848 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001849 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001850 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001851 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001852 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001853 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001855 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001856 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001857 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001858 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1859 }
Evan Chengb783fa32007-07-19 01:14:50 +00001860 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001863 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001864 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001865 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1866 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001867 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001868 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1870
1871 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001872 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001873 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001874 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001875 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001876 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001877 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001878 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001879 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001880 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1881}
1882
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001883let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001884def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001885 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001886 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001887def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001888 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001889 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001890def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001891 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001892 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1893}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001894
Evan Chengb783fa32007-07-19 01:14:50 +00001895def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001896 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001897 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001898def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001900 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1901 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001902def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001903 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001904 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1905
1906// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001907def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001910def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001911 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001912 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001913def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001914 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1916
1917let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001918 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001919 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001920 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001921 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001922 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001923 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001924 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001925 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001926 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001927 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1928 }
Evan Chengb783fa32007-07-19 01:14:50 +00001929 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001930 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001932 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001934 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1935 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001936 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001937 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001938 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1939
1940 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001941 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001942 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001944 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001945 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001946 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1947 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001948 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001949 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1951}
1952
1953// Rotate instructions
1954// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001955let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001956def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001957 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001958 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001959def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001960 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001961 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001962def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001963 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001964 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1965}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001966
Evan Chengb783fa32007-07-19 01:14:50 +00001967def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001970def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001971 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001973def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001974 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1976
1977// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001978def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001981def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001983 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001984def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001985 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001986 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1987
1988let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001989 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001990 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001991 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001992 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001993 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001994 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001995 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001996 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001997 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001998 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1999 }
Evan Chengb783fa32007-07-19 01:14:50 +00002000 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002001 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002003 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2006 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002007 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2010
2011 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002012 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002015 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002016 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2018 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002019 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002020 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002021 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2022}
2023
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002024let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002025def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002026 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002027 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002028def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002029 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002030 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002031def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002032 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002033 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2034}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002035
Evan Chengb783fa32007-07-19 01:14:50 +00002036def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002037 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002038 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002039def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002040 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002042def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002043 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2045
2046// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002047def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002048 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002050def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002051 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002052 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002053def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002054 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2056
2057let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002058 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002059 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002060 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002061 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002062 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002063 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002064 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002065 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002066 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002067 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2068 }
Evan Chengb783fa32007-07-19 01:14:50 +00002069 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002070 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002072 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2075 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002076 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002077 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2079
2080 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002081 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002082 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002083 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002084 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002086 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2087 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002088 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002089 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002090 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2091}
2092
2093
2094
2095// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002096let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002097def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002098 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002099 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002100def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002101 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002102 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002103def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002104 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002105 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002106 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002107def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002108 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002110 TB, OpSize;
2111}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112
2113let isCommutable = 1 in { // These instructions commute to each other.
2114def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002115 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002116 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002117 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2118 (i8 imm:$src3)))]>,
2119 TB;
2120def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002121 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002122 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2124 (i8 imm:$src3)))]>,
2125 TB;
2126def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002127 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002129 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2130 (i8 imm:$src3)))]>,
2131 TB, OpSize;
2132def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002133 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002134 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002135 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2136 (i8 imm:$src3)))]>,
2137 TB, OpSize;
2138}
2139
2140let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002141 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002142 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002143 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002145 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002146 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002147 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002149 addr:$dst)]>, TB;
2150 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002152 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002153 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002154 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2155 (i8 imm:$src3)), addr:$dst)]>,
2156 TB;
2157 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002158 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2161 (i8 imm:$src3)), addr:$dst)]>,
2162 TB;
2163
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002164 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002165 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002166 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002168 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002169 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002170 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002172 addr:$dst)]>, TB, OpSize;
2173 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002175 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002176 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002177 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2178 (i8 imm:$src3)), addr:$dst)]>,
2179 TB, OpSize;
2180 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002181 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002182 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002183 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2184 (i8 imm:$src3)), addr:$dst)]>,
2185 TB, OpSize;
2186}
Evan Cheng55687072007-09-14 21:48:26 +00002187} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188
2189
2190// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002191let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002192let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002193// Register-Register Addition
2194def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2195 (ins GR8 :$src1, GR8 :$src2),
2196 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002197 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002198 (implicit EFLAGS)]>;
2199
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002200let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002201// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002202def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2203 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002204 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002205 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2206 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002207def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2208 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002209 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002210 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2211 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002212} // end isConvertibleToThreeAddress
2213} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002214
2215// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002216def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2217 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002219 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2220 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002221def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2222 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002224 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2225 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002226def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2227 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002228 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002229 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2230 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002231
Bill Wendlingae034ed2008-12-12 00:56:36 +00002232// Register-Integer Addition
2233def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2234 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002235 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2236 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002237
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002238let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002239// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002240def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2241 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002242 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002243 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2244 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002245def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2246 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002247 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002248 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2249 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002250def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2251 (ins GR16:$src1, i16i8imm:$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, i16immSExt8:$src2)),
2254 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002255def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2256 (ins GR32:$src1, i32i8imm:$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, i32immSExt8:$src2)),
2259 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002260}
2261
2262let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002263 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002264 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002266 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2267 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002268 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002269 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002270 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2271 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002272 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002273 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002274 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2275 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002276 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002277 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002278 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2279 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002280 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002281 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002282 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2283 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002284 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002285 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002286 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2287 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002288 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002289 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002290 [(store (add (load addr:$dst), i16immSExt8:$src2),
2291 addr:$dst),
2292 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002293 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002294 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002295 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002296 addr:$dst),
2297 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002298}
2299
Evan Cheng259471d2007-10-05 17:59:57 +00002300let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002301let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002302def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002303 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002304 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002305def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2306 (ins GR16:$src1, GR16:$src2),
2307 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002308 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002309def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2310 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002311 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002312 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002313}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002314def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2315 (ins GR8:$src1, i8mem:$src2),
2316 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002317 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002318def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2319 (ins GR16:$src1, i16mem:$src2),
2320 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002321 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002322 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002323def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2324 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002325 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002326 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2327def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002328 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002329 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002330def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2331 (ins GR16:$src1, i16imm:$src2),
2332 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002333 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002334def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2335 (ins GR16:$src1, i16i8imm:$src2),
2336 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002337 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2338 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002339def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2340 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002341 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002342 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002343def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2344 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002345 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002346 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002347
2348let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002349 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002350 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002351 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2352 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002353 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002354 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2355 OpSize;
2356 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002357 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002358 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2359 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002360 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002361 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2362 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002363 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002364 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2365 OpSize;
2366 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002367 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002368 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2369 OpSize;
2370 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002372 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2373 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, 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 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2376}
Evan Cheng259471d2007-10-05 17:59:57 +00002377} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002378
Bill Wendlingae034ed2008-12-12 00:56:36 +00002379// Register-Register Subtraction
2380def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2381 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002382 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2383 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002384def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2385 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002386 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2387 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002388def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2389 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002390 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2391 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002392
2393// Register-Memory Subtraction
2394def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2395 (ins GR8 :$src1, i8mem :$src2),
2396 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002397 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2398 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002399def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2400 (ins GR16:$src1, i16mem:$src2),
2401 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002402 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2403 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002404def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2405 (ins GR32:$src1, i32mem:$src2),
2406 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002407 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2408 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002409
2410// Register-Integer Subtraction
2411def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2412 (ins GR8:$src1, i8imm:$src2),
2413 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002414 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2415 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002416def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2417 (ins GR16:$src1, i16imm:$src2),
2418 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002419 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2420 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002421def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2422 (ins GR32:$src1, i32imm:$src2),
2423 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002424 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2425 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002426def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2427 (ins GR16:$src1, i16i8imm:$src2),
2428 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002429 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2430 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002431def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2432 (ins GR32:$src1, i32i8imm:$src2),
2433 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002434 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2435 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002436
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002437let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002438 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002439 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002440 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002441 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2442 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002443 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002444 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002445 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2446 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002447 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002448 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002449 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2450 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002451
2452 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002453 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002454 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002455 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2456 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002457 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002458 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002459 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2460 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002461 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002462 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002463 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2464 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002465 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002466 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002467 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002468 addr:$dst),
2469 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002470 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002471 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002472 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002473 addr:$dst),
2474 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002475}
2476
Evan Cheng259471d2007-10-05 17:59:57 +00002477let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002478def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2479 (ins GR8:$src1, GR8:$src2),
2480 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002481 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002482def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2483 (ins GR16:$src1, GR16:$src2),
2484 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002485 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002486def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2487 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002488 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002489 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002490
2491let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002492 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2493 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002494 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002495 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2496 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002497 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002498 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002499 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002500 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002501 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002502 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002503 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002504 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002505 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2506 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002507 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002508 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002509 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2510 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002511 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002512 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002513 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002514 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002515 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002516 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002517 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002518 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002519}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002520def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2521 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002522 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002523def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2524 (ins GR16:$src1, i16mem:$src2),
2525 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002526 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002527 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002528def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2529 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002530 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002531 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002532def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2533 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002534 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002535def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2536 (ins GR16:$src1, i16imm:$src2),
2537 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002538 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002539def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2540 (ins GR16:$src1, i16i8imm:$src2),
2541 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002542 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2543 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002544def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2545 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002546 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002547 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002548def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2549 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002550 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002551 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002552} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002553} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554
Evan Cheng55687072007-09-14 21:48:26 +00002555let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002556let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002557// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002558def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002559 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002560 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2561 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002562def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002563 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002564 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2565 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002566}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002567
Bill Wendlingf5399032008-12-12 21:15:41 +00002568// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002569def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2570 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002571 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002572 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2573 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002574def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002575 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002576 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2577 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002578} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002579} // end Two Address instructions
2580
2581// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002582let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002583// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002584def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002585 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002586 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002587 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2588 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002590 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002591 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002592 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2593 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002594def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002595 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002596 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002597 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2598 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002599def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002600 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002601 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002602 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2603 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002604
Bill Wendlingf5399032008-12-12 21:15:41 +00002605// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002606def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002607 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002608 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002609 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2610 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002611def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002612 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002613 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002614 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2615 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002616def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002617 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002618 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002619 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002620 i16immSExt8:$src2)),
2621 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002622def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002623 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002624 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002625 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002626 i32immSExt8:$src2)),
2627 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002628} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002629
2630//===----------------------------------------------------------------------===//
2631// Test instructions are just like AND, except they don't generate a result.
2632//
Evan Cheng950aac02007-09-25 01:57:46 +00002633let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002634let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002635def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002636 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002637 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002638 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002639def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002640 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002641 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002642 (implicit EFLAGS)]>,
2643 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002644def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002645 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002646 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002647 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002648}
2649
Evan Chengb783fa32007-07-19 01:14:50 +00002650def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002651 "test{b}\t{$src2, $src1|$src1, $src2}",
2652 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2653 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002654def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002655 "test{w}\t{$src2, $src1|$src1, $src2}",
2656 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2657 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002658def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002659 "test{l}\t{$src2, $src1|$src1, $src2}",
2660 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2661 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002662
2663def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002664 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002665 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002666 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002667 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002668def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002669 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002670 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002671 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002672 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002673def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002674 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002675 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002676 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002677 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002678
Evan Cheng621216e2007-09-29 00:00:36 +00002679def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002680 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002681 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002682 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2683 (implicit EFLAGS)]>;
2684def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002685 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002686 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002687 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2688 (implicit EFLAGS)]>, OpSize;
2689def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002690 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002691 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002692 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002693 (implicit EFLAGS)]>;
2694} // Defs = [EFLAGS]
2695
2696
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002697// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002698let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002699def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002700let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002701def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002702
Evan Cheng950aac02007-09-25 01:57:46 +00002703let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002704def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002705 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002706 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002707 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002708 TB; // GR8 = ==
2709def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002710 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002711 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002712 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002713 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002714
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002715def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002716 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002717 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002718 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002719 TB; // GR8 = !=
2720def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002721 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002722 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002723 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002724 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002725
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002726def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002727 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002728 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002729 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002730 TB; // GR8 = < signed
2731def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002732 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002733 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002734 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002735 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002736
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002737def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002738 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002739 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002740 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002741 TB; // GR8 = >= signed
2742def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002743 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002744 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002745 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002746 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002747
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002748def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002749 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002750 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002751 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002752 TB; // GR8 = <= signed
2753def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002754 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002755 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002756 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002757 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002758
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002759def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002760 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002761 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002762 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002763 TB; // GR8 = > signed
2764def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002765 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002766 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002767 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002768 TB; // [mem8] = > signed
2769
2770def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002771 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002772 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002773 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002774 TB; // GR8 = < unsign
2775def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002776 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002777 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002778 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002779 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002780
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002781def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002782 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002783 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002784 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002785 TB; // GR8 = >= unsign
2786def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002787 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002788 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002789 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002790 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002791
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002792def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002793 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002794 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002795 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002796 TB; // GR8 = <= unsign
2797def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002798 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002799 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002800 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002801 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002802
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002803def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002804 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002805 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002806 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002807 TB; // GR8 = > signed
2808def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002809 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002810 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002811 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002812 TB; // [mem8] = > signed
2813
2814def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002815 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002816 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002817 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002818 TB; // GR8 = <sign bit>
2819def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002820 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002821 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002822 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002823 TB; // [mem8] = <sign bit>
2824def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002825 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002826 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002827 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002828 TB; // GR8 = !<sign bit>
2829def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002830 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002831 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002832 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002833 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002834
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002835def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002836 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002837 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002838 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002839 TB; // GR8 = parity
2840def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002841 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002842 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002843 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002844 TB; // [mem8] = parity
2845def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002846 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002847 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002848 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002849 TB; // GR8 = not parity
2850def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002851 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002852 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002853 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002854 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002855
2856def SETOr : I<0x90, MRM0r,
2857 (outs GR8 :$dst), (ins),
2858 "seto\t$dst",
2859 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2860 TB; // GR8 = overflow
2861def SETOm : I<0x90, MRM0m,
2862 (outs), (ins i8mem:$dst),
2863 "seto\t$dst",
2864 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2865 TB; // [mem8] = overflow
2866def SETNOr : I<0x91, MRM0r,
2867 (outs GR8 :$dst), (ins),
2868 "setno\t$dst",
2869 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2870 TB; // GR8 = not overflow
2871def SETNOm : I<0x91, MRM0m,
2872 (outs), (ins i8mem:$dst),
2873 "setno\t$dst",
2874 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2875 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002876} // Uses = [EFLAGS]
2877
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002878
2879// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002880let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002881def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002882 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002883 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002884 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002885def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002886 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002887 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002888 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002889def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002890 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002891 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002892 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002893def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002894 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002895 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002896 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2897 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002898def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002899 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002900 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002901 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2902 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002903def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002904 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002905 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002906 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2907 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002908def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002909 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002910 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002911 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2912 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002913def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002914 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002915 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002916 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2917 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002918def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002919 (outs), (ins GR32:$src1, i32mem:$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, (loadi32 addr:$src2)),
2922 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002923def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002924 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002925 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002926 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002927def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002928 (outs), (ins GR16:$src1, i16imm:$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 GR16:$src1, imm:$src2),
2931 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002932def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002933 (outs), (ins GR32:$src1, i32imm:$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 GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002936def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002937 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002938 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002939 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2940 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002941def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002942 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002943 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002944 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2945 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002946def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002947 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002948 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002949 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2950 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002951def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002952 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002953 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002954 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2955 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002956def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002957 (outs), (ins i16mem:$src1, i16i8imm:$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 (loadi16 addr:$src1), i16immSExt8:$src2),
2960 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002961def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002962 (outs), (ins i32mem:$src1, i32i8imm:$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 (loadi32 addr:$src1), i32immSExt8:$src2),
2965 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002966def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002967 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002968 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002969 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002970 (implicit EFLAGS)]>;
2971} // Defs = [EFLAGS]
2972
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002973// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002974// TODO: BTC, BTR, and BTS
2975let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002976def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002977 "bt{w}\t{$src2, $src1|$src1, $src2}",
2978 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002979 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002980def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002981 "bt{l}\t{$src2, $src1|$src1, $src2}",
2982 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002983 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002984
2985// Unlike with the register+register form, the memory+register form of the
2986// bt instruction does not ignore the high bits of the index. From ISel's
2987// perspective, this is pretty bizarre. Disable these instructions for now.
2988//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2989// "bt{w}\t{$src2, $src1|$src1, $src2}",
2990// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2991// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2992//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2993// "bt{l}\t{$src2, $src1|$src1, $src2}",
2994// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2995// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002996
2997def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2998 "bt{w}\t{$src2, $src1|$src1, $src2}",
2999 [(X86bt GR16:$src1, i16immSExt8:$src2),
3000 (implicit EFLAGS)]>, OpSize, TB;
3001def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3002 "bt{l}\t{$src2, $src1|$src1, $src2}",
3003 [(X86bt GR32:$src1, i32immSExt8:$src2),
3004 (implicit EFLAGS)]>, TB;
3005// Note that these instructions don't need FastBTMem because that
3006// only applies when the other operand is in a register. When it's
3007// an immediate, bt is still fast.
3008def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3009 "bt{w}\t{$src2, $src1|$src1, $src2}",
3010 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3011 (implicit EFLAGS)]>, OpSize, TB;
3012def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3013 "bt{l}\t{$src2, $src1|$src1, $src2}",
3014 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3015 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003016} // Defs = [EFLAGS]
3017
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003018// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003019// Use movsbl intead of movsbw; we don't care about the high 16 bits
3020// of the register here. This has a smaller encoding and avoids a
3021// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003022def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003023 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3024 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003025def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003026 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3027 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003028def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003029 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003030 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003031def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003032 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003033 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003034def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003035 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003036 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003037def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003038 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003039 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3040
Dan Gohman9203ab42008-07-30 18:09:17 +00003041// Use movzbl intead of movzbw; we don't care about the high 16 bits
3042// of the register here. This has a smaller encoding and avoids a
3043// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003044def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003045 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3046 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003047def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003048 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3049 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003050def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003051 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003052 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003053def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003054 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003055 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003056def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003057 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003058 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003059def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003060 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003061 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3062
Dan Gohman744d4622009-04-13 16:09:41 +00003063// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3064// except that they use GR32_NOREX for the output operand register class
3065// instead of GR32. This allows them to operate on h registers on x86-64.
3066def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3067 (outs GR32_NOREX:$dst), (ins GR8:$src),
3068 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3069 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003070let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003071def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3072 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3073 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3074 []>, TB;
3075
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003076let neverHasSideEffects = 1 in {
3077 let Defs = [AX], Uses = [AL] in
3078 def CBW : I<0x98, RawFrm, (outs), (ins),
3079 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3080 let Defs = [EAX], Uses = [AX] in
3081 def CWDE : I<0x98, RawFrm, (outs), (ins),
3082 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003083
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003084 let Defs = [AX,DX], Uses = [AX] in
3085 def CWD : I<0x99, RawFrm, (outs), (ins),
3086 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3087 let Defs = [EAX,EDX], Uses = [EAX] in
3088 def CDQ : I<0x99, RawFrm, (outs), (ins),
3089 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3090}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003091
3092//===----------------------------------------------------------------------===//
3093// Alias Instructions
3094//===----------------------------------------------------------------------===//
3095
3096// Alias instructions that map movr0 to xor.
3097// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00003098let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003099def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003100 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003101 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003102// Use xorl instead of xorw since we don't care about the high 16 bits,
3103// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003104def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003105 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3106 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003107def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003108 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003110}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003111
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003112//===----------------------------------------------------------------------===//
3113// Thread Local Storage Instructions
3114//
3115
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003116// All calls clobber the non-callee saved registers. ESP is marked as
3117// a use to prevent stack-pointer assignments that appear immediately
3118// before calls from potentially appearing dead.
3119let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3120 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3121 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3122 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003123 Uses = [ESP] in
3124def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3125 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003126 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003127 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003128 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003129
sampo9cc09a32009-01-26 01:24:32 +00003130let AddedComplexity = 5 in
3131def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3132 "movl\t%gs:$src, $dst",
3133 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3134
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003135let AddedComplexity = 5 in
3136def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3137 "movl\t%fs:$src, $dst",
3138 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3139
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003140//===----------------------------------------------------------------------===//
3141// DWARF Pseudo Instructions
3142//
3143
Evan Chengb783fa32007-07-19 01:14:50 +00003144def DWARF_LOC : I<0, Pseudo, (outs),
3145 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00003146 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003147 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3148 (i32 imm:$file))]>;
3149
3150//===----------------------------------------------------------------------===//
3151// EH Pseudo Instructions
3152//
3153let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003154 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003155def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003156 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003157 [(X86ehret GR32:$addr)]>;
3158
3159}
3160
3161//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003162// Atomic support
3163//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003164
Evan Cheng3e171562008-04-19 01:20:30 +00003165// Atomic swap. These are just normal xchg instructions. But since a memory
3166// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003167let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003168def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3169 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3170 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3171def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3172 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3173 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3174 OpSize;
3175def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3176 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3177 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3178}
3179
Evan Chengd49dbb82008-04-18 20:55:36 +00003180// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003181let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003182def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003183 "lock\n\t"
3184 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003185 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003186}
Dale Johannesenf160d802008-10-02 18:53:47 +00003187let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003188def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003189 "lock\n\t"
3190 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003191 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3192}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003193
3194let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003195def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003196 "lock\n\t"
3197 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003198 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003199}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003200let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003201def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003202 "lock\n\t"
3203 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003204 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003205}
3206
Evan Chengd49dbb82008-04-18 20:55:36 +00003207// Atomic exchange and add
3208let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3209def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003210 "lock\n\t"
3211 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003212 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003213 TB, LOCK;
3214def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003215 "lock\n\t"
3216 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003217 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003218 TB, OpSize, LOCK;
3219def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003220 "lock\n\t"
3221 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003222 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003223 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003224}
3225
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003226// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003227let Constraints = "$val = $dst", Defs = [EFLAGS],
3228 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003229def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003230 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003231 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003232def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003233 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003234 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003235def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003236 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003237 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003238def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003239 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003240 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003241def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003242 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003243 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003244def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003245 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003246 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003247def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003248 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003249 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003250def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003251 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003252 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003253
3254def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003255 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003256 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003257def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003258 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003259 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003260def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003261 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003262 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003263def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003264 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003265 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003266def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003267 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003268 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003269def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003270 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003271 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003272def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003273 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003274 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003275def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003276 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003277 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003278
3279def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003280 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003281 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003282def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003283 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003284 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003285def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003286 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003287 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003288def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003289 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003290 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003291}
3292
Dale Johannesenf160d802008-10-02 18:53:47 +00003293let Constraints = "$val1 = $dst1, $val2 = $dst2",
3294 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3295 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003296 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003297 usesCustomDAGSchedInserter = 1 in {
3298def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3299 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003300 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003301def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3302 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003303 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003304def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3305 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003306 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003307def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3308 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003309 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003310def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3311 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003312 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003313def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3314 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003315 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003316def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3317 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003318 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003319}
3320
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003321//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003322// Non-Instruction Patterns
3323//===----------------------------------------------------------------------===//
3324
Bill Wendlingfef06052008-09-16 21:48:12 +00003325// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003326def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3327def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003328def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003329def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3330def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3331
3332def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3333 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3334def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3335 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3336def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3337 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3338def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3339 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3340
3341def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3342 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3343def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3344 (MOV32mi addr:$dst, texternalsym:$src)>;
3345
3346// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003347// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003348def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003349 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003350
3351def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003352 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003353def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003354 (TAILCALL)>;
3355
3356def : Pat<(X86tcret GR32:$dst, imm:$off),
3357 (TCRETURNri GR32:$dst, imm:$off)>;
3358
3359def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3360 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3361
3362def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3363 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003364
3365def : Pat<(X86call (i32 tglobaladdr:$dst)),
3366 (CALLpcrel32 tglobaladdr:$dst)>;
3367def : Pat<(X86call (i32 texternalsym:$dst)),
3368 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003369def : Pat<(X86call (i32 imm:$dst)),
3370 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003371
3372// X86 specific add which produces a flag.
3373def : Pat<(addc GR32:$src1, GR32:$src2),
3374 (ADD32rr GR32:$src1, GR32:$src2)>;
3375def : Pat<(addc GR32:$src1, (load addr:$src2)),
3376 (ADD32rm GR32:$src1, addr:$src2)>;
3377def : Pat<(addc GR32:$src1, imm:$src2),
3378 (ADD32ri GR32:$src1, imm:$src2)>;
3379def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3380 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3381
3382def : Pat<(subc GR32:$src1, GR32:$src2),
3383 (SUB32rr GR32:$src1, GR32:$src2)>;
3384def : Pat<(subc GR32:$src1, (load addr:$src2)),
3385 (SUB32rm GR32:$src1, addr:$src2)>;
3386def : Pat<(subc GR32:$src1, imm:$src2),
3387 (SUB32ri GR32:$src1, imm:$src2)>;
3388def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3389 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3390
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003391// Comparisons.
3392
3393// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003394def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003395 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003396def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003397 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003398def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003399 (TEST32rr GR32:$src1, GR32:$src1)>;
3400
Dan Gohman0a3c5222009-01-07 01:00:24 +00003401// Conditional moves with folded loads with operands swapped and conditions
3402// inverted.
3403def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3404 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3405def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3406 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3407def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3408 (CMOVB16rm GR16:$src2, addr:$src1)>;
3409def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3410 (CMOVB32rm GR32:$src2, addr:$src1)>;
3411def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3412 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3413def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3414 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3415def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3416 (CMOVE16rm GR16:$src2, addr:$src1)>;
3417def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3418 (CMOVE32rm GR32:$src2, addr:$src1)>;
3419def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3420 (CMOVA16rm GR16:$src2, addr:$src1)>;
3421def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3422 (CMOVA32rm GR32:$src2, addr:$src1)>;
3423def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3424 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3425def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3426 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3427def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3428 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3429def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3430 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3431def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3432 (CMOVL16rm GR16:$src2, addr:$src1)>;
3433def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3434 (CMOVL32rm GR32:$src2, addr:$src1)>;
3435def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3436 (CMOVG16rm GR16:$src2, addr:$src1)>;
3437def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3438 (CMOVG32rm GR32:$src2, addr:$src1)>;
3439def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3440 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3441def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3442 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3443def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3444 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3445def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3446 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3447def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3448 (CMOVP16rm GR16:$src2, addr:$src1)>;
3449def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3450 (CMOVP32rm GR32:$src2, addr:$src1)>;
3451def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3452 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3453def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3454 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3455def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3456 (CMOVS16rm GR16:$src2, addr:$src1)>;
3457def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3458 (CMOVS32rm GR32:$src2, addr:$src1)>;
3459def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3460 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3461def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3462 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3463def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3464 (CMOVO16rm GR16:$src2, addr:$src1)>;
3465def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3466 (CMOVO32rm GR32:$src2, addr:$src1)>;
3467
Duncan Sands082524c2008-01-23 20:39:46 +00003468// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003469def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3470def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3471def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3472
3473// extload bool -> extload byte
3474def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003475def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3476 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003477def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003478def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3479 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003480def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3481def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3482
Dan Gohmandd612bb2008-08-20 21:27:32 +00003483// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003484def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3485 Requires<[In32BitMode]>;
3486def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3487 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003488def : Pat<(i32 (anyext GR16:$src)),
3489 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003490
Evan Chengf2abee72007-12-13 00:43:27 +00003491// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003492def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3493 (MOVZX32rm8 addr:$src)>;
3494def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3495 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003496
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003497//===----------------------------------------------------------------------===//
3498// Some peepholes
3499//===----------------------------------------------------------------------===//
3500
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003501// Odd encoding trick: -128 fits into an 8-bit immediate field while
3502// +128 doesn't, so in this special case use a sub instead of an add.
3503def : Pat<(add GR16:$src1, 128),
3504 (SUB16ri8 GR16:$src1, -128)>;
3505def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3506 (SUB16mi8 addr:$dst, -128)>;
3507def : Pat<(add GR32:$src1, 128),
3508 (SUB32ri8 GR32:$src1, -128)>;
3509def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3510 (SUB32mi8 addr:$dst, -128)>;
3511
Dan Gohman9203ab42008-07-30 18:09:17 +00003512// r & (2^16-1) ==> movz
3513def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003514 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003515// r & (2^8-1) ==> movz
3516def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003517 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003518 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003519 Requires<[In32BitMode]>;
3520// r & (2^8-1) ==> movz
3521def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003522 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003523 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003524 Requires<[In32BitMode]>;
3525
3526// sext_inreg patterns
3527def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003528 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003529def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003530 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003531 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003532 Requires<[In32BitMode]>;
3533def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003534 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003535 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003536 Requires<[In32BitMode]>;
3537
3538// trunc patterns
3539def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003540 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003541def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003542 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003543 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003544 Requires<[In32BitMode]>;
3545def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003546 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003547 x86_subreg_8bit)>,
3548 Requires<[In32BitMode]>;
3549
3550// h-register tricks
3551def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003552 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003553 x86_subreg_8bit_hi)>,
3554 Requires<[In32BitMode]>;
3555def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003556 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003557 x86_subreg_8bit_hi)>,
3558 Requires<[In32BitMode]>;
3559def : Pat<(srl_su GR16:$src, (i8 8)),
3560 (EXTRACT_SUBREG
3561 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003562 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003563 x86_subreg_8bit_hi)),
3564 x86_subreg_16bit)>,
3565 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003566def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3567 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3568 x86_subreg_8bit_hi))>,
3569 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003570def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003571 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003572 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003573 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003574
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003575// (shl x, 1) ==> (add x, x)
3576def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3577def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3578def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3579
Evan Cheng76a64c72008-08-30 02:03:58 +00003580// (shl x (and y, 31)) ==> (shl x, y)
3581def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3582 (SHL8rCL GR8:$src1)>;
3583def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3584 (SHL16rCL GR16:$src1)>;
3585def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3586 (SHL32rCL GR32:$src1)>;
3587def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3588 (SHL8mCL addr:$dst)>;
3589def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3590 (SHL16mCL addr:$dst)>;
3591def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3592 (SHL32mCL addr:$dst)>;
3593
3594def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3595 (SHR8rCL GR8:$src1)>;
3596def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3597 (SHR16rCL GR16:$src1)>;
3598def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3599 (SHR32rCL GR32:$src1)>;
3600def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3601 (SHR8mCL addr:$dst)>;
3602def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3603 (SHR16mCL addr:$dst)>;
3604def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3605 (SHR32mCL addr:$dst)>;
3606
3607def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3608 (SAR8rCL GR8:$src1)>;
3609def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3610 (SAR16rCL GR16:$src1)>;
3611def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3612 (SAR32rCL GR32:$src1)>;
3613def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3614 (SAR8mCL addr:$dst)>;
3615def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3616 (SAR16mCL addr:$dst)>;
3617def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3618 (SAR32mCL addr:$dst)>;
3619
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003620// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3621def : Pat<(or (srl GR32:$src1, CL:$amt),
3622 (shl GR32:$src2, (sub 32, CL:$amt))),
3623 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3624
3625def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3626 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3627 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3628
Dan Gohman921581d2008-10-17 01:23:35 +00003629def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3630 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3631 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3632
3633def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3634 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3635 addr:$dst),
3636 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3637
3638def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3639 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3640
3641def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3642 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3643 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3644
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003645// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3646def : Pat<(or (shl GR32:$src1, CL:$amt),
3647 (srl GR32:$src2, (sub 32, CL:$amt))),
3648 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3649
3650def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3651 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3652 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3653
Dan Gohman921581d2008-10-17 01:23:35 +00003654def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3655 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3656 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3657
3658def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3659 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3660 addr:$dst),
3661 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3662
3663def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3664 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3665
3666def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3667 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3668 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3669
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003670// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3671def : Pat<(or (srl GR16:$src1, CL:$amt),
3672 (shl GR16:$src2, (sub 16, CL:$amt))),
3673 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3674
3675def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3676 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3677 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3678
Dan Gohman921581d2008-10-17 01:23:35 +00003679def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3680 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3681 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3682
3683def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3684 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3685 addr:$dst),
3686 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3687
3688def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3689 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3690
3691def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3692 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3693 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3694
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003695// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3696def : Pat<(or (shl GR16:$src1, CL:$amt),
3697 (srl GR16:$src2, (sub 16, CL:$amt))),
3698 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3699
3700def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3701 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3702 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3703
Dan Gohman921581d2008-10-17 01:23:35 +00003704def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3705 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3706 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3707
3708def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3709 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3710 addr:$dst),
3711 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3712
3713def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3714 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3715
3716def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3717 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3718 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3719
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003720//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003721// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003722//===----------------------------------------------------------------------===//
3723
Dan Gohman99a12192009-03-04 19:44:21 +00003724// Register-Register Addition with EFLAGS result
3725def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003726 (implicit EFLAGS)),
3727 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003728def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003729 (implicit EFLAGS)),
3730 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003731def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003732 (implicit EFLAGS)),
3733 (ADD32rr GR32:$src1, GR32:$src2)>;
3734
Dan Gohman99a12192009-03-04 19:44:21 +00003735// Register-Memory Addition with EFLAGS result
3736def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003737 (implicit EFLAGS)),
3738 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003739def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003740 (implicit EFLAGS)),
3741 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003742def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003743 (implicit EFLAGS)),
3744 (ADD32rm GR32:$src1, addr:$src2)>;
3745
Dan Gohman99a12192009-03-04 19:44:21 +00003746// Register-Integer Addition with EFLAGS result
3747def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003748 (implicit EFLAGS)),
3749 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003750def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003751 (implicit EFLAGS)),
3752 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003753def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003754 (implicit EFLAGS)),
3755 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003756def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003757 (implicit EFLAGS)),
3758 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003759def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003760 (implicit EFLAGS)),
3761 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3762
Dan Gohman99a12192009-03-04 19:44:21 +00003763// Memory-Register Addition with EFLAGS result
3764def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003765 addr:$dst),
3766 (implicit EFLAGS)),
3767 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003768def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003769 addr:$dst),
3770 (implicit EFLAGS)),
3771 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003772def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003773 addr:$dst),
3774 (implicit EFLAGS)),
3775 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003776
3777// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003778def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003779 addr:$dst),
3780 (implicit EFLAGS)),
3781 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003782def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003783 addr:$dst),
3784 (implicit EFLAGS)),
3785 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003786def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003787 addr:$dst),
3788 (implicit EFLAGS)),
3789 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003790def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003791 addr:$dst),
3792 (implicit EFLAGS)),
3793 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003794def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003795 addr:$dst),
3796 (implicit EFLAGS)),
3797 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3798
Dan Gohman99a12192009-03-04 19:44:21 +00003799// Register-Register Subtraction with EFLAGS result
3800def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003801 (implicit EFLAGS)),
3802 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003803def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003804 (implicit EFLAGS)),
3805 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003806def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003807 (implicit EFLAGS)),
3808 (SUB32rr GR32:$src1, GR32:$src2)>;
3809
Dan Gohman99a12192009-03-04 19:44:21 +00003810// Register-Memory Subtraction with EFLAGS result
3811def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003812 (implicit EFLAGS)),
3813 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003814def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003815 (implicit EFLAGS)),
3816 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003817def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003818 (implicit EFLAGS)),
3819 (SUB32rm GR32:$src1, addr:$src2)>;
3820
Dan Gohman99a12192009-03-04 19:44:21 +00003821// Register-Integer Subtraction with EFLAGS result
3822def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003823 (implicit EFLAGS)),
3824 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003825def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003826 (implicit EFLAGS)),
3827 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003828def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003829 (implicit EFLAGS)),
3830 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003831def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003832 (implicit EFLAGS)),
3833 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003834def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003835 (implicit EFLAGS)),
3836 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3837
Dan Gohman99a12192009-03-04 19:44:21 +00003838// Memory-Register Subtraction with EFLAGS result
3839def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003840 addr:$dst),
3841 (implicit EFLAGS)),
3842 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003843def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003844 addr:$dst),
3845 (implicit EFLAGS)),
3846 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003847def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003848 addr:$dst),
3849 (implicit EFLAGS)),
3850 (SUB32mr addr:$dst, GR32:$src2)>;
3851
Dan Gohman99a12192009-03-04 19:44:21 +00003852// Memory-Integer Subtraction with EFLAGS result
3853def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003854 addr:$dst),
3855 (implicit EFLAGS)),
3856 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003857def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003858 addr:$dst),
3859 (implicit EFLAGS)),
3860 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003861def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003862 addr:$dst),
3863 (implicit EFLAGS)),
3864 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003865def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003866 addr:$dst),
3867 (implicit EFLAGS)),
3868 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003869def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003870 addr:$dst),
3871 (implicit EFLAGS)),
3872 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3873
3874
Dan Gohman99a12192009-03-04 19:44:21 +00003875// Register-Register Signed Integer Multiply with EFLAGS result
3876def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003877 (implicit EFLAGS)),
3878 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003879def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003880 (implicit EFLAGS)),
3881 (IMUL32rr GR32:$src1, GR32:$src2)>;
3882
Dan Gohman99a12192009-03-04 19:44:21 +00003883// Register-Memory Signed Integer Multiply with EFLAGS result
3884def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003885 (implicit EFLAGS)),
3886 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003887def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003888 (implicit EFLAGS)),
3889 (IMUL32rm GR32:$src1, addr:$src2)>;
3890
Dan Gohman99a12192009-03-04 19:44:21 +00003891// Register-Integer Signed Integer Multiply with EFLAGS result
3892def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003893 (implicit EFLAGS)),
3894 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003895def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003896 (implicit EFLAGS)),
3897 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003898def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003899 (implicit EFLAGS)),
3900 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003901def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003902 (implicit EFLAGS)),
3903 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3904
Dan Gohman99a12192009-03-04 19:44:21 +00003905// Memory-Integer Signed Integer Multiply with EFLAGS result
3906def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003907 (implicit EFLAGS)),
3908 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003909def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003910 (implicit EFLAGS)),
3911 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003912def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003913 (implicit EFLAGS)),
3914 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003915def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003916 (implicit EFLAGS)),
3917 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3918
Dan Gohman99a12192009-03-04 19:44:21 +00003919// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003920let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003921def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003922 (implicit EFLAGS)),
3923 (ADD16rr GR16:$src1, GR16:$src1)>;
3924
Dan Gohman99a12192009-03-04 19:44:21 +00003925def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003926 (implicit EFLAGS)),
3927 (ADD32rr GR32:$src1, GR32:$src1)>;
3928}
3929
Dan Gohman99a12192009-03-04 19:44:21 +00003930// INC and DEC with EFLAGS result. Note that these do not set CF.
3931def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3932 (INC8r GR8:$src)>;
3933def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3934 (implicit EFLAGS)),
3935 (INC8m addr:$dst)>;
3936def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3937 (DEC8r GR8:$src)>;
3938def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3939 (implicit EFLAGS)),
3940 (DEC8m addr:$dst)>;
3941
3942def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003943 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003944def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3945 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003946 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003947def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003948 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003949def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3950 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003951 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003952
3953def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003954 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003955def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3956 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003957 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003958def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003959 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003960def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3961 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003962 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003963
Bill Wendlingf5399032008-12-12 21:15:41 +00003964//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003965// Floating Point Stack Support
3966//===----------------------------------------------------------------------===//
3967
3968include "X86InstrFPStack.td"
3969
3970//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003971// X86-64 Support
3972//===----------------------------------------------------------------------===//
3973
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003974include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003975
3976//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003977// XMM Floating point support (requires SSE / SSE2)
3978//===----------------------------------------------------------------------===//
3979
3980include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003981
3982//===----------------------------------------------------------------------===//
3983// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3984//===----------------------------------------------------------------------===//
3985
3986include "X86InstrMMX.td"