blob: 7ece204b88893584797cbd2e569f69b744319001 [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
Bill Wendling7173da52007-11-13 09:19:02 +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">;
183def f32mem : X86MemOperand<"printf32mem">;
184def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000185def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000186def f128mem : X86MemOperand<"printf128mem">;
187
Dan Gohman744d4622009-04-13 16:09:41 +0000188// A version of i8mem for use on x86-64 that uses GR64_NOREX instead of
189// plain GR64, so that it doesn't potentially require a REX prefix.
190def i8mem_NOREX : Operand<i64> {
191 let PrintMethod = "printi8mem";
192 let MIOperandInfo = (ops GR64_NOREX, i8imm, GR64_NOREX, i32imm, i8imm);
193}
194
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195def lea32mem : Operand<i32> {
Rafael Espindolabca99f72009-04-08 21:14:34 +0000196 let PrintMethod = "printlea32mem";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000197 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
198}
199
200def SSECC : Operand<i8> {
201 let PrintMethod = "printSSECC";
202}
203
204def piclabel: Operand<i32> {
205 let PrintMethod = "printPICLabel";
206}
207
208// A couple of more descriptive operand definitions.
209// 16-bits but only 8 bits are significant.
210def i16i8imm : Operand<i16>;
211// 32-bits but only 8 bits are significant.
212def i32i8imm : Operand<i32>;
213
Chris Lattner357a0ca2009-06-20 19:34:09 +0000214// Branch targets have OtherVT type and print as pc-relative values.
215def brtarget : Operand<OtherVT> {
216 let PrintMethod = "print_pcrel_imm";
217}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000218
219//===----------------------------------------------------------------------===//
220// X86 Complex Pattern Definitions.
221//
222
223// Define X86 specific addressing mode.
Rafael Espindolabca99f72009-04-08 21:14:34 +0000224def addr : ComplexPattern<iPTR, 5, "SelectAddr", [], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
Dan Gohman946223f2009-05-11 18:02:53 +0000226 [add, sub, mul, shl, or, frameindex], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000227
228//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000229// X86 Instruction Predicate Definitions.
230def HasMMX : Predicate<"Subtarget->hasMMX()">;
231def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
232def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
233def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
234def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000235def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
236def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000237def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
238def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000239def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
240def In64BitMode : Predicate<"Subtarget->is64Bit()">;
241def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
242def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
243def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000244def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000245def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000246def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247
248//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000249// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000250//
251
Evan Cheng86ab7d32007-07-31 08:04:03 +0000252include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000253
254//===----------------------------------------------------------------------===//
255// Pattern fragments...
256//
257
258// X86 specific condition code. These correspond to CondCode in
259// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000260def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
261def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
262def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
263def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
264def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
265def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
266def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
267def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
268def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
269def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000270def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000271def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000273def X86_COND_O : PatLeaf<(i8 13)>;
274def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
275def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276
277def i16immSExt8 : PatLeaf<(i16 imm), [{
278 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
279 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000280 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000281}]>;
282
283def i32immSExt8 : PatLeaf<(i32 imm), [{
284 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
285 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000286 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287}]>;
288
289// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000290// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
291// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000292def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000293 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000294 if (const Value *Src = LD->getSrcValue())
295 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000296 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000297 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000298 ISD::LoadExtType ExtType = LD->getExtensionType();
299 if (ExtType == ISD::NON_EXTLOAD)
300 return true;
301 if (ExtType == ISD::EXTLOAD)
302 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000303 return false;
304}]>;
305
Dan Gohman2a174122008-10-15 06:50:19 +0000306def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000307 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000308 if (const Value *Src = LD->getSrcValue())
309 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000310 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000311 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000312 ISD::LoadExtType ExtType = LD->getExtensionType();
313 if (ExtType == ISD::EXTLOAD)
314 return LD->getAlignment() >= 2 && !LD->isVolatile();
315 return false;
316}]>;
317
Dan Gohman2a174122008-10-15 06:50:19 +0000318def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000319 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000320 if (const Value *Src = LD->getSrcValue())
321 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000322 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000323 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000324 ISD::LoadExtType ExtType = LD->getExtensionType();
325 if (ExtType == ISD::NON_EXTLOAD)
326 return true;
327 if (ExtType == ISD::EXTLOAD)
328 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000329 return false;
330}]>;
331
Dan Gohman2a174122008-10-15 06:50:19 +0000332def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000333 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000334 if (const Value *Src = LD->getSrcValue())
335 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000336 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000337 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000338 if (LD->isVolatile())
339 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000340 ISD::LoadExtType ExtType = LD->getExtensionType();
341 if (ExtType == ISD::NON_EXTLOAD)
342 return true;
343 if (ExtType == ISD::EXTLOAD)
344 return LD->getAlignment() >= 4;
345 return false;
346}]>;
347
sampo9cc09a32009-01-26 01:24:32 +0000348def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000349 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
350 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
351 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000352 return false;
353}]>;
354
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000355def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
356 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
357 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
358 return PT->getAddressSpace() == 257;
359 return false;
360}]>;
361
Chris Lattner12208612009-04-10 00:16:23 +0000362def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
363 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
364 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000365 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000366 return false;
367 return true;
368}]>;
369def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
370 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
371 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000372 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000373 return false;
374 return true;
375}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376
Chris Lattner12208612009-04-10 00:16:23 +0000377def loadf32 : PatFrag<(ops node:$ptr), (f32 (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}]>;
384def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
385 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
386 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000387 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000388 return false;
389 return true;
390}]>;
391def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
392 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
393 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000394 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000395 return false;
396 return true;
397}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000398
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
400def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
401def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
402
403def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
404def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
405def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
406def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
407def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
408def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
409
410def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
411def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
412def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
413def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
414def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
415def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
416
Chris Lattner21da6382008-02-19 17:37:35 +0000417
418// An 'and' node with a single use.
419def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000420 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000421}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000422// An 'srl' node with a single use.
423def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
424 return N->hasOneUse();
425}]>;
426// An 'trunc' node with a single use.
427def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
428 return N->hasOneUse();
429}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000430
Dan Gohman921581d2008-10-17 01:23:35 +0000431// 'shld' and 'shrd' instruction patterns. Note that even though these have
432// the srl and shl in their patterns, the C++ code must still check for them,
433// because predicates are tested before children nodes are explored.
434
435def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
436 (or (srl node:$src1, node:$amt1),
437 (shl node:$src2, node:$amt2)), [{
438 assert(N->getOpcode() == ISD::OR);
439 return N->getOperand(0).getOpcode() == ISD::SRL &&
440 N->getOperand(1).getOpcode() == ISD::SHL &&
441 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
442 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
443 N->getOperand(0).getConstantOperandVal(1) ==
444 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
445}]>;
446
447def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
448 (or (shl node:$src1, node:$amt1),
449 (srl node:$src2, node:$amt2)), [{
450 assert(N->getOpcode() == ISD::OR);
451 return N->getOperand(0).getOpcode() == ISD::SHL &&
452 N->getOperand(1).getOpcode() == ISD::SRL &&
453 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
454 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
455 N->getOperand(0).getConstantOperandVal(1) ==
456 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
457}]>;
458
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000459//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460// Instruction list...
461//
462
463// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
464// a stack adjustment and the codegen must know that they may modify the stack
465// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000466// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
467// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000468let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000469def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
470 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000471 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000472 Requires<[In32BitMode]>;
473def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
474 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000475 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000476 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000477}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000478
479// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000480let neverHasSideEffects = 1 in
481 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000482
Evan Cheng0729ccf2008-01-05 00:41:47 +0000483// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000484let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000485 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman70a8a112009-04-27 15:13:28 +0000486 "call\t$label\n\t"
487 "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000488
489//===----------------------------------------------------------------------===//
490// Control Flow Instructions...
491//
492
493// Return instructions.
494let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000495 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000496 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000497 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000498 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000499 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
500 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501 [(X86retflag imm:$amt)]>;
502}
503
504// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000505let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000506 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
507 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000510 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000511
Owen Andersonf8053082007-11-12 07:39:39 +0000512// Indirect branches
513let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000514 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000516 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000517 [(brind (loadi32 addr:$dst))]>;
518}
519
520// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000521let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000522def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000523 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000524def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000525 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000526def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000527 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000528def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000529 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000530def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000531 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000532def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000533 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534
Dan Gohman91888f02007-07-31 20:11:57 +0000535def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000536 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000537def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000538 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000539def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000540 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000541def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000542 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543
Dan Gohman91888f02007-07-31 20:11:57 +0000544def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000545 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000546def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000547 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000548def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000549 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000550def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000551 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000552def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000553 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000554def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000555 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000556} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557
558//===----------------------------------------------------------------------===//
559// Call Instructions...
560//
Evan Cheng37e7c752007-07-21 00:34:19 +0000561let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000562 // All calls clobber the non-callee saved registers. ESP is marked as
563 // a use to prevent stack-pointer assignments that appear immediately
564 // before calls from potentially appearing dead. Uses for argument
565 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000566 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
567 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000568 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
569 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000570 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000571 def CALLpcrel32 : Ii32<0xE8, RawFrm,
572 (outs), (ins i32imm_pcrel:$dst,variable_ops),
573 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000574 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000575 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000576 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000577 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000578 }
579
580// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000581
Chris Lattnerb56cc342008-03-11 03:23:40 +0000582def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000583 "#TAILCALL",
584 []>;
585
Evan Cheng37e7c752007-07-21 00:34:19 +0000586let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000587def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000588 "#TC_RETURN $dst $offset",
589 []>;
590
591let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000592def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000593 "#TC_RETURN $dst $offset",
594 []>;
595
596let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000597
Chris Lattner357a0ca2009-06-20 19:34:09 +0000598 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000599 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000600let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000601 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
602 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000603let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000604 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000605 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000606
607//===----------------------------------------------------------------------===//
608// Miscellaneous Instructions...
609//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000610let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000611def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000612 (outs), (ins), "leave", []>;
613
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000614let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
615let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000616def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000617
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000618let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000619def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000620}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621
Bill Wendling4c2638c2009-06-15 19:39:04 +0000622let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
623def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000624 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000625def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000626 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000627def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000628 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000629}
630
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000631let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000632def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000633let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000634def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000635
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000636let isTwoAddress = 1 in // GR32 = bswap GR32
637 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000638 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000639 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000640 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
641
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642
Evan Cheng48679f42007-12-14 02:13:44 +0000643// Bit scan instructions.
644let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000645def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000646 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000647 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000648def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000649 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000650 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
651 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000652def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000653 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000654 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000655def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000656 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000657 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
658 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000659
Evan Cheng4e33de92007-12-14 18:49:43 +0000660def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000661 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000662 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000663def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000664 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000665 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
666 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000667def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000668 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000669 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000670def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000671 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000672 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
673 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000674} // Defs = [EFLAGS]
675
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000676let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000678 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000679 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000680let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000681def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000682 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000683 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000684 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
685
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000686let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000687def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000688 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000689def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000690 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000691def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000692 [(X86rep_movs i32)]>, REP;
693}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000695let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000696def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000697 [(X86rep_stos i8)]>, REP;
698let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000699def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000700 [(X86rep_stos i16)]>, REP, OpSize;
701let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000702def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000703 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000704
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000705let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000706def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000707 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000709let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000710def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000711}
712
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713//===----------------------------------------------------------------------===//
714// Input/Output Instructions...
715//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000716let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000717def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000718 "in{b}\t{%dx, %al|%AL, %DX}", []>;
719let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000720def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000721 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
722let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000723def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000724 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000726let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000727def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000728 "in{b}\t{$port, %al|%AL, $port}", []>;
729let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000730def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000731 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
732let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000733def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000734 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000736let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000737def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000738 "out{b}\t{%al, %dx|%DX, %AL}", []>;
739let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000740def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000741 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
742let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000743def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000744 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000746let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000747def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000748 "out{b}\t{%al, $port|$port, %AL}", []>;
749let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000750def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000751 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
752let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000753def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000754 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000755
756//===----------------------------------------------------------------------===//
757// Move Instructions...
758//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000759let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000760def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000761 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000762def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000763 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000764def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000765 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000766}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000767let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000768def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000769 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000771def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000772 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000774def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000775 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 [(set GR32:$dst, imm:$src)]>;
777}
Evan Chengb783fa32007-07-19 01:14:50 +0000778def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000779 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000781def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000782 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000784def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000785 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786 [(store (i32 imm:$src), addr:$dst)]>;
787
Dan Gohman5574cc72008-12-03 18:15:48 +0000788let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000789def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000790 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000791 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000792def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000793 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000794 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000795def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000796 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000797 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000798}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000799
Evan Chengb783fa32007-07-19 01:14:50 +0000800def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000801 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000803def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000804 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000806def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000807 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000809
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000810// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
811// that they can be used for copying and storing h registers, which can't be
812// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000813let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000814def MOV8rr_NOREX : I<0x88, MRMDestReg,
815 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000816 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000817let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000818def MOV8mr_NOREX : I<0x88, MRMDestMem,
819 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
820 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000821let mayLoad = 1,
822 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000823def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
824 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
825 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000826
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827//===----------------------------------------------------------------------===//
828// Fixed-Register Multiplication and Division Instructions...
829//
830
831// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000832let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000833def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
835 // This probably ought to be moved to a def : Pat<> if the
836 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000837 [(set AL, (mul AL, GR8:$src)),
838 (implicit EFLAGS)]>; // AL,AH = AL*GR8
839
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000840let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000841def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
842 "mul{w}\t$src",
843 []>, OpSize; // AX,DX = AX*GR16
844
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000845let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000846def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
847 "mul{l}\t$src",
848 []>; // EAX,EDX = EAX*GR32
849
Evan Cheng55687072007-09-14 21:48:26 +0000850let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000851def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000852 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
854 // This probably ought to be moved to a def : Pat<> if the
855 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000856 [(set AL, (mul AL, (loadi8 addr:$src))),
857 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
858
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000859let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000860let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000861def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000862 "mul{w}\t$src",
863 []>, OpSize; // AX,DX = AX*[mem16]
864
Evan Cheng55687072007-09-14 21:48:26 +0000865let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000866def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000867 "mul{l}\t$src",
868 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000869}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000871let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000872let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000873def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
874 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000875let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000876def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000877 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000878let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000879def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
880 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000881let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000882let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000883def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000884 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000885let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000886def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000887 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
888let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000889def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000890 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000891}
Dan Gohmand44572d2008-11-18 21:29:14 +0000892} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893
894// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000895let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000896def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000897 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000898let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000899def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000900 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000901let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000902def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000903 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000904let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000905let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000906def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000907 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000908let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000909def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000910 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000911let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000912def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000913 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000914}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915
916// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000917let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000918def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000919 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000920let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000921def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000922 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000923let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000924def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000925 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000926let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000927let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000928def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000929 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000930let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000931def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000932 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000933let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000934def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000935 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000936}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937
938//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000939// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940//
941let isTwoAddress = 1 in {
942
943// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000944let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000945let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000947 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000948 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000949 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000950 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000953 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000954 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000956 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000959 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000960 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000962 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000965 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000966 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000968 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000971 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000972 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000974 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000977 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000978 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000980 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000983 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000984 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000986 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000989 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000990 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000992 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000995 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000996 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000998 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001001 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001002 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001004 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001007 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001008 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001010 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001013 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001014 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001016 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001017 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001019 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001020 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001021 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001022 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001025 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001026 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001027 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001028 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001031 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001032 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001034 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001037 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001038 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001040 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001043 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001044 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001046 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001049 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001050 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001051 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001052 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001055 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001056 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001058 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001061 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001062 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001064 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001066def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001067 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001068 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001069 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001070 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001073 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001074 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001076 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001079 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001080 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001082 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001084def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001085 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001086 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001088 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001091 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001092 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001094 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001097 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001098 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001100 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001101 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001103 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001104 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001106 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001107 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001109 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001110 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001112 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001114def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1115 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1116 "cmovo\t{$src2, $dst|$dst, $src2}",
1117 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1118 X86_COND_O, EFLAGS))]>,
1119 TB, OpSize;
1120def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1121 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1122 "cmovo\t{$src2, $dst|$dst, $src2}",
1123 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1124 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001125 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001126def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1127 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1128 "cmovno\t{$src2, $dst|$dst, $src2}",
1129 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1130 X86_COND_NO, EFLAGS))]>,
1131 TB, OpSize;
1132def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1133 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1134 "cmovno\t{$src2, $dst|$dst, $src2}",
1135 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1136 X86_COND_NO, EFLAGS))]>,
1137 TB;
1138} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001139
1140def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1141 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1142 "cmovb\t{$src2, $dst|$dst, $src2}",
1143 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1144 X86_COND_B, EFLAGS))]>,
1145 TB, OpSize;
1146def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1147 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1148 "cmovb\t{$src2, $dst|$dst, $src2}",
1149 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1150 X86_COND_B, EFLAGS))]>,
1151 TB;
1152def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1153 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1154 "cmovae\t{$src2, $dst|$dst, $src2}",
1155 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1156 X86_COND_AE, EFLAGS))]>,
1157 TB, OpSize;
1158def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1159 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1160 "cmovae\t{$src2, $dst|$dst, $src2}",
1161 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1162 X86_COND_AE, EFLAGS))]>,
1163 TB;
1164def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1165 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1166 "cmove\t{$src2, $dst|$dst, $src2}",
1167 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1168 X86_COND_E, EFLAGS))]>,
1169 TB, OpSize;
1170def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1171 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1172 "cmove\t{$src2, $dst|$dst, $src2}",
1173 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1174 X86_COND_E, EFLAGS))]>,
1175 TB;
1176def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1177 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1178 "cmovne\t{$src2, $dst|$dst, $src2}",
1179 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1180 X86_COND_NE, EFLAGS))]>,
1181 TB, OpSize;
1182def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1183 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1184 "cmovne\t{$src2, $dst|$dst, $src2}",
1185 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1186 X86_COND_NE, EFLAGS))]>,
1187 TB;
1188def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1189 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1190 "cmovbe\t{$src2, $dst|$dst, $src2}",
1191 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1192 X86_COND_BE, EFLAGS))]>,
1193 TB, OpSize;
1194def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1195 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1196 "cmovbe\t{$src2, $dst|$dst, $src2}",
1197 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1198 X86_COND_BE, EFLAGS))]>,
1199 TB;
1200def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1201 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1202 "cmova\t{$src2, $dst|$dst, $src2}",
1203 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1204 X86_COND_A, EFLAGS))]>,
1205 TB, OpSize;
1206def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1207 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1208 "cmova\t{$src2, $dst|$dst, $src2}",
1209 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1210 X86_COND_A, EFLAGS))]>,
1211 TB;
1212def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1213 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1214 "cmovl\t{$src2, $dst|$dst, $src2}",
1215 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1216 X86_COND_L, EFLAGS))]>,
1217 TB, OpSize;
1218def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1219 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1220 "cmovl\t{$src2, $dst|$dst, $src2}",
1221 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1222 X86_COND_L, EFLAGS))]>,
1223 TB;
1224def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1225 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1226 "cmovge\t{$src2, $dst|$dst, $src2}",
1227 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1228 X86_COND_GE, EFLAGS))]>,
1229 TB, OpSize;
1230def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1231 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1232 "cmovge\t{$src2, $dst|$dst, $src2}",
1233 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1234 X86_COND_GE, EFLAGS))]>,
1235 TB;
1236def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1237 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1238 "cmovle\t{$src2, $dst|$dst, $src2}",
1239 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1240 X86_COND_LE, EFLAGS))]>,
1241 TB, OpSize;
1242def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1243 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1244 "cmovle\t{$src2, $dst|$dst, $src2}",
1245 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1246 X86_COND_LE, EFLAGS))]>,
1247 TB;
1248def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1249 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1250 "cmovg\t{$src2, $dst|$dst, $src2}",
1251 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1252 X86_COND_G, EFLAGS))]>,
1253 TB, OpSize;
1254def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1255 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1256 "cmovg\t{$src2, $dst|$dst, $src2}",
1257 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1258 X86_COND_G, EFLAGS))]>,
1259 TB;
1260def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1261 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1262 "cmovs\t{$src2, $dst|$dst, $src2}",
1263 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1264 X86_COND_S, EFLAGS))]>,
1265 TB, OpSize;
1266def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1267 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1268 "cmovs\t{$src2, $dst|$dst, $src2}",
1269 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1270 X86_COND_S, EFLAGS))]>,
1271 TB;
1272def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1273 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1274 "cmovns\t{$src2, $dst|$dst, $src2}",
1275 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1276 X86_COND_NS, EFLAGS))]>,
1277 TB, OpSize;
1278def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1279 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1280 "cmovns\t{$src2, $dst|$dst, $src2}",
1281 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1282 X86_COND_NS, EFLAGS))]>,
1283 TB;
1284def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1285 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1286 "cmovp\t{$src2, $dst|$dst, $src2}",
1287 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1288 X86_COND_P, EFLAGS))]>,
1289 TB, OpSize;
1290def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1291 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1292 "cmovp\t{$src2, $dst|$dst, $src2}",
1293 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1294 X86_COND_P, EFLAGS))]>,
1295 TB;
1296def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1297 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1298 "cmovnp\t{$src2, $dst|$dst, $src2}",
1299 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1300 X86_COND_NP, EFLAGS))]>,
1301 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001302def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1303 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1304 "cmovnp\t{$src2, $dst|$dst, $src2}",
1305 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1306 X86_COND_NP, EFLAGS))]>,
1307 TB;
1308def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1309 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1310 "cmovo\t{$src2, $dst|$dst, $src2}",
1311 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1312 X86_COND_O, EFLAGS))]>,
1313 TB, OpSize;
1314def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1315 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1316 "cmovo\t{$src2, $dst|$dst, $src2}",
1317 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1318 X86_COND_O, EFLAGS))]>,
1319 TB;
1320def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1321 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1322 "cmovno\t{$src2, $dst|$dst, $src2}",
1323 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1324 X86_COND_NO, EFLAGS))]>,
1325 TB, OpSize;
1326def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1327 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1328 "cmovno\t{$src2, $dst|$dst, $src2}",
1329 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1330 X86_COND_NO, EFLAGS))]>,
1331 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001332} // Uses = [EFLAGS]
1333
1334
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335// unary instructions
1336let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001337let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001338def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001339 [(set GR8:$dst, (ineg GR8:$src)),
1340 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001341def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001342 [(set GR16:$dst, (ineg GR16:$src)),
1343 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001344def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001345 [(set GR32:$dst, (ineg GR32:$src)),
1346 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001347let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001348 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001349 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1350 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001351 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001352 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1353 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001354 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001355 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1356 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001357}
Evan Cheng55687072007-09-14 21:48:26 +00001358} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359
Evan Chengc6cee682009-01-21 02:09:05 +00001360// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1361let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001362def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001364def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001366def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001368}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001370 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001372 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001374 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001375 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1376}
1377} // CodeSize
1378
1379// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001380let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001382def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001383 [(set GR8:$dst, (add GR8:$src, 1)),
1384 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001385let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001386def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001387 [(set GR16:$dst, (add GR16:$src, 1)),
1388 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001390def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001391 [(set GR32:$dst, (add GR32:$src, 1)),
1392 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393}
1394let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001395 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001396 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1397 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001398 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001399 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1400 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001401 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001402 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001403 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1404 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001405 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406}
1407
1408let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001409def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001410 [(set GR8:$dst, (add GR8:$src, -1)),
1411 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001413def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001414 [(set GR16:$dst, (add GR16:$src, -1)),
1415 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001416 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001417def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001418 [(set GR32:$dst, (add GR32:$src, -1)),
1419 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001420}
1421
1422let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001423 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001424 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1425 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001426 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001427 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1428 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001429 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001430 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001431 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1432 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001433 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001434}
Evan Cheng55687072007-09-14 21:48:26 +00001435} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001436
1437// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001438let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001439let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1440def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001441 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001442 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001443 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1444 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001445def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001446 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001447 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001448 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1449 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001450def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001451 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001452 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001453 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1454 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455}
1456
1457def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001458 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001459 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001460 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001461 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001462def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001463 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001465 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001466 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001468 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001470 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001471 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001472
1473def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001474 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001475 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001476 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1477 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001478def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001479 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001480 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001481 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1482 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001483def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001484 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001485 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001486 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1487 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001488def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001489 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001490 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001491 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1492 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001493 OpSize;
1494def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001495 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001496 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001497 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1498 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001499
1500let isTwoAddress = 0 in {
1501 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001502 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001503 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001504 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1505 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001506 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001507 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001508 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001509 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1510 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511 OpSize;
1512 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001513 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001515 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1516 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001518 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001519 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001520 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1521 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001523 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001524 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001525 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1526 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001527 OpSize;
1528 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001529 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001530 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001531 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1532 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001534 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001535 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001536 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1537 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001538 OpSize;
1539 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001540 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001542 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1543 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001544}
1545
1546
1547let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001548def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001549 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001550 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1551 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001552def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001554 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1555 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001556def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001557 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001558 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1559 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560}
Evan Chengb783fa32007-07-19 01:14:50 +00001561def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001562 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001563 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1564 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001565def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001566 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001567 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1568 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001569def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001570 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001571 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1572 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001573
Evan Chengb783fa32007-07-19 01:14:50 +00001574def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001575 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001576 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1577 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001578def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001579 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001580 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1581 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001582def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001583 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001584 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1585 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001586
Evan Chengb783fa32007-07-19 01:14:50 +00001587def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001588 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001589 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1590 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001591def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001592 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001593 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1594 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001596 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001597 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001598 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1599 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001600 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001601 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001602 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1603 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001604 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001605 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001606 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1607 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001608 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001609 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001610 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1611 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001612 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001613 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001614 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1615 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001616 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001617 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001618 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001619 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1620 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001621 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001622 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001623 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1624 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001626 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001627 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001628 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1629 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001630} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631
1632
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001633let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001634 def XOR8rr : I<0x30, MRMDestReg,
1635 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1636 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001637 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1638 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001639 def XOR16rr : I<0x31, MRMDestReg,
1640 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1641 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001642 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1643 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001644 def XOR32rr : I<0x31, MRMDestReg,
1645 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1646 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001647 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1648 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001649} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650
1651def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001652 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001653 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001654 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1655 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001657 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001659 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1660 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001661 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001662def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001663 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001665 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1666 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001668def XOR8ri : Ii8<0x80, MRM6r,
1669 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1670 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001671 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1672 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001673def XOR16ri : Ii16<0x81, MRM6r,
1674 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1675 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001676 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1677 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001678def XOR32ri : Ii32<0x81, MRM6r,
1679 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1680 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001681 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1682 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001683def XOR16ri8 : Ii8<0x83, MRM6r,
1684 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1685 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001686 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1687 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001688 OpSize;
1689def XOR32ri8 : Ii8<0x83, MRM6r,
1690 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1691 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001692 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1693 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001694
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001695let isTwoAddress = 0 in {
1696 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001697 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001698 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001699 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1700 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001702 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001703 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001704 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1705 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001706 OpSize;
1707 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001708 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001710 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1711 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001712 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001713 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001715 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1716 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001718 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001720 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1721 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722 OpSize;
1723 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001724 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001725 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001726 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1727 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001728 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001729 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001731 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1732 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733 OpSize;
1734 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001735 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001737 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1738 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001739} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001740} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741
1742// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001743let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001744let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001745def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001746 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001747 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001748def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001749 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001750 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001751def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001752 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001753 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001754} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001755
Evan Chengb783fa32007-07-19 01:14:50 +00001756def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001757 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001758 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1759let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001760def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001763def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001765 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001766// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1767// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001768} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001769
1770let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001771 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001772 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001773 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001774 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001775 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001776 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001777 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001778 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001779 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001780 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1781 }
Evan Chengb783fa32007-07-19 01:14:50 +00001782 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001784 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001785 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1788 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001789 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001790 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001791 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1792
1793 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001794 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001797 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001798 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1800 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001801 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001802 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1804}
1805
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001806let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001807def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001808 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001809 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001810def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001811 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001812 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001813def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001814 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001815 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1816}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001817
Evan Chengb783fa32007-07-19 01:14:50 +00001818def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001819 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001820 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001821def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001822 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001824def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1827
1828// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001829def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001830 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001831 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001832def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001833 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001834 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001835def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1838
1839let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001840 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001841 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001842 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001843 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001844 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001845 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001846 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001847 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001848 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001849 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001850 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1851 }
Evan Chengb783fa32007-07-19 01:14:50 +00001852 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001853 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001855 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001856 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1858 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001859 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001860 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001861 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1862
1863 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001864 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001865 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001867 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001868 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001870 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1873}
1874
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001875let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001876def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001877 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001878 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001879def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001880 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001881 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001882def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001883 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001884 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1885}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886
Evan Chengb783fa32007-07-19 01:14:50 +00001887def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001888 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001889 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001890def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001891 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001892 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1893 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001894def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001895 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001896 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1897
1898// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001899def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001900 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001901 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001902def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001903 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001904 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001905def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1908
1909let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001910 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001911 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001912 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001913 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001914 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001915 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001916 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001917 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001918 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001919 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1920 }
Evan Chengb783fa32007-07-19 01:14:50 +00001921 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001924 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1927 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001928 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001930 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1931
1932 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001933 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001935 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001936 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001937 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001938 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1939 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001940 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001941 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1943}
1944
1945// Rotate instructions
1946// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001947let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001948def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001949 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001950 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001951def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001952 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001953 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001954def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001955 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001956 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1957}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958
Evan Chengb783fa32007-07-19 01:14:50 +00001959def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001960 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001962def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001963 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001965def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1968
1969// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001970def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001971 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001973def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001974 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001976def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001977 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1979
1980let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001981 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001982 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001983 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001984 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001985 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001986 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001987 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001988 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001989 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001990 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1991 }
Evan Chengb783fa32007-07-19 01:14:50 +00001992 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001993 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001994 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001995 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001996 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001997 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1998 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001999 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2002
2003 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002004 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002005 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002006 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002007 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2010 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002011 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002012 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002013 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2014}
2015
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002016let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002017def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002018 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002019 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002020def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002021 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002022 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002023def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002024 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002025 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2026}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027
Evan Chengb783fa32007-07-19 01:14:50 +00002028def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002029 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002031def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002032 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002034def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002035 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2037
2038// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002039def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002040 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002042def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002043 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002045def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2048
2049let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002050 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002051 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002052 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002053 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002054 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002055 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002056 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002057 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002058 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002059 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2060 }
Evan Chengb783fa32007-07-19 01:14:50 +00002061 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002062 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002063 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002064 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002065 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002066 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2067 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002068 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2071
2072 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002073 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002074 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002075 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002076 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002077 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2079 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002080 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002081 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2083}
2084
2085
2086
2087// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002088let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002089def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002090 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002091 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002092def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002093 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002094 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002095def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002096 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002097 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002098 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002099def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002100 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002101 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002102 TB, OpSize;
2103}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104
2105let isCommutable = 1 in { // These instructions commute to each other.
2106def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002107 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002108 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2110 (i8 imm:$src3)))]>,
2111 TB;
2112def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002113 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002114 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002115 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2116 (i8 imm:$src3)))]>,
2117 TB;
2118def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002119 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002120 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2122 (i8 imm:$src3)))]>,
2123 TB, OpSize;
2124def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002125 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002126 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002127 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2128 (i8 imm:$src3)))]>,
2129 TB, OpSize;
2130}
2131
2132let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002133 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002134 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002135 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002136 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002137 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002138 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002139 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002140 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002141 addr:$dst)]>, TB;
2142 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002143 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002144 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002145 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002146 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2147 (i8 imm:$src3)), addr:$dst)]>,
2148 TB;
2149 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002150 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2153 (i8 imm:$src3)), addr:$dst)]>,
2154 TB;
2155
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002156 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002157 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002158 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002159 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002160 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002161 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002162 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002164 addr:$dst)]>, TB, OpSize;
2165 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002166 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002167 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002168 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002169 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2170 (i8 imm:$src3)), addr:$dst)]>,
2171 TB, OpSize;
2172 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002173 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002174 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002175 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2176 (i8 imm:$src3)), addr:$dst)]>,
2177 TB, OpSize;
2178}
Evan Cheng55687072007-09-14 21:48:26 +00002179} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002180
2181
2182// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002183let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002185// Register-Register Addition
2186def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2187 (ins GR8 :$src1, GR8 :$src2),
2188 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002189 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002190 (implicit EFLAGS)]>;
2191
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002192let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002193// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002194def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2195 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002196 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002197 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2198 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002199def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2200 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002202 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2203 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204} // end isConvertibleToThreeAddress
2205} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002206
2207// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002208def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2209 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002210 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002211 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2212 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002213def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2214 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002215 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002216 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2217 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002218def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2219 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002220 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002221 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2222 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002223
Bill Wendlingae034ed2008-12-12 00:56:36 +00002224// Register-Integer Addition
2225def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2226 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002227 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2228 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002229
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002231// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002232def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2233 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002234 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002235 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2236 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002237def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2238 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002239 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002240 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2241 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002242def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2243 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002244 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002245 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2246 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002247def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2248 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002249 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002250 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2251 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002252}
2253
2254let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002255 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002256 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002258 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2259 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002260 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002261 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002262 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2263 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002264 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002266 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2267 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002268 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002269 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002270 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2271 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002272 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002273 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002274 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2275 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002276 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002277 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002278 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2279 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002280 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002281 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002282 [(store (add (load addr:$dst), i16immSExt8:$src2),
2283 addr:$dst),
2284 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002285 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002287 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002288 addr:$dst),
2289 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290}
2291
Evan Cheng259471d2007-10-05 17:59:57 +00002292let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002293let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002294def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002295 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002296 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002297def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2298 (ins GR16:$src1, GR16:$src2),
2299 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002300 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002301def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2302 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002303 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002304 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002305}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002306def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2307 (ins GR8:$src1, i8mem:$src2),
2308 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002309 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002310def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2311 (ins GR16:$src1, i16mem:$src2),
2312 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002313 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002314 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002315def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2316 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002317 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002318 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2319def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002320 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002321 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002322def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2323 (ins GR16:$src1, i16imm:$src2),
2324 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002325 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002326def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2327 (ins GR16:$src1, i16i8imm:$src2),
2328 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002329 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2330 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002331def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2332 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002334 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002335def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2336 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002337 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002338 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002339
2340let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002341 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002342 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002343 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2344 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002345 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002346 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2347 OpSize;
2348 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002350 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2351 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002352 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002353 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2354 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002355 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002356 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2357 OpSize;
2358 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002359 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002360 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2361 OpSize;
2362 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002363 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002364 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2365 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002366 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002367 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2368}
Evan Cheng259471d2007-10-05 17:59:57 +00002369} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002370
Bill Wendlingae034ed2008-12-12 00:56:36 +00002371// Register-Register Subtraction
2372def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2373 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002374 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2375 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002376def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2377 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002378 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2379 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002380def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2381 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002382 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2383 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002384
2385// Register-Memory Subtraction
2386def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2387 (ins GR8 :$src1, i8mem :$src2),
2388 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002389 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2390 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002391def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2392 (ins GR16:$src1, i16mem:$src2),
2393 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002394 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2395 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002396def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2397 (ins GR32:$src1, i32mem:$src2),
2398 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002399 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2400 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002401
2402// Register-Integer Subtraction
2403def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2404 (ins GR8:$src1, i8imm:$src2),
2405 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002406 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2407 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002408def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2409 (ins GR16:$src1, i16imm:$src2),
2410 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002411 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2412 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002413def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2414 (ins GR32:$src1, i32imm:$src2),
2415 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002416 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2417 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002418def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2419 (ins GR16:$src1, i16i8imm:$src2),
2420 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002421 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2422 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002423def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2424 (ins GR32:$src1, i32i8imm:$src2),
2425 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002426 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2427 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002428
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002429let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002430 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002431 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002432 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002433 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2434 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002435 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002436 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002437 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2438 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002439 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002440 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002441 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2442 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002443
2444 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002445 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002446 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002447 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2448 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002449 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002450 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002451 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2452 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002453 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002454 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002455 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2456 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002457 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002458 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002459 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002460 addr:$dst),
2461 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002462 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002463 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002464 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002465 addr:$dst),
2466 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002467}
2468
Evan Cheng259471d2007-10-05 17:59:57 +00002469let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002470def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2471 (ins GR8:$src1, GR8:$src2),
2472 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002473 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002474def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2475 (ins GR16:$src1, GR16:$src2),
2476 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002477 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002478def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2479 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002480 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002481 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002482
2483let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002484 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2485 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002486 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002487 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2488 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002489 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002490 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002491 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002492 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002493 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002494 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002495 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002496 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002497 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2498 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002499 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002500 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002501 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2502 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002503 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002504 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002505 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002506 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002507 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002508 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002509 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002510 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002511}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002512def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2513 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002514 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002515def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2516 (ins GR16:$src1, i16mem:$src2),
2517 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002518 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002519 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002520def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2521 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002522 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002523 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002524def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2525 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002526 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002527def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2528 (ins GR16:$src1, i16imm:$src2),
2529 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002530 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002531def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2532 (ins GR16:$src1, i16i8imm:$src2),
2533 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002534 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2535 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002536def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2537 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002538 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002539 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002540def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2541 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002542 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002543 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002544} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002545} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002546
Evan Cheng55687072007-09-14 21:48:26 +00002547let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002548let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002549// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002550def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002551 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002552 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2553 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002554def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002555 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002556 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2557 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002558}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002559
Bill Wendlingf5399032008-12-12 21:15:41 +00002560// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002561def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2562 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002563 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002564 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2565 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002566def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002567 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002568 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2569 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002570} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002571} // end Two Address instructions
2572
2573// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002574let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002575// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002576def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002577 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002578 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002579 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2580 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002581def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002582 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002583 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002584 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2585 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002586def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002587 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002588 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002589 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2590 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002591def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002592 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002593 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002594 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2595 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002596
Bill Wendlingf5399032008-12-12 21:15:41 +00002597// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002598def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002599 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002600 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002601 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2602 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002603def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002604 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002605 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002606 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2607 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002608def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002609 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002610 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002611 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002612 i16immSExt8:$src2)),
2613 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002614def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002615 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002616 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002617 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002618 i32immSExt8:$src2)),
2619 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002620} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002621
2622//===----------------------------------------------------------------------===//
2623// Test instructions are just like AND, except they don't generate a result.
2624//
Evan Cheng950aac02007-09-25 01:57:46 +00002625let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002626let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002627def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002628 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002629 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002630 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002631def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002632 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002633 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002634 (implicit EFLAGS)]>,
2635 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002636def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002637 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002638 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002639 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002640}
2641
Evan Chengb783fa32007-07-19 01:14:50 +00002642def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002643 "test{b}\t{$src2, $src1|$src1, $src2}",
2644 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2645 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002646def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002647 "test{w}\t{$src2, $src1|$src1, $src2}",
2648 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2649 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002650def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002651 "test{l}\t{$src2, $src1|$src1, $src2}",
2652 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2653 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002654
2655def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002656 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002657 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002658 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002659 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002660def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002661 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002662 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002663 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002664 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002665def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002666 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002667 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002668 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002669 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002670
Evan Cheng621216e2007-09-29 00:00:36 +00002671def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002672 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002673 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002674 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2675 (implicit EFLAGS)]>;
2676def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002677 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002678 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002679 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2680 (implicit EFLAGS)]>, OpSize;
2681def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002682 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002683 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002684 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002685 (implicit EFLAGS)]>;
2686} // Defs = [EFLAGS]
2687
2688
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002689// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002690let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002691def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002692let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002693def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002694
Evan Cheng950aac02007-09-25 01:57:46 +00002695let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002696def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002697 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002698 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002699 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002700 TB; // GR8 = ==
2701def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002702 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002703 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002704 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002705 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002706
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002707def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002708 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002709 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002710 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002711 TB; // GR8 = !=
2712def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002713 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002714 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002715 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002716 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002717
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002718def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002719 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002720 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002721 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002722 TB; // GR8 = < signed
2723def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002724 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002725 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002726 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002727 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002728
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002729def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002730 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002731 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002732 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002733 TB; // GR8 = >= signed
2734def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002735 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002736 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002737 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002738 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002739
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002740def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002741 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002742 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002743 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002744 TB; // GR8 = <= signed
2745def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002746 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002747 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002748 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002749 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002750
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002751def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002752 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002753 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002754 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002755 TB; // GR8 = > signed
2756def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002757 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002758 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002759 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002760 TB; // [mem8] = > signed
2761
2762def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002763 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002764 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002765 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002766 TB; // GR8 = < unsign
2767def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002768 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002769 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002770 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002771 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002772
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002773def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002774 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002775 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002776 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002777 TB; // GR8 = >= unsign
2778def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002779 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002780 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002781 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002782 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002783
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002784def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002785 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002786 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002787 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002788 TB; // GR8 = <= unsign
2789def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002790 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002791 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002792 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002793 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002794
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002795def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002796 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002797 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002798 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002799 TB; // GR8 = > signed
2800def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002801 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002802 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002803 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002804 TB; // [mem8] = > signed
2805
2806def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002807 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002808 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002809 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002810 TB; // GR8 = <sign bit>
2811def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002812 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002813 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002814 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002815 TB; // [mem8] = <sign bit>
2816def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002817 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002818 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002819 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002820 TB; // GR8 = !<sign bit>
2821def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002822 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002823 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002824 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002825 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002826
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002827def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002828 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002829 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002830 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002831 TB; // GR8 = parity
2832def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002833 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002834 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002835 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002836 TB; // [mem8] = parity
2837def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002838 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002839 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002840 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002841 TB; // GR8 = not parity
2842def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002843 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002844 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002845 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002846 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002847
2848def SETOr : I<0x90, MRM0r,
2849 (outs GR8 :$dst), (ins),
2850 "seto\t$dst",
2851 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2852 TB; // GR8 = overflow
2853def SETOm : I<0x90, MRM0m,
2854 (outs), (ins i8mem:$dst),
2855 "seto\t$dst",
2856 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2857 TB; // [mem8] = overflow
2858def SETNOr : I<0x91, MRM0r,
2859 (outs GR8 :$dst), (ins),
2860 "setno\t$dst",
2861 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2862 TB; // GR8 = not overflow
2863def SETNOm : I<0x91, MRM0m,
2864 (outs), (ins i8mem:$dst),
2865 "setno\t$dst",
2866 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2867 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002868} // Uses = [EFLAGS]
2869
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002870
2871// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002872let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002873def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002874 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002875 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002876 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002877def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002878 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002879 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002880 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002881def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002882 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002883 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002884 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002885def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002886 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002887 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002888 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2889 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002890def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002891 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002892 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002893 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2894 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002895def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002896 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002897 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002898 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2899 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002900def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002901 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002902 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002903 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2904 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002905def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002906 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002907 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002908 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2909 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002910def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002911 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002912 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002913 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2914 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002915def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002916 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002917 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002918 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002919def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002920 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002921 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002922 [(X86cmp GR16:$src1, imm:$src2),
2923 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002924def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002925 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002926 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002927 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002928def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002929 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002930 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002931 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2932 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002933def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002934 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002935 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002936 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2937 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002938def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002939 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002940 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002941 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2942 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002943def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002944 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002945 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002946 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2947 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002948def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002949 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002950 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002951 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2952 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002953def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002954 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002955 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002956 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2957 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002958def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002959 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002960 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002961 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002962 (implicit EFLAGS)]>;
2963} // Defs = [EFLAGS]
2964
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002965// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002966// TODO: BTC, BTR, and BTS
2967let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002968def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002969 "bt{w}\t{$src2, $src1|$src1, $src2}",
2970 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002971 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002972def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002973 "bt{l}\t{$src2, $src1|$src1, $src2}",
2974 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002975 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002976
2977// Unlike with the register+register form, the memory+register form of the
2978// bt instruction does not ignore the high bits of the index. From ISel's
2979// perspective, this is pretty bizarre. Disable these instructions for now.
2980//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2981// "bt{w}\t{$src2, $src1|$src1, $src2}",
2982// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2983// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2984//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2985// "bt{l}\t{$src2, $src1|$src1, $src2}",
2986// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2987// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002988
2989def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2990 "bt{w}\t{$src2, $src1|$src1, $src2}",
2991 [(X86bt GR16:$src1, i16immSExt8:$src2),
2992 (implicit EFLAGS)]>, OpSize, TB;
2993def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
2994 "bt{l}\t{$src2, $src1|$src1, $src2}",
2995 [(X86bt GR32:$src1, i32immSExt8:$src2),
2996 (implicit EFLAGS)]>, TB;
2997// Note that these instructions don't need FastBTMem because that
2998// only applies when the other operand is in a register. When it's
2999// an immediate, bt is still fast.
3000def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3001 "bt{w}\t{$src2, $src1|$src1, $src2}",
3002 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3003 (implicit EFLAGS)]>, OpSize, TB;
3004def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3005 "bt{l}\t{$src2, $src1|$src1, $src2}",
3006 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3007 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003008} // Defs = [EFLAGS]
3009
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003010// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003011// Use movsbl intead of movsbw; we don't care about the high 16 bits
3012// of the register here. This has a smaller encoding and avoids a
3013// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003014def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003015 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3016 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003017def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003018 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3019 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003020def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003021 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003022 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003023def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003024 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003025 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003026def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003027 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003028 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003029def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003030 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003031 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3032
Dan Gohman9203ab42008-07-30 18:09:17 +00003033// Use movzbl intead of movzbw; we don't care about the high 16 bits
3034// of the register here. This has a smaller encoding and avoids a
3035// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003036def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003037 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3038 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003039def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003040 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3041 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003042def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003043 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003044 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003045def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003046 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003047 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003048def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003049 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003050 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003051def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003052 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003053 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3054
Dan Gohman744d4622009-04-13 16:09:41 +00003055// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3056// except that they use GR32_NOREX for the output operand register class
3057// instead of GR32. This allows them to operate on h registers on x86-64.
3058def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3059 (outs GR32_NOREX:$dst), (ins GR8:$src),
3060 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3061 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003062let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003063def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3064 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3065 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3066 []>, TB;
3067
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003068let neverHasSideEffects = 1 in {
3069 let Defs = [AX], Uses = [AL] in
3070 def CBW : I<0x98, RawFrm, (outs), (ins),
3071 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3072 let Defs = [EAX], Uses = [AX] in
3073 def CWDE : I<0x98, RawFrm, (outs), (ins),
3074 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003075
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003076 let Defs = [AX,DX], Uses = [AX] in
3077 def CWD : I<0x99, RawFrm, (outs), (ins),
3078 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3079 let Defs = [EAX,EDX], Uses = [EAX] in
3080 def CDQ : I<0x99, RawFrm, (outs), (ins),
3081 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3082}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003083
3084//===----------------------------------------------------------------------===//
3085// Alias Instructions
3086//===----------------------------------------------------------------------===//
3087
3088// Alias instructions that map movr0 to xor.
3089// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00003090let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003091def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003092 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003093 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003094// Use xorl instead of xorw since we don't care about the high 16 bits,
3095// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003096def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003097 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3098 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003099def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003100 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003101 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003102}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003103
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003104//===----------------------------------------------------------------------===//
3105// Thread Local Storage Instructions
3106//
3107
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003108// All calls clobber the non-callee saved registers. ESP is marked as
3109// a use to prevent stack-pointer assignments that appear immediately
3110// before calls from potentially appearing dead.
3111let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3112 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3113 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3114 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
3115 Uses = [ESP, EBX] in
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003116def TLS_addr32 : I<0, Pseudo, (outs), (ins i32imm:$sym),
Dan Gohman70a8a112009-04-27 15:13:28 +00003117 "leal\t${sym:mem}(,%ebx,1), %eax; "
3118 "call\t___tls_get_addr@PLT",
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003119 [(X86tlsaddr tglobaltlsaddr:$sym)]>,
3120 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003121
sampo9cc09a32009-01-26 01:24:32 +00003122let AddedComplexity = 5 in
3123def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3124 "movl\t%gs:$src, $dst",
3125 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3126
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003127let AddedComplexity = 5 in
3128def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3129 "movl\t%fs:$src, $dst",
3130 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3131
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003132//===----------------------------------------------------------------------===//
3133// DWARF Pseudo Instructions
3134//
3135
Evan Chengb783fa32007-07-19 01:14:50 +00003136def DWARF_LOC : I<0, Pseudo, (outs),
3137 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00003138 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003139 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3140 (i32 imm:$file))]>;
3141
3142//===----------------------------------------------------------------------===//
3143// EH Pseudo Instructions
3144//
3145let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003146 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003147def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003148 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003149 [(X86ehret GR32:$addr)]>;
3150
3151}
3152
3153//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003154// Atomic support
3155//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003156
Evan Cheng3e171562008-04-19 01:20:30 +00003157// Atomic swap. These are just normal xchg instructions. But since a memory
3158// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003159let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003160def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3161 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3162 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3163def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3164 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3165 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3166 OpSize;
3167def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3168 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3169 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3170}
3171
Evan Chengd49dbb82008-04-18 20:55:36 +00003172// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003173let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003174def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003175 "lock\n\t"
3176 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003177 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003178}
Dale Johannesenf160d802008-10-02 18:53:47 +00003179let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003180def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003181 "lock\n\t"
3182 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003183 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3184}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003185
3186let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003187def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003188 "lock\n\t"
3189 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003190 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003191}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003192let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003193def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003194 "lock\n\t"
3195 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003196 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003197}
3198
Evan Chengd49dbb82008-04-18 20:55:36 +00003199// Atomic exchange and add
3200let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3201def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003202 "lock\n\t"
3203 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003204 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003205 TB, LOCK;
3206def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003207 "lock\n\t"
3208 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003209 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003210 TB, OpSize, LOCK;
3211def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003212 "lock\n\t"
3213 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003214 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003215 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003216}
3217
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003218// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003219let Constraints = "$val = $dst", Defs = [EFLAGS],
3220 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003221def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003222 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003223 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003224def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003225 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003226 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003227def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003228 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003229 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003230def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003231 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003232 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003233def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003234 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003235 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003236def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003237 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003238 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003239def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003240 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003241 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003242def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003243 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003244 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003245
3246def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003247 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003248 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003249def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003250 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003251 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003252def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003253 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003254 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003255def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003256 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003257 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003258def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003259 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003260 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003261def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003262 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003263 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003264def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003265 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003266 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003267def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003268 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003269 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003270
3271def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003272 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003273 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003274def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003275 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003276 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003277def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003278 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003279 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003280def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003281 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003282 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003283}
3284
Dale Johannesenf160d802008-10-02 18:53:47 +00003285let Constraints = "$val1 = $dst1, $val2 = $dst2",
3286 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3287 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003288 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003289 usesCustomDAGSchedInserter = 1 in {
3290def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3291 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003292 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003293def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3294 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003295 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003296def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3297 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003298 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003299def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3300 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003301 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003302def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3303 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003304 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003305def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3306 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003307 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003308def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3309 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003310 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003311}
3312
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003313//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003314// Non-Instruction Patterns
3315//===----------------------------------------------------------------------===//
3316
Bill Wendlingfef06052008-09-16 21:48:12 +00003317// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003318def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3319def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003320def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003321def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3322def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3323
3324def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3325 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3326def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3327 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3328def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3329 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3330def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3331 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3332
3333def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3334 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3335def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3336 (MOV32mi addr:$dst, texternalsym:$src)>;
3337
3338// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003339// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003340def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003341 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003342
3343def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003344 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003345def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003346 (TAILCALL)>;
3347
3348def : Pat<(X86tcret GR32:$dst, imm:$off),
3349 (TCRETURNri GR32:$dst, imm:$off)>;
3350
3351def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3352 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3353
3354def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3355 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003356
3357def : Pat<(X86call (i32 tglobaladdr:$dst)),
3358 (CALLpcrel32 tglobaladdr:$dst)>;
3359def : Pat<(X86call (i32 texternalsym:$dst)),
3360 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003361def : Pat<(X86call (i32 imm:$dst)),
3362 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003363
3364// X86 specific add which produces a flag.
3365def : Pat<(addc GR32:$src1, GR32:$src2),
3366 (ADD32rr GR32:$src1, GR32:$src2)>;
3367def : Pat<(addc GR32:$src1, (load addr:$src2)),
3368 (ADD32rm GR32:$src1, addr:$src2)>;
3369def : Pat<(addc GR32:$src1, imm:$src2),
3370 (ADD32ri GR32:$src1, imm:$src2)>;
3371def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3372 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3373
3374def : Pat<(subc GR32:$src1, GR32:$src2),
3375 (SUB32rr GR32:$src1, GR32:$src2)>;
3376def : Pat<(subc GR32:$src1, (load addr:$src2)),
3377 (SUB32rm GR32:$src1, addr:$src2)>;
3378def : Pat<(subc GR32:$src1, imm:$src2),
3379 (SUB32ri GR32:$src1, imm:$src2)>;
3380def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3381 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3382
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003383// Comparisons.
3384
3385// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003386def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003387 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003388def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003389 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003390def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003391 (TEST32rr GR32:$src1, GR32:$src1)>;
3392
Dan Gohman0a3c5222009-01-07 01:00:24 +00003393// Conditional moves with folded loads with operands swapped and conditions
3394// inverted.
3395def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3396 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3397def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3398 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3399def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3400 (CMOVB16rm GR16:$src2, addr:$src1)>;
3401def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3402 (CMOVB32rm GR32:$src2, addr:$src1)>;
3403def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3404 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3405def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3406 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3407def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3408 (CMOVE16rm GR16:$src2, addr:$src1)>;
3409def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3410 (CMOVE32rm GR32:$src2, addr:$src1)>;
3411def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3412 (CMOVA16rm GR16:$src2, addr:$src1)>;
3413def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3414 (CMOVA32rm GR32:$src2, addr:$src1)>;
3415def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3416 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3417def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3418 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3419def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3420 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3421def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3422 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3423def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3424 (CMOVL16rm GR16:$src2, addr:$src1)>;
3425def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3426 (CMOVL32rm GR32:$src2, addr:$src1)>;
3427def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3428 (CMOVG16rm GR16:$src2, addr:$src1)>;
3429def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3430 (CMOVG32rm GR32:$src2, addr:$src1)>;
3431def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3432 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3433def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3434 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3435def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3436 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3437def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3438 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3439def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3440 (CMOVP16rm GR16:$src2, addr:$src1)>;
3441def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3442 (CMOVP32rm GR32:$src2, addr:$src1)>;
3443def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3444 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3445def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3446 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3447def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3448 (CMOVS16rm GR16:$src2, addr:$src1)>;
3449def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3450 (CMOVS32rm GR32:$src2, addr:$src1)>;
3451def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3452 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3453def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3454 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3455def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3456 (CMOVO16rm GR16:$src2, addr:$src1)>;
3457def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3458 (CMOVO32rm GR32:$src2, addr:$src1)>;
3459
Duncan Sands082524c2008-01-23 20:39:46 +00003460// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003461def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3462def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3463def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3464
3465// extload bool -> extload byte
3466def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003467def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3468 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003469def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003470def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3471 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003472def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3473def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3474
Dan Gohmandd612bb2008-08-20 21:27:32 +00003475// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003476def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3477 Requires<[In32BitMode]>;
3478def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3479 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003480def : Pat<(i32 (anyext GR16:$src)),
3481 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003482
Evan Chengf2abee72007-12-13 00:43:27 +00003483// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003484def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3485 (MOVZX32rm8 addr:$src)>;
3486def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3487 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003488
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003489//===----------------------------------------------------------------------===//
3490// Some peepholes
3491//===----------------------------------------------------------------------===//
3492
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003493// Odd encoding trick: -128 fits into an 8-bit immediate field while
3494// +128 doesn't, so in this special case use a sub instead of an add.
3495def : Pat<(add GR16:$src1, 128),
3496 (SUB16ri8 GR16:$src1, -128)>;
3497def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3498 (SUB16mi8 addr:$dst, -128)>;
3499def : Pat<(add GR32:$src1, 128),
3500 (SUB32ri8 GR32:$src1, -128)>;
3501def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3502 (SUB32mi8 addr:$dst, -128)>;
3503
Dan Gohman9203ab42008-07-30 18:09:17 +00003504// r & (2^16-1) ==> movz
3505def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003506 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003507// r & (2^8-1) ==> movz
3508def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003509 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003510 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003511 Requires<[In32BitMode]>;
3512// r & (2^8-1) ==> movz
3513def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003514 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003515 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003516 Requires<[In32BitMode]>;
3517
3518// sext_inreg patterns
3519def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003520 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003521def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003522 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003523 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003524 Requires<[In32BitMode]>;
3525def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003526 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003527 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003528 Requires<[In32BitMode]>;
3529
3530// trunc patterns
3531def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003532 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003533def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003534 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003535 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003536 Requires<[In32BitMode]>;
3537def : Pat<(i8 (trunc GR16:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003538 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003539 x86_subreg_8bit)>,
3540 Requires<[In32BitMode]>;
3541
3542// h-register tricks
3543def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003544 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003545 x86_subreg_8bit_hi)>,
3546 Requires<[In32BitMode]>;
3547def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003548 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003549 x86_subreg_8bit_hi)>,
3550 Requires<[In32BitMode]>;
3551def : Pat<(srl_su GR16:$src, (i8 8)),
3552 (EXTRACT_SUBREG
3553 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003554 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003555 x86_subreg_8bit_hi)),
3556 x86_subreg_16bit)>,
3557 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003558def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3559 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3560 x86_subreg_8bit_hi))>,
3561 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003562def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003563 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003564 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003565 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003566
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003567// (shl x, 1) ==> (add x, x)
3568def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3569def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3570def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3571
Evan Cheng76a64c72008-08-30 02:03:58 +00003572// (shl x (and y, 31)) ==> (shl x, y)
3573def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3574 (SHL8rCL GR8:$src1)>;
3575def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3576 (SHL16rCL GR16:$src1)>;
3577def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3578 (SHL32rCL GR32:$src1)>;
3579def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3580 (SHL8mCL addr:$dst)>;
3581def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3582 (SHL16mCL addr:$dst)>;
3583def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3584 (SHL32mCL addr:$dst)>;
3585
3586def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3587 (SHR8rCL GR8:$src1)>;
3588def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3589 (SHR16rCL GR16:$src1)>;
3590def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3591 (SHR32rCL GR32:$src1)>;
3592def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3593 (SHR8mCL addr:$dst)>;
3594def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3595 (SHR16mCL addr:$dst)>;
3596def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3597 (SHR32mCL addr:$dst)>;
3598
3599def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3600 (SAR8rCL GR8:$src1)>;
3601def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3602 (SAR16rCL GR16:$src1)>;
3603def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3604 (SAR32rCL GR32:$src1)>;
3605def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3606 (SAR8mCL addr:$dst)>;
3607def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3608 (SAR16mCL addr:$dst)>;
3609def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3610 (SAR32mCL addr:$dst)>;
3611
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003612// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3613def : Pat<(or (srl GR32:$src1, CL:$amt),
3614 (shl GR32:$src2, (sub 32, CL:$amt))),
3615 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3616
3617def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3618 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3619 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3620
Dan Gohman921581d2008-10-17 01:23:35 +00003621def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3622 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3623 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3624
3625def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3626 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3627 addr:$dst),
3628 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3629
3630def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3631 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3632
3633def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3634 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3635 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3636
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003637// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3638def : Pat<(or (shl GR32:$src1, CL:$amt),
3639 (srl GR32:$src2, (sub 32, CL:$amt))),
3640 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3641
3642def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3643 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3644 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3645
Dan Gohman921581d2008-10-17 01:23:35 +00003646def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3647 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3648 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3649
3650def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3651 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3652 addr:$dst),
3653 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3654
3655def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3656 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3657
3658def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3659 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3660 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3661
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003662// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3663def : Pat<(or (srl GR16:$src1, CL:$amt),
3664 (shl GR16:$src2, (sub 16, CL:$amt))),
3665 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3666
3667def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3668 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3669 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3670
Dan Gohman921581d2008-10-17 01:23:35 +00003671def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3672 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3673 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3674
3675def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3676 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3677 addr:$dst),
3678 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3679
3680def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3681 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3682
3683def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3684 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3685 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3686
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003687// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3688def : Pat<(or (shl GR16:$src1, CL:$amt),
3689 (srl GR16:$src2, (sub 16, CL:$amt))),
3690 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3691
3692def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3693 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3694 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3695
Dan Gohman921581d2008-10-17 01:23:35 +00003696def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3697 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3698 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3699
3700def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3701 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3702 addr:$dst),
3703 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3704
3705def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3706 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3707
3708def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3709 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3710 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3711
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003712//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003713// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003714//===----------------------------------------------------------------------===//
3715
Dan Gohman99a12192009-03-04 19:44:21 +00003716// Register-Register Addition with EFLAGS result
3717def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003718 (implicit EFLAGS)),
3719 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003720def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003721 (implicit EFLAGS)),
3722 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003723def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003724 (implicit EFLAGS)),
3725 (ADD32rr GR32:$src1, GR32:$src2)>;
3726
Dan Gohman99a12192009-03-04 19:44:21 +00003727// Register-Memory Addition with EFLAGS result
3728def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003729 (implicit EFLAGS)),
3730 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003731def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003732 (implicit EFLAGS)),
3733 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003734def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003735 (implicit EFLAGS)),
3736 (ADD32rm GR32:$src1, addr:$src2)>;
3737
Dan Gohman99a12192009-03-04 19:44:21 +00003738// Register-Integer Addition with EFLAGS result
3739def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003740 (implicit EFLAGS)),
3741 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003742def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003743 (implicit EFLAGS)),
3744 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003745def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003746 (implicit EFLAGS)),
3747 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003748def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003749 (implicit EFLAGS)),
3750 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003751def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003752 (implicit EFLAGS)),
3753 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3754
Dan Gohman99a12192009-03-04 19:44:21 +00003755// Memory-Register Addition with EFLAGS result
3756def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003757 addr:$dst),
3758 (implicit EFLAGS)),
3759 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003760def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003761 addr:$dst),
3762 (implicit EFLAGS)),
3763 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003764def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003765 addr:$dst),
3766 (implicit EFLAGS)),
3767 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003768
3769// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003770def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003771 addr:$dst),
3772 (implicit EFLAGS)),
3773 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003774def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003775 addr:$dst),
3776 (implicit EFLAGS)),
3777 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003778def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003779 addr:$dst),
3780 (implicit EFLAGS)),
3781 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003782def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003783 addr:$dst),
3784 (implicit EFLAGS)),
3785 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003786def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003787 addr:$dst),
3788 (implicit EFLAGS)),
3789 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3790
Dan Gohman99a12192009-03-04 19:44:21 +00003791// Register-Register Subtraction with EFLAGS result
3792def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003793 (implicit EFLAGS)),
3794 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003795def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003796 (implicit EFLAGS)),
3797 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003798def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003799 (implicit EFLAGS)),
3800 (SUB32rr GR32:$src1, GR32:$src2)>;
3801
Dan Gohman99a12192009-03-04 19:44:21 +00003802// Register-Memory Subtraction with EFLAGS result
3803def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003804 (implicit EFLAGS)),
3805 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003806def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003807 (implicit EFLAGS)),
3808 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003809def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003810 (implicit EFLAGS)),
3811 (SUB32rm GR32:$src1, addr:$src2)>;
3812
Dan Gohman99a12192009-03-04 19:44:21 +00003813// Register-Integer Subtraction with EFLAGS result
3814def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003815 (implicit EFLAGS)),
3816 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003817def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003818 (implicit EFLAGS)),
3819 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003820def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003821 (implicit EFLAGS)),
3822 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003823def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003824 (implicit EFLAGS)),
3825 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003826def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003827 (implicit EFLAGS)),
3828 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3829
Dan Gohman99a12192009-03-04 19:44:21 +00003830// Memory-Register Subtraction with EFLAGS result
3831def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003832 addr:$dst),
3833 (implicit EFLAGS)),
3834 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003835def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003836 addr:$dst),
3837 (implicit EFLAGS)),
3838 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003839def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003840 addr:$dst),
3841 (implicit EFLAGS)),
3842 (SUB32mr addr:$dst, GR32:$src2)>;
3843
Dan Gohman99a12192009-03-04 19:44:21 +00003844// Memory-Integer Subtraction with EFLAGS result
3845def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003846 addr:$dst),
3847 (implicit EFLAGS)),
3848 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003849def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003850 addr:$dst),
3851 (implicit EFLAGS)),
3852 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003853def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003854 addr:$dst),
3855 (implicit EFLAGS)),
3856 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003857def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003858 addr:$dst),
3859 (implicit EFLAGS)),
3860 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003861def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003862 addr:$dst),
3863 (implicit EFLAGS)),
3864 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3865
3866
Dan Gohman99a12192009-03-04 19:44:21 +00003867// Register-Register Signed Integer Multiply with EFLAGS result
3868def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003869 (implicit EFLAGS)),
3870 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003871def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003872 (implicit EFLAGS)),
3873 (IMUL32rr GR32:$src1, GR32:$src2)>;
3874
Dan Gohman99a12192009-03-04 19:44:21 +00003875// Register-Memory Signed Integer Multiply with EFLAGS result
3876def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003877 (implicit EFLAGS)),
3878 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003879def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003880 (implicit EFLAGS)),
3881 (IMUL32rm GR32:$src1, addr:$src2)>;
3882
Dan Gohman99a12192009-03-04 19:44:21 +00003883// Register-Integer Signed Integer Multiply with EFLAGS result
3884def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003885 (implicit EFLAGS)),
3886 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003887def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003888 (implicit EFLAGS)),
3889 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003890def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003891 (implicit EFLAGS)),
3892 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003893def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003894 (implicit EFLAGS)),
3895 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3896
Dan Gohman99a12192009-03-04 19:44:21 +00003897// Memory-Integer Signed Integer Multiply with EFLAGS result
3898def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003899 (implicit EFLAGS)),
3900 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003901def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003902 (implicit EFLAGS)),
3903 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003904def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003905 (implicit EFLAGS)),
3906 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003907def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003908 (implicit EFLAGS)),
3909 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3910
Dan Gohman99a12192009-03-04 19:44:21 +00003911// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003912let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003913def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003914 (implicit EFLAGS)),
3915 (ADD16rr GR16:$src1, GR16:$src1)>;
3916
Dan Gohman99a12192009-03-04 19:44:21 +00003917def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003918 (implicit EFLAGS)),
3919 (ADD32rr GR32:$src1, GR32:$src1)>;
3920}
3921
Dan Gohman99a12192009-03-04 19:44:21 +00003922// INC and DEC with EFLAGS result. Note that these do not set CF.
3923def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3924 (INC8r GR8:$src)>;
3925def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3926 (implicit EFLAGS)),
3927 (INC8m addr:$dst)>;
3928def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3929 (DEC8r GR8:$src)>;
3930def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3931 (implicit EFLAGS)),
3932 (DEC8m addr:$dst)>;
3933
3934def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003935 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003936def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3937 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003938 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003939def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003940 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003941def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3942 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003943 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003944
3945def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003946 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003947def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3948 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003949 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003950def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003951 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003952def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3953 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003954 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003955
Bill Wendlingf5399032008-12-12 21:15:41 +00003956//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003957// Floating Point Stack Support
3958//===----------------------------------------------------------------------===//
3959
3960include "X86InstrFPStack.td"
3961
3962//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003963// X86-64 Support
3964//===----------------------------------------------------------------------===//
3965
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003966include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003967
3968//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003969// XMM Floating point support (requires SSE / SSE2)
3970//===----------------------------------------------------------------------===//
3971
3972include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003973
3974//===----------------------------------------------------------------------===//
3975// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3976//===----------------------------------------------------------------------===//
3977
3978include "X86InstrMMX.td"