blob: a6b0880dac09eaccb943cc2f83f5fb9c3e370807 [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
20def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
24def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
Evan Cheng621216e2007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng950aac02007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029
Dan Gohman99a12192009-03-04 19:44:21 +000030// Unary and binary operator instructions that set EFLAGS as a side-effect.
31def SDTUnaryArithWithFlags : SDTypeProfile<1, 1,
32 [SDTCisInt<0>]>;
33def SDTBinaryArithWithFlags : SDTypeProfile<1, 2,
34 [SDTCisSameAs<0, 1>,
35 SDTCisSameAs<0, 2>,
36 SDTCisInt<0>]>;
Evan Cheng621216e2007-09-29 00:00:36 +000037def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000038 [SDTCisVT<0, OtherVT>,
39 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000040
Evan Cheng621216e2007-09-29 00:00:36 +000041def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000042 [SDTCisVT<0, i8>,
43 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000044
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000045def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
46 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000047def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000048
Dale Johannesenf160d802008-10-02 18:53:47 +000049def SDTX86atomicBinary : SDTypeProfile<2, 3, [SDTCisInt<0>, SDTCisInt<1>,
50 SDTCisPtrTy<2>, SDTCisInt<3>,SDTCisInt<4>]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +000051def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052
Sean Callanan2c8a2592009-06-23 23:25:37 +000053def SDT_X86CallSeqStart : SDCallSeqStart<[SDTCisVT<0, i32>]>;
54def SDT_X86CallSeqEnd : SDCallSeqEnd<[SDTCisVT<0, i32>,
55 SDTCisVT<1, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000056
Dan Gohman3329ffe2008-05-29 19:57:41 +000057def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000058
59def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
60
61def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
62
63def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
64
Rafael Espindolaaf759ab2009-04-17 14:35:58 +000065def SDT_X86TLSADDR : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066
Rafael Espindolabca99f72009-04-08 21:14:34 +000067def SDT_X86SegmentBaseAddress : SDTypeProfile<1, 1, [SDTCisPtrTy<0>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068
69def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
70
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000071def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
72
Evan Cheng48679f42007-12-14 02:13:44 +000073def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
74def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000075def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
76def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
77
Evan Cheng621216e2007-09-29 00:00:36 +000078def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079
Dan Gohman7fe9b7f2008-12-23 22:45:23 +000080def X86bt : SDNode<"X86ISD::BT", SDTX86CmpTest>;
81
Evan Cheng621216e2007-09-29 00:00:36 +000082def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000084 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000085def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000087def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
89 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000090def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
91 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
92 SDNPMayLoad]>;
Dale Johannesenf160d802008-10-02 18:53:47 +000093def X86AtomAdd64 : SDNode<"X86ISD::ATOMADD64_DAG", SDTX86atomicBinary,
94 [SDNPHasChain, SDNPMayStore,
95 SDNPMayLoad, SDNPMemOperand]>;
96def X86AtomSub64 : SDNode<"X86ISD::ATOMSUB64_DAG", SDTX86atomicBinary,
97 [SDNPHasChain, SDNPMayStore,
98 SDNPMayLoad, SDNPMemOperand]>;
99def X86AtomOr64 : SDNode<"X86ISD::ATOMOR64_DAG", SDTX86atomicBinary,
100 [SDNPHasChain, SDNPMayStore,
101 SDNPMayLoad, SDNPMemOperand]>;
102def X86AtomXor64 : SDNode<"X86ISD::ATOMXOR64_DAG", SDTX86atomicBinary,
103 [SDNPHasChain, SDNPMayStore,
104 SDNPMayLoad, SDNPMemOperand]>;
105def X86AtomAnd64 : SDNode<"X86ISD::ATOMAND64_DAG", SDTX86atomicBinary,
106 [SDNPHasChain, SDNPMayStore,
107 SDNPMayLoad, SDNPMemOperand]>;
108def X86AtomNand64 : SDNode<"X86ISD::ATOMNAND64_DAG", SDTX86atomicBinary,
109 [SDNPHasChain, SDNPMayStore,
110 SDNPMayLoad, SDNPMemOperand]>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +0000111def X86AtomSwap64 : SDNode<"X86ISD::ATOMSWAP64_DAG", SDTX86atomicBinary,
112 [SDNPHasChain, SDNPMayStore,
113 SDNPMayLoad, SDNPMemOperand]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000114def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
115 [SDNPHasChain, SDNPOptInFlag]>;
116
117def X86callseq_start :
118 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
119 [SDNPHasChain, SDNPOutFlag]>;
120def X86callseq_end :
121 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000122 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123
124def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
125 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
126
127def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
128 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
129
130def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000131 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000133 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
134 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000135
136def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000137 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000138
139def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
140def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
141
142def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000143 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000144def X86SegmentBaseAddress : SDNode<"X86ISD::SegmentBaseAddress",
145 SDT_X86SegmentBaseAddress, []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000146
147def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
148 [SDNPHasChain]>;
149
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000150def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
151 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000152
Dan Gohman99a12192009-03-04 19:44:21 +0000153def X86add_flag : SDNode<"X86ISD::ADD", SDTBinaryArithWithFlags>;
154def X86sub_flag : SDNode<"X86ISD::SUB", SDTBinaryArithWithFlags>;
155def X86smul_flag : SDNode<"X86ISD::SMUL", SDTBinaryArithWithFlags>;
156def X86umul_flag : SDNode<"X86ISD::UMUL", SDTUnaryArithWithFlags>;
157def X86inc_flag : SDNode<"X86ISD::INC", SDTUnaryArithWithFlags>;
158def X86dec_flag : SDNode<"X86ISD::DEC", SDTUnaryArithWithFlags>;
Bill Wendlingae034ed2008-12-12 00:56:36 +0000159
Evan Chengc3495762009-03-30 21:36:47 +0000160def X86mul_imm : SDNode<"X86ISD::MUL_IMM", SDTIntBinOp>;
161
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000162//===----------------------------------------------------------------------===//
163// X86 Operand Definitions.
164//
165
Chris Lattner357a0ca2009-06-20 19:34:09 +0000166def i32imm_pcrel : Operand<i32> {
167 let PrintMethod = "print_pcrel_imm";
168}
169
170
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171// *mem - Operand definitions for the funky X86 addressing mode operands.
172//
173class X86MemOperand<string printMethod> : Operand<iPTR> {
174 let PrintMethod = printMethod;
Rafael Espindolabca99f72009-04-08 21:14:34 +0000175 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm, i8imm);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176}
177
178def i8mem : X86MemOperand<"printi8mem">;
179def i16mem : X86MemOperand<"printi16mem">;
180def i32mem : X86MemOperand<"printi32mem">;
181def i64mem : X86MemOperand<"printi64mem">;
182def i128mem : X86MemOperand<"printi128mem">;
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], []>;
Chris Lattnerf1940742009-06-20 20:38:48 +0000227def tls32addr : ComplexPattern<i32, 4, "SelectTLSADDRAddr",
228 [tglobaltlsaddr], []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000229
230//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231// X86 Instruction Predicate Definitions.
232def HasMMX : Predicate<"Subtarget->hasMMX()">;
233def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
234def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
235def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
236def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000237def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
238def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
David Greene8bf22bc2009-06-26 22:46:54 +0000239def HasSSE4A : Predicate<"Subtarget->hasSSE4A()">;
240def HasAVX : Predicate<"Subtarget->hasAVX()">;
241def HasFMA3 : Predicate<"Subtarget->hasFMA3()">;
242def HasFMA4 : Predicate<"Subtarget->hasFMA4()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000243def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
244def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000245def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
246def In64BitMode : Predicate<"Subtarget->is64Bit()">;
247def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
248def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
249def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
Evan Cheng13559d62008-09-26 23:41:32 +0000250def OptForSpeed : Predicate<"!OptForSize">;
Evan Cheng95a77fd2009-01-02 05:35:45 +0000251def FastBTMem : Predicate<"!Subtarget->isBTMemSlow()">;
Evan Cheng6d35a4d2009-05-20 04:53:57 +0000252def CallImmAddr : Predicate<"Subtarget->IsLegalToCallImmediateAddr(TM)">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000253
254//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000255// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000256//
257
Evan Cheng86ab7d32007-07-31 08:04:03 +0000258include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000259
260//===----------------------------------------------------------------------===//
261// Pattern fragments...
262//
263
264// X86 specific condition code. These correspond to CondCode in
265// X86InstrInfo.h. They must be kept in synch.
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000266def X86_COND_A : PatLeaf<(i8 0)>; // alt. COND_NBE
267def X86_COND_AE : PatLeaf<(i8 1)>; // alt. COND_NC
268def X86_COND_B : PatLeaf<(i8 2)>; // alt. COND_C
269def X86_COND_BE : PatLeaf<(i8 3)>; // alt. COND_NA
270def X86_COND_E : PatLeaf<(i8 4)>; // alt. COND_Z
271def X86_COND_G : PatLeaf<(i8 5)>; // alt. COND_NLE
272def X86_COND_GE : PatLeaf<(i8 6)>; // alt. COND_NL
273def X86_COND_L : PatLeaf<(i8 7)>; // alt. COND_NGE
274def X86_COND_LE : PatLeaf<(i8 8)>; // alt. COND_NG
275def X86_COND_NE : PatLeaf<(i8 9)>; // alt. COND_NZ
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276def X86_COND_NO : PatLeaf<(i8 10)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000277def X86_COND_NP : PatLeaf<(i8 11)>; // alt. COND_PO
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000278def X86_COND_NS : PatLeaf<(i8 12)>;
Dan Gohman0fc9ed62009-01-07 00:15:08 +0000279def X86_COND_O : PatLeaf<(i8 13)>;
280def X86_COND_P : PatLeaf<(i8 14)>; // alt. COND_PE
281def X86_COND_S : PatLeaf<(i8 15)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282
283def i16immSExt8 : PatLeaf<(i16 imm), [{
284 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
285 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000286 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287}]>;
288
289def i32immSExt8 : PatLeaf<(i32 imm), [{
290 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
291 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000292 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000293}]>;
294
295// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000296// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
297// known to be 32-bit aligned or better. Ditto for i8 to i16.
Dan Gohman2a174122008-10-15 06:50:19 +0000298def loadi16 : PatFrag<(ops node:$ptr), (i16 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000299 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000300 if (const Value *Src = LD->getSrcValue())
301 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000302 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000303 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000304 ISD::LoadExtType ExtType = LD->getExtensionType();
305 if (ExtType == ISD::NON_EXTLOAD)
306 return true;
307 if (ExtType == ISD::EXTLOAD)
308 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000309 return false;
310}]>;
311
Dan Gohman2a174122008-10-15 06:50:19 +0000312def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng56ec77b2008-09-24 23:27:55 +0000313 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000314 if (const Value *Src = LD->getSrcValue())
315 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000316 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000317 return false;
Evan Cheng56ec77b2008-09-24 23:27:55 +0000318 ISD::LoadExtType ExtType = LD->getExtensionType();
319 if (ExtType == ISD::EXTLOAD)
320 return LD->getAlignment() >= 2 && !LD->isVolatile();
321 return false;
322}]>;
323
Dan Gohman2a174122008-10-15 06:50:19 +0000324def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000325 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000326 if (const Value *Src = LD->getSrcValue())
327 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000328 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000329 return false;
Dan Gohman8335c412008-08-20 15:24:22 +0000330 ISD::LoadExtType ExtType = LD->getExtensionType();
331 if (ExtType == ISD::NON_EXTLOAD)
332 return true;
333 if (ExtType == ISD::EXTLOAD)
334 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000335 return false;
336}]>;
337
Dan Gohman2a174122008-10-15 06:50:19 +0000338def nvloadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{
Evan Cheng1e5e5452008-09-29 17:26:18 +0000339 LoadSDNode *LD = cast<LoadSDNode>(N);
Chris Lattner12208612009-04-10 00:16:23 +0000340 if (const Value *Src = LD->getSrcValue())
341 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000342 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000343 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000344 if (LD->isVolatile())
345 return false;
Evan Cheng1e5e5452008-09-29 17:26:18 +0000346 ISD::LoadExtType ExtType = LD->getExtensionType();
347 if (ExtType == ISD::NON_EXTLOAD)
348 return true;
349 if (ExtType == ISD::EXTLOAD)
350 return LD->getAlignment() >= 4;
351 return false;
352}]>;
353
sampo9cc09a32009-01-26 01:24:32 +0000354def gsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
Chris Lattner12208612009-04-10 00:16:23 +0000355 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
356 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
357 return PT->getAddressSpace() == 256;
sampo9cc09a32009-01-26 01:24:32 +0000358 return false;
359}]>;
360
Chris Lattnera7c2d8a2009-05-05 18:52:19 +0000361def fsload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
362 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
363 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
364 return PT->getAddressSpace() == 257;
365 return false;
366}]>;
367
Chris Lattner12208612009-04-10 00:16:23 +0000368def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr)), [{
369 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
370 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000371 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000372 return false;
373 return true;
374}]>;
375def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr)), [{
376 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
377 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000378 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000379 return false;
380 return true;
381}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382
Chris Lattner12208612009-04-10 00:16:23 +0000383def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr)), [{
384 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
385 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000386 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000387 return false;
388 return true;
389}]>;
390def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr)), [{
391 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
392 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000393 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000394 return false;
395 return true;
396}]>;
397def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr)), [{
398 if (const Value *Src = cast<LoadSDNode>(N)->getSrcValue())
399 if (const PointerType *PT = dyn_cast<PointerType>(Src->getType()))
Mon P Wangdc97d5a2009-04-27 07:22:10 +0000400 if (PT->getAddressSpace() > 255)
Chris Lattner12208612009-04-10 00:16:23 +0000401 return false;
402 return true;
403}]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000404
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
406def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
407def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
408
409def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
410def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
411def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
412def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
413def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
414def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
415
416def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
417def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
418def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
419def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
420def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
421def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
422
Chris Lattner21da6382008-02-19 17:37:35 +0000423
424// An 'and' node with a single use.
425def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000426 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000427}]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000428// An 'srl' node with a single use.
429def srl_su : PatFrag<(ops node:$lhs, node:$rhs), (srl node:$lhs, node:$rhs), [{
430 return N->hasOneUse();
431}]>;
432// An 'trunc' node with a single use.
433def trunc_su : PatFrag<(ops node:$src), (trunc node:$src), [{
434 return N->hasOneUse();
435}]>;
Chris Lattner21da6382008-02-19 17:37:35 +0000436
Dan Gohman921581d2008-10-17 01:23:35 +0000437// 'shld' and 'shrd' instruction patterns. Note that even though these have
438// the srl and shl in their patterns, the C++ code must still check for them,
439// because predicates are tested before children nodes are explored.
440
441def shrd : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
442 (or (srl node:$src1, node:$amt1),
443 (shl node:$src2, node:$amt2)), [{
444 assert(N->getOpcode() == ISD::OR);
445 return N->getOperand(0).getOpcode() == ISD::SRL &&
446 N->getOperand(1).getOpcode() == ISD::SHL &&
447 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
448 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
449 N->getOperand(0).getConstantOperandVal(1) ==
450 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
451}]>;
452
453def shld : PatFrag<(ops node:$src1, node:$amt1, node:$src2, node:$amt2),
454 (or (shl node:$src1, node:$amt1),
455 (srl node:$src2, node:$amt2)), [{
456 assert(N->getOpcode() == ISD::OR);
457 return N->getOperand(0).getOpcode() == ISD::SHL &&
458 N->getOperand(1).getOpcode() == ISD::SRL &&
459 isa<ConstantSDNode>(N->getOperand(0).getOperand(1)) &&
460 isa<ConstantSDNode>(N->getOperand(1).getOperand(1)) &&
461 N->getOperand(0).getConstantOperandVal(1) ==
462 N->getValueSizeInBits(0) - N->getOperand(1).getConstantOperandVal(1);
463}]>;
464
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000465//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000466// Instruction list...
467//
468
469// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
470// a stack adjustment and the codegen must know that they may modify the stack
471// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000472// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
473// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000474let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Dan Gohman01c9f772008-10-01 18:28:06 +0000475def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
476 "#ADJCALLSTACKDOWN",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000477 [(X86callseq_start timm:$amt)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000478 Requires<[In32BitMode]>;
479def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
480 "#ADJCALLSTACKUP",
Chris Lattnerfe5d4022008-10-11 22:08:30 +0000481 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
Dan Gohman01c9f772008-10-01 18:28:06 +0000482 Requires<[In32BitMode]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000483}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000484
485// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000486let neverHasSideEffects = 1 in
487 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000488
Evan Cheng0729ccf2008-01-05 00:41:47 +0000489// PIC base
Dan Gohman9499cfe2008-10-01 04:14:30 +0000490let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000491 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
Dan Gohman70a8a112009-04-27 15:13:28 +0000492 "call\t$label\n\t"
493 "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000494
495//===----------------------------------------------------------------------===//
496// Control Flow Instructions...
497//
498
499// Return instructions.
500let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000501 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000502 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000503 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000504 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000505 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
506 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507 [(X86retflag imm:$amt)]>;
508}
509
510// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000511let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000512 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
513 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000514
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000516 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000517
Owen Andersonf8053082007-11-12 07:39:39 +0000518// Indirect branches
519let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000520 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000521 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000522 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000523 [(brind (loadi32 addr:$dst))]>;
524}
525
526// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000527let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000528def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000529 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000530def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000531 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000532def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000533 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000534def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000535 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000536def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000537 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000538def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000539 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000540
Dan Gohman91888f02007-07-31 20:11:57 +0000541def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000542 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000543def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000544 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000545def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000546 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000547def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000548 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549
Dan Gohman91888f02007-07-31 20:11:57 +0000550def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000551 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000552def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000553 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000554def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000555 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000556def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000557 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000558def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000559 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000560def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000561 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000562} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563
564//===----------------------------------------------------------------------===//
565// Call Instructions...
566//
Evan Cheng37e7c752007-07-21 00:34:19 +0000567let isCall = 1 in
Dan Gohman01c9f772008-10-01 18:28:06 +0000568 // All calls clobber the non-callee saved registers. ESP is marked as
569 // a use to prevent stack-pointer assignments that appear immediately
570 // before calls from potentially appearing dead. Uses for argument
571 // registers are added manually.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000572 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
573 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng2293b252008-10-17 21:02:22 +0000574 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
575 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Dan Gohman9499cfe2008-10-01 04:14:30 +0000576 Uses = [ESP] in {
Chris Lattner357a0ca2009-06-20 19:34:09 +0000577 def CALLpcrel32 : Ii32<0xE8, RawFrm,
578 (outs), (ins i32imm_pcrel:$dst,variable_ops),
579 "call\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000580 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000581 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000582 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000583 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 }
585
586// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000587
Chris Lattnerb56cc342008-03-11 03:23:40 +0000588def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000589 "#TAILCALL",
590 []>;
591
Evan Cheng37e7c752007-07-21 00:34:19 +0000592let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000593def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000594 "#TC_RETURN $dst $offset",
595 []>;
596
597let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000598def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000599 "#TC_RETURN $dst $offset",
600 []>;
601
602let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000603
Chris Lattner357a0ca2009-06-20 19:34:09 +0000604 def TAILJMPd : IBr<0xE9, (ins i32imm_pcrel:$dst), "jmp\t$dst # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000605 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000606let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000607 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
608 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000609let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000610 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000611 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612
613//===----------------------------------------------------------------------===//
614// Miscellaneous Instructions...
615//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000616let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000617def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000618 (outs), (ins), "leave", []>;
619
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000620let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
621let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000622def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000623
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000624let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000625def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000626}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627
Bill Wendling4c2638c2009-06-15 19:39:04 +0000628let Defs = [ESP], Uses = [ESP], neverHasSideEffects = 1, mayStore = 1 in {
629def PUSH32i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000630 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000631def PUSH32i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000632 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000633def PUSH32i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm),
Bill Wendling0b0437f2009-06-15 20:59:31 +0000634 "push{l}\t$imm", []>;
Bill Wendling4c2638c2009-06-15 19:39:04 +0000635}
636
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000637let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000638def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000639let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000640def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000641
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000642let isTwoAddress = 1 in // GR32 = bswap GR32
643 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000644 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000645 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000646 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
647
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648
Evan Cheng48679f42007-12-14 02:13:44 +0000649// Bit scan instructions.
650let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000651def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000652 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000653 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000654def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000655 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000656 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
657 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000658def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000659 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000660 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000661def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000662 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000663 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
664 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000665
Evan Cheng4e33de92007-12-14 18:49:43 +0000666def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000667 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000668 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000669def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000670 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000671 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
672 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000673def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000674 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000675 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000676def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000677 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000678 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
679 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000680} // Defs = [EFLAGS]
681
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000682let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000684 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000685 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000686let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000688 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000689 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
691
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000692let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000693def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000694 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000695def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000696 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000697def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000698 [(X86rep_movs i32)]>, REP;
699}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000701let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000702def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000703 [(X86rep_stos i8)]>, REP;
704let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000705def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000706 [(X86rep_stos i16)]>, REP, OpSize;
707let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000708def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000709 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000711let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000712def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000713 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000715let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000716def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000717}
718
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719//===----------------------------------------------------------------------===//
720// Input/Output Instructions...
721//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000722let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000723def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000724 "in{b}\t{%dx, %al|%AL, %DX}", []>;
725let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000726def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000727 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
728let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000729def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000730 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000732let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000733def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000734 "in{b}\t{$port, %al|%AL, $port}", []>;
735let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000736def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000737 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
738let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000739def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000740 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000742let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000743def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000744 "out{b}\t{%al, %dx|%DX, %AL}", []>;
745let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000746def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000747 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
748let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000749def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000750 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000752let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000753def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000754 "out{b}\t{%al, $port|$port, %AL}", []>;
755let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000756def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000757 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
758let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000759def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000760 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000761
762//===----------------------------------------------------------------------===//
763// Move Instructions...
764//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000765let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000766def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000767 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000768def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000769 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000770def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000771 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000772}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000773let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000774def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000775 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000777def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000778 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000780def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000781 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782 [(set GR32:$dst, imm:$src)]>;
783}
Evan Chengb783fa32007-07-19 01:14:50 +0000784def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000785 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000787def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000788 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000790def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000791 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 [(store (i32 imm:$src), addr:$dst)]>;
793
Dan Gohman5574cc72008-12-03 18:15:48 +0000794let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000795def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000796 "mov{b}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000797 [(set GR8:$dst, (loadi8 addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000798def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000799 "mov{w}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000800 [(set GR16:$dst, (loadi16 addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000801def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000802 "mov{l}\t{$src, $dst|$dst, $src}",
Chris Lattner12208612009-04-10 00:16:23 +0000803 [(set GR32:$dst, (loadi32 addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000804}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805
Evan Chengb783fa32007-07-19 01:14:50 +0000806def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000807 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000809def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000810 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000812def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000813 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814 [(store GR32:$src, addr:$dst)]>;
Dan Gohman744d4622009-04-13 16:09:41 +0000815
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000816// Versions of MOV8rr, MOV8mr, and MOV8rm that use i8mem_NOREX and GR8_NOREX so
817// that they can be used for copying and storing h registers, which can't be
818// encoded when a REX prefix is present.
Dan Gohman2da0db32009-04-15 00:04:23 +0000819let neverHasSideEffects = 1 in
Dan Gohman40ddc362009-04-15 19:48:57 +0000820def MOV8rr_NOREX : I<0x88, MRMDestReg,
821 (outs GR8_NOREX:$dst), (ins GR8_NOREX:$src),
Dan Gohman2da0db32009-04-15 00:04:23 +0000822 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000823let mayStore = 1 in
Dan Gohman2da0db32009-04-15 00:04:23 +0000824def MOV8mr_NOREX : I<0x88, MRMDestMem,
825 (outs), (ins i8mem_NOREX:$dst, GR8_NOREX:$src),
826 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Evan Chengebc49402009-04-30 00:58:57 +0000827let mayLoad = 1,
828 canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in
Dan Gohman1d8ce9c2009-04-27 16:41:36 +0000829def MOV8rm_NOREX : I<0x8A, MRMSrcMem,
830 (outs GR8_NOREX:$dst), (ins i8mem_NOREX:$src),
831 "mov{b}\t{$src, $dst|$dst, $src} # NOREX", []>;
Dan Gohman744d4622009-04-13 16:09:41 +0000832
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833//===----------------------------------------------------------------------===//
834// Fixed-Register Multiplication and Division Instructions...
835//
836
837// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000838let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000839def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
841 // This probably ought to be moved to a def : Pat<> if the
842 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000843 [(set AL, (mul AL, GR8:$src)),
844 (implicit EFLAGS)]>; // AL,AH = AL*GR8
845
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000846let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000847def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src),
848 "mul{w}\t$src",
849 []>, OpSize; // AX,DX = AX*GR16
850
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000851let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Bill Wendlingf5399032008-12-12 21:15:41 +0000852def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src),
853 "mul{l}\t$src",
854 []>; // EAX,EDX = EAX*GR32
855
Evan Cheng55687072007-09-14 21:48:26 +0000856let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000857def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000858 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
860 // This probably ought to be moved to a def : Pat<> if the
861 // syntax can be accepted.
Bill Wendlingf5399032008-12-12 21:15:41 +0000862 [(set AL, (mul AL, (loadi8 addr:$src))),
863 (implicit EFLAGS)]>; // AL,AH = AL*[mem8]
864
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000865let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000866let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000867def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000868 "mul{w}\t$src",
869 []>, OpSize; // AX,DX = AX*[mem16]
870
Evan Cheng55687072007-09-14 21:48:26 +0000871let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000872def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Bill Wendlingf5399032008-12-12 21:15:41 +0000873 "mul{l}\t$src",
874 []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000875}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000877let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000878let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000879def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
880 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000881let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000882def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000883 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000884let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000885def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
886 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000887let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000888let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000889def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000890 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000891let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000892def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000893 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
894let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000895def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000896 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000897}
Dan Gohmand44572d2008-11-18 21:29:14 +0000898} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000899
900// unsigned division/remainder
Dale Johannesend8fd3562008-10-07 18:54:28 +0000901let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000902def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000903 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000904let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000905def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000906 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000907let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000908def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000909 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000910let mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000911let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000912def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000913 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000914let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000915def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000916 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000917let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000918def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000919 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000920}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921
922// Signed division/remainder.
Dale Johannesend8fd3562008-10-07 18:54:28 +0000923let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000924def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000925 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000926let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000927def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000928 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000929let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000930def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000931 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000932let mayLoad = 1, mayLoad = 1 in {
Dale Johannesend8fd3562008-10-07 18:54:28 +0000933let Defs = [AL,AH,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000934def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000935 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000936let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000937def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000938 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000939let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000940def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000941 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000942}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943
944//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000945// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946//
947let isTwoAddress = 1 in {
948
949// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000950let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000951let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000953 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000954 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000956 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000959 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000960 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000962 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000965 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000966 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000968 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000969 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000971 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000972 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000974 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000975 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000977 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000978 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000979 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000980 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000983 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000984 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000986 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000989 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000990 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000991 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000992 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000993 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000995 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000996 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000998 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001001 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001002 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001004 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001007 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001008 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001010 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001013 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001014 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001016 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001017 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001019 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001020 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001021 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001022 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001025 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001026 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001027 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001028 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001031 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001032 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001034 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001037 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001038 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001040 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001043 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001044 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001046 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001049 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001050 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001051 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001052 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001055 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001056 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001058 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001061 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001062 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001064 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001066def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001067 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001068 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001069 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001070 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001073 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001074 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001076 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001079 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001080 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001082 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001084def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001085 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001086 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001088 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001091 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001092 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001094 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001097 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001098 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001100 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001101 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001103 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001104 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001106 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001107 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +00001109 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001110 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001112 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001114def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +00001115 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001116 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +00001118 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001120def CMOVO16rr : I<0x40, MRMSrcReg, // if overflow, GR16 = GR16
1121 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1122 "cmovo\t{$src2, $dst|$dst, $src2}",
1123 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1124 X86_COND_O, EFLAGS))]>,
1125 TB, OpSize;
1126def CMOVO32rr : I<0x40, MRMSrcReg, // if overflow, GR32 = GR32
1127 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1128 "cmovo\t{$src2, $dst|$dst, $src2}",
1129 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1130 X86_COND_O, EFLAGS))]>,
Evan Cheng950aac02007-09-25 01:57:46 +00001131 TB;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001132def CMOVNO16rr : I<0x41, MRMSrcReg, // if !overflow, GR16 = GR16
1133 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1134 "cmovno\t{$src2, $dst|$dst, $src2}",
1135 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
1136 X86_COND_NO, EFLAGS))]>,
1137 TB, OpSize;
1138def CMOVNO32rr : I<0x41, MRMSrcReg, // if !overflow, GR32 = GR32
1139 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1140 "cmovno\t{$src2, $dst|$dst, $src2}",
1141 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
1142 X86_COND_NO, EFLAGS))]>,
1143 TB;
1144} // isCommutable = 1
Evan Cheng926658c2007-10-05 23:13:21 +00001145
1146def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
1147 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1148 "cmovb\t{$src2, $dst|$dst, $src2}",
1149 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1150 X86_COND_B, EFLAGS))]>,
1151 TB, OpSize;
1152def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
1153 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1154 "cmovb\t{$src2, $dst|$dst, $src2}",
1155 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1156 X86_COND_B, EFLAGS))]>,
1157 TB;
1158def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
1159 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1160 "cmovae\t{$src2, $dst|$dst, $src2}",
1161 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1162 X86_COND_AE, EFLAGS))]>,
1163 TB, OpSize;
1164def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
1165 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1166 "cmovae\t{$src2, $dst|$dst, $src2}",
1167 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1168 X86_COND_AE, EFLAGS))]>,
1169 TB;
1170def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
1171 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1172 "cmove\t{$src2, $dst|$dst, $src2}",
1173 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1174 X86_COND_E, EFLAGS))]>,
1175 TB, OpSize;
1176def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
1177 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1178 "cmove\t{$src2, $dst|$dst, $src2}",
1179 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1180 X86_COND_E, EFLAGS))]>,
1181 TB;
1182def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
1183 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1184 "cmovne\t{$src2, $dst|$dst, $src2}",
1185 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1186 X86_COND_NE, EFLAGS))]>,
1187 TB, OpSize;
1188def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
1189 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1190 "cmovne\t{$src2, $dst|$dst, $src2}",
1191 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1192 X86_COND_NE, EFLAGS))]>,
1193 TB;
1194def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
1195 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1196 "cmovbe\t{$src2, $dst|$dst, $src2}",
1197 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1198 X86_COND_BE, EFLAGS))]>,
1199 TB, OpSize;
1200def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
1201 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1202 "cmovbe\t{$src2, $dst|$dst, $src2}",
1203 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1204 X86_COND_BE, EFLAGS))]>,
1205 TB;
1206def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
1207 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1208 "cmova\t{$src2, $dst|$dst, $src2}",
1209 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1210 X86_COND_A, EFLAGS))]>,
1211 TB, OpSize;
1212def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
1213 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1214 "cmova\t{$src2, $dst|$dst, $src2}",
1215 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1216 X86_COND_A, EFLAGS))]>,
1217 TB;
1218def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
1219 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1220 "cmovl\t{$src2, $dst|$dst, $src2}",
1221 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1222 X86_COND_L, EFLAGS))]>,
1223 TB, OpSize;
1224def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
1225 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1226 "cmovl\t{$src2, $dst|$dst, $src2}",
1227 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1228 X86_COND_L, EFLAGS))]>,
1229 TB;
1230def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1231 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1232 "cmovge\t{$src2, $dst|$dst, $src2}",
1233 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1234 X86_COND_GE, EFLAGS))]>,
1235 TB, OpSize;
1236def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1237 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1238 "cmovge\t{$src2, $dst|$dst, $src2}",
1239 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1240 X86_COND_GE, EFLAGS))]>,
1241 TB;
1242def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1243 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1244 "cmovle\t{$src2, $dst|$dst, $src2}",
1245 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1246 X86_COND_LE, EFLAGS))]>,
1247 TB, OpSize;
1248def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1249 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1250 "cmovle\t{$src2, $dst|$dst, $src2}",
1251 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1252 X86_COND_LE, EFLAGS))]>,
1253 TB;
1254def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1255 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1256 "cmovg\t{$src2, $dst|$dst, $src2}",
1257 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1258 X86_COND_G, EFLAGS))]>,
1259 TB, OpSize;
1260def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1261 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1262 "cmovg\t{$src2, $dst|$dst, $src2}",
1263 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1264 X86_COND_G, EFLAGS))]>,
1265 TB;
1266def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1267 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1268 "cmovs\t{$src2, $dst|$dst, $src2}",
1269 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1270 X86_COND_S, EFLAGS))]>,
1271 TB, OpSize;
1272def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1273 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1274 "cmovs\t{$src2, $dst|$dst, $src2}",
1275 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1276 X86_COND_S, EFLAGS))]>,
1277 TB;
1278def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1279 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1280 "cmovns\t{$src2, $dst|$dst, $src2}",
1281 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1282 X86_COND_NS, EFLAGS))]>,
1283 TB, OpSize;
1284def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1285 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1286 "cmovns\t{$src2, $dst|$dst, $src2}",
1287 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1288 X86_COND_NS, EFLAGS))]>,
1289 TB;
1290def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1291 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1292 "cmovp\t{$src2, $dst|$dst, $src2}",
1293 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1294 X86_COND_P, EFLAGS))]>,
1295 TB, OpSize;
1296def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1297 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1298 "cmovp\t{$src2, $dst|$dst, $src2}",
1299 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1300 X86_COND_P, EFLAGS))]>,
1301 TB;
1302def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1303 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1304 "cmovnp\t{$src2, $dst|$dst, $src2}",
1305 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1306 X86_COND_NP, EFLAGS))]>,
1307 TB, OpSize;
Dan Gohman12fd4d72009-01-07 00:35:10 +00001308def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
1309 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1310 "cmovnp\t{$src2, $dst|$dst, $src2}",
1311 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1312 X86_COND_NP, EFLAGS))]>,
1313 TB;
1314def CMOVO16rm : I<0x40, MRMSrcMem, // if overflow, GR16 = [mem16]
1315 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1316 "cmovo\t{$src2, $dst|$dst, $src2}",
1317 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1318 X86_COND_O, EFLAGS))]>,
1319 TB, OpSize;
1320def CMOVO32rm : I<0x40, MRMSrcMem, // if overflow, GR32 = [mem32]
1321 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1322 "cmovo\t{$src2, $dst|$dst, $src2}",
1323 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1324 X86_COND_O, EFLAGS))]>,
1325 TB;
1326def CMOVNO16rm : I<0x41, MRMSrcMem, // if !overflow, GR16 = [mem16]
1327 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1328 "cmovno\t{$src2, $dst|$dst, $src2}",
1329 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1330 X86_COND_NO, EFLAGS))]>,
1331 TB, OpSize;
1332def CMOVNO32rm : I<0x41, MRMSrcMem, // if !overflow, GR32 = [mem32]
1333 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1334 "cmovno\t{$src2, $dst|$dst, $src2}",
1335 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1336 X86_COND_NO, EFLAGS))]>,
1337 TB;
Evan Cheng950aac02007-09-25 01:57:46 +00001338} // Uses = [EFLAGS]
1339
1340
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341// unary instructions
1342let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001343let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001344def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001345 [(set GR8:$dst, (ineg GR8:$src)),
1346 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001347def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001348 [(set GR16:$dst, (ineg GR16:$src)),
1349 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001350def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001351 [(set GR32:$dst, (ineg GR32:$src)),
1352 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001353let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001354 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001355 [(store (ineg (loadi8 addr:$dst)), addr:$dst),
1356 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001357 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001358 [(store (ineg (loadi16 addr:$dst)), addr:$dst),
1359 (implicit EFLAGS)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001360 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001361 [(store (ineg (loadi32 addr:$dst)), addr:$dst),
1362 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363}
Evan Cheng55687072007-09-14 21:48:26 +00001364} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365
Evan Chengc6cee682009-01-21 02:09:05 +00001366// Match xor -1 to not. Favors these over a move imm + xor to save code size.
1367let AddedComplexity = 15 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001368def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001370def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001372def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373 [(set GR32:$dst, (not GR32:$src))]>;
Evan Chengc6cee682009-01-21 02:09:05 +00001374}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001375let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001376 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001378 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001379 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001380 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1382}
1383} // CodeSize
1384
1385// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001386let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001387let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001388def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001389 [(set GR8:$dst, (add GR8:$src, 1)),
1390 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001391let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001392def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001393 [(set GR16:$dst, (add GR16:$src, 1)),
1394 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001396def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001397 [(set GR32:$dst, (add GR32:$src, 1)),
1398 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399}
1400let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001401 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001402 [(store (add (loadi8 addr:$dst), 1), addr:$dst),
1403 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001404 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001405 [(store (add (loadi16 addr:$dst), 1), addr:$dst),
1406 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001407 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001408 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001409 [(store (add (loadi32 addr:$dst), 1), addr:$dst),
1410 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001411 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412}
1413
1414let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001415def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001416 [(set GR8:$dst, (add GR8:$src, -1)),
1417 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001419def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001420 [(set GR16:$dst, (add GR16:$src, -1)),
1421 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001423def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001424 [(set GR32:$dst, (add GR32:$src, -1)),
1425 (implicit EFLAGS)]>, Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426}
1427
1428let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001429 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001430 [(store (add (loadi8 addr:$dst), -1), addr:$dst),
1431 (implicit EFLAGS)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001432 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001433 [(store (add (loadi16 addr:$dst), -1), addr:$dst),
1434 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001435 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001436 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001437 [(store (add (loadi32 addr:$dst), -1), addr:$dst),
1438 (implicit EFLAGS)]>,
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001439 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440}
Evan Cheng55687072007-09-14 21:48:26 +00001441} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442
1443// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001444let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001445let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1446def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001447 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001448 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001449 [(set GR8:$dst, (and GR8:$src1, GR8:$src2)),
1450 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001452 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001453 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001454 [(set GR16:$dst, (and GR16:$src1, GR16:$src2)),
1455 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001456def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001457 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001459 [(set GR32:$dst, (and GR32:$src1, GR32:$src2)),
1460 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001461}
1462
1463def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001464 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001465 "and{b}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001466 [(set GR8:$dst, (and GR8:$src1, (loadi8 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001467 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001468def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001469 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001470 "and{w}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001471 [(set GR16:$dst, (and GR16:$src1, (loadi16 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001472 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001474 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001475 "and{l}\t{$src2, $dst|$dst, $src2}",
Chris Lattner12208612009-04-10 00:16:23 +00001476 [(set GR32:$dst, (and GR32:$src1, (loadi32 addr:$src2))),
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001477 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001478
1479def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001480 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001482 [(set GR8:$dst, (and GR8:$src1, imm:$src2)),
1483 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001484def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001485 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001487 [(set GR16:$dst, (and GR16:$src1, imm:$src2)),
1488 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001490 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001491 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001492 [(set GR32:$dst, (and GR32:$src1, imm:$src2)),
1493 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001495 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001496 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001497 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2)),
1498 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001499 OpSize;
1500def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001501 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001502 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001503 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2)),
1504 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505
1506let isTwoAddress = 0 in {
1507 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001508 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001509 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001510 [(store (and (load addr:$dst), GR8:$src), addr:$dst),
1511 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001512 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001513 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001515 [(store (and (load addr:$dst), GR16:$src), addr:$dst),
1516 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517 OpSize;
1518 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001519 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001520 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001521 [(store (and (load addr:$dst), GR32:$src), addr:$dst),
1522 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001523 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001524 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001525 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001526 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst),
1527 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001529 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001530 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001531 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst),
1532 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533 OpSize;
1534 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001535 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001537 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst),
1538 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001539 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001540 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001542 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst),
1543 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001544 OpSize;
1545 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001546 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001548 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst),
1549 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001550}
1551
1552
1553let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001554def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001555 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001556 [(set GR8:$dst, (or GR8:$src1, GR8:$src2)),
1557 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001558def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001560 [(set GR16:$dst, (or GR16:$src1, GR16:$src2)),
1561 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001562def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001563 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001564 [(set GR32:$dst, (or GR32:$src1, GR32:$src2)),
1565 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001566}
Evan Chengb783fa32007-07-19 01:14:50 +00001567def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001568 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001569 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2))),
1570 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001571def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001572 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001573 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2))),
1574 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001575def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001576 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001577 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2))),
1578 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001579
Evan Chengb783fa32007-07-19 01:14:50 +00001580def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001581 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001582 [(set GR8:$dst, (or GR8:$src1, imm:$src2)),
1583 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001584def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001585 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001586 [(set GR16:$dst, (or GR16:$src1, imm:$src2)),
1587 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001588def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001589 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001590 [(set GR32:$dst, (or GR32:$src1, imm:$src2)),
1591 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001592
Evan Chengb783fa32007-07-19 01:14:50 +00001593def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001594 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001595 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2)),
1596 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001597def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001598 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001599 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2)),
1600 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001602 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001603 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001604 [(store (or (load addr:$dst), GR8:$src), addr:$dst),
1605 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001606 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001607 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001608 [(store (or (load addr:$dst), GR16:$src), addr:$dst),
1609 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001610 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001611 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001612 [(store (or (load addr:$dst), GR32:$src), addr:$dst),
1613 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001614 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001615 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001616 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst),
1617 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001618 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001619 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001620 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst),
1621 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001622 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001623 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001624 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001625 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst),
1626 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001627 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001629 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst),
1630 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001632 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001633 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001634 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst),
1635 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001636} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001637
1638
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001639let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001640 def XOR8rr : I<0x30, MRMDestReg,
1641 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1642 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001643 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2)),
1644 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001645 def XOR16rr : I<0x31, MRMDestReg,
1646 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1647 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001648 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2)),
1649 (implicit EFLAGS)]>, OpSize;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001650 def XOR32rr : I<0x31, MRMDestReg,
1651 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1652 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001653 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2)),
1654 (implicit EFLAGS)]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001655} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656
1657def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001658 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001659 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001660 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2))),
1661 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001662def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001663 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001665 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2))),
1666 (implicit EFLAGS)]>,
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001667 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001668def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001669 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001670 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001671 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2))),
1672 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001673
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001674def XOR8ri : Ii8<0x80, MRM6r,
1675 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1676 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001677 [(set GR8:$dst, (xor GR8:$src1, imm:$src2)),
1678 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001679def XOR16ri : Ii16<0x81, MRM6r,
1680 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1681 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001682 [(set GR16:$dst, (xor GR16:$src1, imm:$src2)),
1683 (implicit EFLAGS)]>, OpSize;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001684def XOR32ri : Ii32<0x81, MRM6r,
1685 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1686 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001687 [(set GR32:$dst, (xor GR32:$src1, imm:$src2)),
1688 (implicit EFLAGS)]>;
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001689def XOR16ri8 : Ii8<0x83, MRM6r,
1690 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1691 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001692 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2)),
1693 (implicit EFLAGS)]>,
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001694 OpSize;
1695def XOR32ri8 : Ii8<0x83, MRM6r,
1696 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1697 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001698 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2)),
1699 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001700
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701let isTwoAddress = 0 in {
1702 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001703 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001704 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001705 [(store (xor (load addr:$dst), GR8:$src), addr:$dst),
1706 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001708 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001709 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001710 [(store (xor (load addr:$dst), GR16:$src), addr:$dst),
1711 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001712 OpSize;
1713 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001714 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001715 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001716 [(store (xor (load addr:$dst), GR32:$src), addr:$dst),
1717 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001718 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001719 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001721 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst),
1722 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001723 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001724 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001725 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001726 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst),
1727 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001728 OpSize;
1729 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001730 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001731 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001732 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst),
1733 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001734 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001735 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001737 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst),
1738 (implicit EFLAGS)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001739 OpSize;
1740 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001741 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001742 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohman7b93f1c2009-03-03 19:53:46 +00001743 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst),
1744 (implicit EFLAGS)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001745} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001746} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747
1748// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001749let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001750let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001751def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001752 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001753 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001754def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001755 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001756 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001757def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001758 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001759 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001760} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001761
Evan Chengb783fa32007-07-19 01:14:50 +00001762def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001763 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001764 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1765let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001766def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001767 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001768 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001769def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001770 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001771 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001772// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1773// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001774} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775
1776let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001777 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001778 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001779 "shl{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001780 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001781 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001782 "shl{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001783 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001784 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001785 "shl{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001786 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1787 }
Evan Chengb783fa32007-07-19 01:14:50 +00001788 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001789 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001791 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1794 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001795 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001796 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001797 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1798
1799 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001800 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001801 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001803 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001805 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1806 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001807 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001808 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001809 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1810}
1811
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001812let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001813def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001814 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001815 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001816def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001817 "shr{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001818 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001819def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001820 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001821 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1822}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823
Evan Chengb783fa32007-07-19 01:14:50 +00001824def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001827def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001830def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1833
1834// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001835def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001838def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001839 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001841def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001842 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001843 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1844
1845let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001846 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001847 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001848 "shr{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001849 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001850 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001851 "shr{w}\t{%cl, $dst|$dst, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001852 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001853 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001854 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001855 "shr{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001856 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1857 }
Evan Chengb783fa32007-07-19 01:14:50 +00001858 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001861 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001862 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001863 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1864 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001865 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001866 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001867 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1868
1869 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001870 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001873 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001874 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001875 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001876 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001877 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001878 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1879}
1880
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001881let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001882def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001883 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001884 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001885def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001886 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001887 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001888def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001889 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001890 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1891}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001892
Evan Chengb783fa32007-07-19 01:14:50 +00001893def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001896def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001897 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1899 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001900def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1903
1904// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001905def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001908def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001909 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001910 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001911def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1914
1915let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001916 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001917 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001918 "sar{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001919 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001920 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001921 "sar{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001922 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001923 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001924 "sar{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001925 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1926 }
Evan Chengb783fa32007-07-19 01:14:50 +00001927 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001930 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001931 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1933 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001934 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001935 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001936 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1937
1938 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001939 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001941 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001942 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001943 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001944 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1945 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001946 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001947 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001948 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1949}
1950
1951// Rotate instructions
1952// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001953let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001954def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001955 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001956 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001957def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001958 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001959 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001960def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00001961 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001962 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1963}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964
Evan Chengb783fa32007-07-19 01:14:50 +00001965def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001968def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001969 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001971def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001972 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1974
1975// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001976def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001977 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001978 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001979def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001980 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001981 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001982def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1985
1986let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001987 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001988 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001989 "rol{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001990 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001991 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001992 "rol{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001993 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001994 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00001995 "rol{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001996 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1997 }
Evan Chengb783fa32007-07-19 01:14:50 +00001998 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001999 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002000 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002001 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002002 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002003 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2004 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002005 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002006 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002007 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2008
2009 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002010 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002011 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002012 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002013 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2016 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002017 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002018 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2020}
2021
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002022let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002023def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002024 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002025 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002026def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002027 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002028 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002029def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Eli Friedman378ea832009-06-19 04:48:38 +00002030 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002031 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
2032}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002033
Evan Chengb783fa32007-07-19 01:14:50 +00002034def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002035 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002037def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002040def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002041 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002042 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
2043
2044// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002045def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002048def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002049 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002051def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
2054
2055let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002056 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002057 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002058 "ror{b}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002059 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002060 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002061 "ror{w}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002062 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002063 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Eli Friedman378ea832009-06-19 04:48:38 +00002064 "ror{l}\t{%cl, $dst|$dst, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002065 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
2066 }
Evan Chengb783fa32007-07-19 01:14:50 +00002067 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002068 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002069 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002070 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002071 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
2073 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002074 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002075 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002076 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
2077
2078 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00002079 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002082 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002083 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002084 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
2085 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002086 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002087 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
2089}
2090
2091
2092
2093// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002094let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002095def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002096 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002097 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002098def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002099 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002100 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002101def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002102 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002104 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002105def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002106 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002108 TB, OpSize;
2109}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002110
2111let isCommutable = 1 in { // These instructions commute to each other.
2112def SHLD32rri8 : Ii8<0xA4, 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 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002115 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
2116 (i8 imm:$src3)))]>,
2117 TB;
2118def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002119 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002120 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
2122 (i8 imm:$src3)))]>,
2123 TB;
2124def SHLD16rri8 : Ii8<0xA4, 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 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002127 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
2128 (i8 imm:$src3)))]>,
2129 TB, OpSize;
2130def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002131 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002132 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
2134 (i8 imm:$src3)))]>,
2135 TB, OpSize;
2136}
2137
2138let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002139 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002140 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002141 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002142 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002143 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002144 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002145 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002146 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002147 addr:$dst)]>, TB;
2148 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002149 def SHLD32mri8 : Ii8<0xA4, 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 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
2153 (i8 imm:$src3)), addr:$dst)]>,
2154 TB;
2155 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002156 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
2159 (i8 imm:$src3)), addr:$dst)]>,
2160 TB;
2161
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002162 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002163 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002164 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002165 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002166 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002167 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Eli Friedman378ea832009-06-19 04:48:38 +00002168 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002169 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002170 addr:$dst)]>, TB, OpSize;
2171 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002172 def SHLD16mri8 : Ii8<0xA4, 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 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002175 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
2176 (i8 imm:$src3)), addr:$dst)]>,
2177 TB, OpSize;
2178 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002179 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00002180 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002181 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
2182 (i8 imm:$src3)), addr:$dst)]>,
2183 TB, OpSize;
2184}
Evan Cheng55687072007-09-14 21:48:26 +00002185} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186
2187
2188// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00002189let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002190let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Bill Wendlingae034ed2008-12-12 00:56:36 +00002191// Register-Register Addition
2192def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
2193 (ins GR8 :$src1, GR8 :$src2),
2194 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002195 [(set GR8:$dst, (add GR8:$src1, GR8:$src2)),
Bill Wendlingae034ed2008-12-12 00:56:36 +00002196 (implicit EFLAGS)]>;
2197
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002198let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002199// Register-Register Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002200def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
2201 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002202 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002203 [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
2204 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002205def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
2206 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002207 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002208 [(set GR32:$dst, (add GR32:$src1, GR32:$src2)),
2209 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002210} // end isConvertibleToThreeAddress
2211} // end isCommutable
Bill Wendlingae034ed2008-12-12 00:56:36 +00002212
2213// Register-Memory Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002214def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
2215 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002216 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002217 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2))),
2218 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002219def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
2220 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002221 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002222 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2))),
2223 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002224def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
2225 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002226 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002227 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2))),
2228 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002229
Bill Wendlingae034ed2008-12-12 00:56:36 +00002230// Register-Integer Addition
2231def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2232 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002233 [(set GR8:$dst, (add GR8:$src1, imm:$src2)),
2234 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002235
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002236let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Bill Wendlingae034ed2008-12-12 00:56:36 +00002237// Register-Integer Addition
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002238def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
2239 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002241 [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
2242 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002243def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
2244 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002245 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002246 [(set GR32:$dst, (add GR32:$src1, imm:$src2)),
2247 (implicit EFLAGS)]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002248def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
2249 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002250 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002251 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2)),
2252 (implicit EFLAGS)]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002253def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
2254 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002255 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002256 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2)),
2257 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002258}
2259
2260let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002261 // Memory-Register Addition
Bill Wendlingf5399032008-12-12 21:15:41 +00002262 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002263 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002264 [(store (add (load addr:$dst), GR8:$src2), addr:$dst),
2265 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002266 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002267 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002268 [(store (add (load addr:$dst), GR16:$src2), addr:$dst),
2269 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002270 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002271 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002272 [(store (add (load addr:$dst), GR32:$src2), addr:$dst),
2273 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002274 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002275 "add{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002276 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst),
2277 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002278 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002279 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002280 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst),
2281 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002282 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002283 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002284 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst),
2285 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002286 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002287 "add{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002288 [(store (add (load addr:$dst), i16immSExt8:$src2),
2289 addr:$dst),
2290 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002291 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002292 "add{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002293 [(store (add (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002294 addr:$dst),
2295 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002296}
2297
Evan Cheng259471d2007-10-05 17:59:57 +00002298let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002299let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Dale Johannesen747fe522009-06-02 03:12:52 +00002300def ADC8rr : I<0x10, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002301 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002302 [(set GR8:$dst, (adde GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002303def ADC16rr : I<0x11, MRMDestReg, (outs GR16:$dst),
2304 (ins GR16:$src1, GR16:$src2),
2305 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002306 [(set GR16:$dst, (adde GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002307def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst),
2308 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002309 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002310 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002311}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002312def ADC8rm : I<0x12, MRMSrcMem , (outs GR8:$dst),
2313 (ins GR8:$src1, i8mem:$src2),
2314 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002315 [(set GR8:$dst, (adde GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002316def ADC16rm : I<0x13, MRMSrcMem , (outs GR16:$dst),
2317 (ins GR16:$src1, i16mem:$src2),
2318 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002319 [(set GR16:$dst, (adde GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002320 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002321def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst),
2322 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002323 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002324 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
2325def ADC8ri : Ii8<0x80, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002326 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002327 [(set GR8:$dst, (adde GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002328def ADC16ri : Ii16<0x81, MRM2r, (outs GR16:$dst),
2329 (ins GR16:$src1, i16imm:$src2),
2330 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002331 [(set GR16:$dst, (adde GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002332def ADC16ri8 : Ii8<0x83, MRM2r, (outs GR16:$dst),
2333 (ins GR16:$src1, i16i8imm:$src2),
2334 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002335 [(set GR16:$dst, (adde GR16:$src1, i16immSExt8:$src2))]>,
2336 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002337def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst),
2338 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002340 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002341def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst),
2342 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002343 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002344 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002345
2346let isTwoAddress = 0 in {
Dale Johannesen747fe522009-06-02 03:12:52 +00002347 def ADC8mr : I<0x10, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002348 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002349 [(store (adde (load addr:$dst), GR8:$src2), addr:$dst)]>;
2350 def ADC16mr : I<0x11, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002351 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002352 [(store (adde (load addr:$dst), GR16:$src2), addr:$dst)]>,
2353 OpSize;
2354 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002355 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002356 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
2357 def ADC8mi : Ii8<0x80, MRM2m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002358 "adc{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002359 [(store (adde (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
2360 def ADC16mi : Ii16<0x81, MRM2m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002361 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002362 [(store (adde (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
2363 OpSize;
2364 def ADC16mi8 : Ii8<0x83, MRM2m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dale Johannesen06b83f12009-05-18 17:44:15 +00002365 "adc{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002366 [(store (adde (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
2367 OpSize;
2368 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002369 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002370 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
2371 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002372 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002373 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2374}
Evan Cheng259471d2007-10-05 17:59:57 +00002375} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002376
Bill Wendlingae034ed2008-12-12 00:56:36 +00002377// Register-Register Subtraction
2378def SUB8rr : I<0x28, MRMDestReg, (outs GR8:$dst), (ins GR8:$src1, GR8:$src2),
2379 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002380 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2)),
2381 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002382def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
2383 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002384 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2)),
2385 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002386def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
2387 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002388 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2)),
2389 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002390
2391// Register-Memory Subtraction
2392def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst),
2393 (ins GR8 :$src1, i8mem :$src2),
2394 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002395 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2))),
2396 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002397def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst),
2398 (ins GR16:$src1, i16mem:$src2),
2399 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002400 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2))),
2401 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002402def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst),
2403 (ins GR32:$src1, i32mem:$src2),
2404 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002405 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2))),
2406 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002407
2408// Register-Integer Subtraction
2409def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst),
2410 (ins GR8:$src1, i8imm:$src2),
2411 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002412 [(set GR8:$dst, (sub GR8:$src1, imm:$src2)),
2413 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002414def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst),
2415 (ins GR16:$src1, i16imm:$src2),
2416 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002417 [(set GR16:$dst, (sub GR16:$src1, imm:$src2)),
2418 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002419def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst),
2420 (ins GR32:$src1, i32imm:$src2),
2421 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002422 [(set GR32:$dst, (sub GR32:$src1, imm:$src2)),
2423 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002424def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst),
2425 (ins GR16:$src1, i16i8imm:$src2),
2426 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002427 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2)),
2428 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002429def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst),
2430 (ins GR32:$src1, i32i8imm:$src2),
2431 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002432 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2)),
2433 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002434
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002435let isTwoAddress = 0 in {
Bill Wendlingae034ed2008-12-12 00:56:36 +00002436 // Memory-Register Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002437 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002438 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002439 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst),
2440 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002441 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002442 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002443 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst),
2444 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002445 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002446 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002447 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst),
2448 (implicit EFLAGS)]>;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002449
2450 // Memory-Integer Subtraction
Evan Chengb783fa32007-07-19 01:14:50 +00002451 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002452 "sub{b}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002453 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst),
2454 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002455 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002456 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002457 [(store (sub (loadi16 addr:$dst), imm:$src2),addr:$dst),
2458 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002459 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002460 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002461 [(store (sub (loadi32 addr:$dst), imm:$src2),addr:$dst),
2462 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002463 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002464 "sub{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002465 [(store (sub (load addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002466 addr:$dst),
2467 (implicit EFLAGS)]>, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002468 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002469 "sub{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002470 [(store (sub (load addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00002471 addr:$dst),
2472 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002473}
2474
Evan Cheng259471d2007-10-05 17:59:57 +00002475let Uses = [EFLAGS] in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002476def SBB8rr : I<0x18, MRMDestReg, (outs GR8:$dst),
2477 (ins GR8:$src1, GR8:$src2),
2478 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002479 [(set GR8:$dst, (sube GR8:$src1, GR8:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002480def SBB16rr : I<0x19, MRMDestReg, (outs GR16:$dst),
2481 (ins GR16:$src1, GR16:$src2),
2482 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002483 [(set GR16:$dst, (sube GR16:$src1, GR16:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002484def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst),
2485 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002486 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002487 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002488
2489let isTwoAddress = 0 in {
Dale Johannesen06b83f12009-05-18 17:44:15 +00002490 def SBB8mr : I<0x18, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2),
2491 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002492 [(store (sube (load addr:$dst), GR8:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002493 def SBB16mr : I<0x19, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
2494 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002495 [(store (sube (load addr:$dst), GR16:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002496 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002497 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002498 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002499 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002500 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002501 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002502 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002503 def SBB16mi : Ii16<0x81, MRM3m, (outs), (ins i16mem:$dst, i16imm:$src2),
2504 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002505 [(store (sube (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002506 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002507 def SBB16mi8 : Ii8<0x83, MRM3m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
2508 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002509 [(store (sube (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002510 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002511 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002512 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002513 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002514 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002515 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002516 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002517}
Dale Johannesen06b83f12009-05-18 17:44:15 +00002518def SBB8rm : I<0x1A, MRMSrcMem, (outs GR8:$dst), (ins GR8:$src1, i8mem:$src2),
2519 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002520 [(set GR8:$dst, (sube GR8:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002521def SBB16rm : I<0x1B, MRMSrcMem, (outs GR16:$dst),
2522 (ins GR16:$src1, i16mem:$src2),
2523 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002524 [(set GR16:$dst, (sube GR16:$src1, (load addr:$src2)))]>,
Dale Johannesen067cfb22009-05-18 21:41:59 +00002525 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002526def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst),
2527 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002528 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002529 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002530def SBB8ri : Ii8<0x80, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
2531 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002532 [(set GR8:$dst, (sube GR8:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002533def SBB16ri : Ii16<0x81, MRM3r, (outs GR16:$dst),
2534 (ins GR16:$src1, i16imm:$src2),
2535 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002536 [(set GR16:$dst, (sube GR16:$src1, imm:$src2))]>, OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002537def SBB16ri8 : Ii8<0x83, MRM3r, (outs GR16:$dst),
2538 (ins GR16:$src1, i16i8imm:$src2),
2539 "sbb{w}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002540 [(set GR16:$dst, (sube GR16:$src1, i16immSExt8:$src2))]>,
2541 OpSize;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002542def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst),
2543 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002544 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002545 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00002546def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst),
2547 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002548 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dale Johannesen747fe522009-06-02 03:12:52 +00002549 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002550} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002551} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002552
Evan Cheng55687072007-09-14 21:48:26 +00002553let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Bill Wendlingf5399032008-12-12 21:15:41 +00002555// Register-Register Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002556def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1,GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002557 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002558 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2)),
2559 (implicit EFLAGS)]>, TB, OpSize;
Bill Wendlingae034ed2008-12-12 00:56:36 +00002560def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1,GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002561 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002562 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2)),
2563 (implicit EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002564}
Bill Wendlingae034ed2008-12-12 00:56:36 +00002565
Bill Wendlingf5399032008-12-12 21:15:41 +00002566// Register-Memory Signed Integer Multiply
Bill Wendlingae034ed2008-12-12 00:56:36 +00002567def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst),
2568 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002569 "imul{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002570 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2))),
2571 (implicit EFLAGS)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002572def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002573 "imul{l}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002574 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2))),
2575 (implicit EFLAGS)]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002576} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002577} // end Two Address instructions
2578
2579// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002580let Defs = [EFLAGS] in {
Bill Wendlingf5399032008-12-12 21:15:41 +00002581// Register-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002582def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002583 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002584 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002585 [(set GR16:$dst, (mul GR16:$src1, imm:$src2)),
2586 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002587def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002588 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002589 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002590 [(set GR32:$dst, (mul GR32:$src1, imm:$src2)),
2591 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002592def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002593 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002594 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002595 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2)),
2596 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002597def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002598 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002599 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002600 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2)),
2601 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002602
Bill Wendlingf5399032008-12-12 21:15:41 +00002603// Memory-Integer Signed Integer Multiply
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002604def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002605 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002606 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002607 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2)),
2608 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002609def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002610 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002611 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingf5399032008-12-12 21:15:41 +00002612 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2)),
2613 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002614def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002615 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002616 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002617 [(set GR16:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002618 i16immSExt8:$src2)),
2619 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002620def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002621 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002622 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Bill Wendlingae034ed2008-12-12 00:56:36 +00002623 [(set GR32:$dst, (mul (load addr:$src1),
Bill Wendlingf5399032008-12-12 21:15:41 +00002624 i32immSExt8:$src2)),
2625 (implicit EFLAGS)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002626} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002627
2628//===----------------------------------------------------------------------===//
2629// Test instructions are just like AND, except they don't generate a result.
2630//
Evan Cheng950aac02007-09-25 01:57:46 +00002631let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002632let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002633def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002634 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002635 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002636 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002637def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002638 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002639 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002640 (implicit EFLAGS)]>,
2641 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002642def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002643 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002644 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002645 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002646}
2647
Evan Chengb783fa32007-07-19 01:14:50 +00002648def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002649 "test{b}\t{$src2, $src1|$src1, $src2}",
2650 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2651 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002652def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002653 "test{w}\t{$src2, $src1|$src1, $src2}",
2654 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2655 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002656def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002657 "test{l}\t{$src2, $src1|$src1, $src2}",
2658 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2659 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002660
2661def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002662 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002663 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002664 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002665 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002666def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002667 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002668 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002669 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002670 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002671def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002672 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002673 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002674 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002675 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002676
Evan Cheng621216e2007-09-29 00:00:36 +00002677def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002678 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002679 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002680 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2681 (implicit EFLAGS)]>;
2682def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002683 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002684 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002685 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2686 (implicit EFLAGS)]>, OpSize;
2687def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002688 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002689 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002690 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002691 (implicit EFLAGS)]>;
2692} // Defs = [EFLAGS]
2693
2694
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002695// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002696let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002697def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002698let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002699def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002700
Evan Cheng950aac02007-09-25 01:57:46 +00002701let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002702def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002703 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002704 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002705 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002706 TB; // GR8 = ==
2707def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002708 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002709 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002710 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002711 TB; // [mem8] = ==
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002712
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002713def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002714 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002715 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002716 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002717 TB; // GR8 = !=
2718def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002719 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002720 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002721 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002722 TB; // [mem8] = !=
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002723
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002724def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002725 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002726 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002727 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002728 TB; // GR8 = < signed
2729def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002730 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002731 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002732 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002733 TB; // [mem8] = < signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002734
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002735def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002736 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002737 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002738 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002739 TB; // GR8 = >= signed
2740def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002741 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002742 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002743 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002744 TB; // [mem8] = >= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002745
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002746def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002747 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002748 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002749 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002750 TB; // GR8 = <= signed
2751def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002752 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002753 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002754 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002755 TB; // [mem8] = <= signed
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002756
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002757def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002758 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002759 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002760 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002761 TB; // GR8 = > signed
2762def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002763 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002764 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002765 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002766 TB; // [mem8] = > signed
2767
2768def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002769 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002770 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002771 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002772 TB; // GR8 = < unsign
2773def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002774 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002775 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002776 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002777 TB; // [mem8] = < unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002778
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002779def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002780 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002781 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002782 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002783 TB; // GR8 = >= unsign
2784def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002785 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002786 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002787 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002788 TB; // [mem8] = >= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002789
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002790def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002791 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002792 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002793 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002794 TB; // GR8 = <= unsign
2795def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002796 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002797 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002798 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002799 TB; // [mem8] = <= unsign
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002800
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002801def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002802 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002803 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002804 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002805 TB; // GR8 = > signed
2806def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002807 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002808 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002809 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002810 TB; // [mem8] = > signed
2811
2812def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002813 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002814 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002815 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002816 TB; // GR8 = <sign bit>
2817def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002818 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002819 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002820 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002821 TB; // [mem8] = <sign bit>
2822def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002823 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002824 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002825 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002826 TB; // GR8 = !<sign bit>
2827def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002828 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002829 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002830 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002831 TB; // [mem8] = !<sign bit>
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002832
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002833def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002834 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002835 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002836 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002837 TB; // GR8 = parity
2838def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002839 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002840 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002841 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002842 TB; // [mem8] = parity
2843def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002844 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002845 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002846 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002847 TB; // GR8 = not parity
2848def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002849 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002850 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002851 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002852 TB; // [mem8] = not parity
Bill Wendling0c52d0a2008-12-02 00:07:05 +00002853
2854def SETOr : I<0x90, MRM0r,
2855 (outs GR8 :$dst), (ins),
2856 "seto\t$dst",
2857 [(set GR8:$dst, (X86setcc X86_COND_O, EFLAGS))]>,
2858 TB; // GR8 = overflow
2859def SETOm : I<0x90, MRM0m,
2860 (outs), (ins i8mem:$dst),
2861 "seto\t$dst",
2862 [(store (X86setcc X86_COND_O, EFLAGS), addr:$dst)]>,
2863 TB; // [mem8] = overflow
2864def SETNOr : I<0x91, MRM0r,
2865 (outs GR8 :$dst), (ins),
2866 "setno\t$dst",
2867 [(set GR8:$dst, (X86setcc X86_COND_NO, EFLAGS))]>,
2868 TB; // GR8 = not overflow
2869def SETNOm : I<0x91, MRM0m,
2870 (outs), (ins i8mem:$dst),
2871 "setno\t$dst",
2872 [(store (X86setcc X86_COND_NO, EFLAGS), addr:$dst)]>,
2873 TB; // [mem8] = not overflow
Evan Cheng950aac02007-09-25 01:57:46 +00002874} // Uses = [EFLAGS]
2875
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002876
2877// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002878let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002879def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002880 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002881 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002882 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002883def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002884 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002885 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002886 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002887def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002888 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002889 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002890 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002891def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002892 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002893 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002894 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2895 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002896def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002897 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002898 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002899 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2900 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002901def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002902 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002903 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002904 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2905 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002906def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002907 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002908 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002909 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2910 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002911def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002912 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002913 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002914 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2915 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002916def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002917 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002918 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002919 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2920 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002921def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002922 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002923 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002924 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002925def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002926 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002927 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002928 [(X86cmp GR16:$src1, imm:$src2),
2929 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002930def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002931 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002932 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002933 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002934def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002935 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002936 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002937 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2938 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002939def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002940 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002941 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002942 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2943 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002944def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002945 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002946 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002947 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2948 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002949def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002950 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002951 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002952 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2953 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002954def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002955 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002956 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002957 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2958 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002959def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002960 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002961 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002962 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2963 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002964def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002965 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002966 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002967 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002968 (implicit EFLAGS)]>;
2969} // Defs = [EFLAGS]
2970
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002971// Bit tests.
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002972// TODO: BTC, BTR, and BTS
2973let Defs = [EFLAGS] in {
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002974def BT16rr : I<0xA3, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002975 "bt{w}\t{$src2, $src1|$src1, $src2}",
2976 [(X86bt GR16:$src1, GR16:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002977 (implicit EFLAGS)]>, OpSize, TB;
Dan Gohmanfc4eddb2009-01-13 20:32:45 +00002978def BT32rr : I<0xA3, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00002979 "bt{l}\t{$src2, $src1|$src1, $src2}",
2980 [(X86bt GR32:$src1, GR32:$src2),
Chris Lattner5a95cde2008-12-25 01:32:49 +00002981 (implicit EFLAGS)]>, TB;
Dan Gohman85a228c2009-01-13 23:23:30 +00002982
2983// Unlike with the register+register form, the memory+register form of the
2984// bt instruction does not ignore the high bits of the index. From ISel's
2985// perspective, this is pretty bizarre. Disable these instructions for now.
2986//def BT16mr : I<0xA3, MRMDestMem, (outs), (ins i16mem:$src1, GR16:$src2),
2987// "bt{w}\t{$src2, $src1|$src1, $src2}",
2988// [(X86bt (loadi16 addr:$src1), GR16:$src2),
2989// (implicit EFLAGS)]>, OpSize, TB, Requires<[FastBTMem]>;
2990//def BT32mr : I<0xA3, MRMDestMem, (outs), (ins i32mem:$src1, GR32:$src2),
2991// "bt{l}\t{$src2, $src1|$src1, $src2}",
2992// [(X86bt (loadi32 addr:$src1), GR32:$src2),
2993// (implicit EFLAGS)]>, TB, Requires<[FastBTMem]>;
Dan Gohman46fb1cf2009-01-13 20:33:23 +00002994
2995def BT16ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR16:$src1, i16i8imm:$src2),
2996 "bt{w}\t{$src2, $src1|$src1, $src2}",
2997 [(X86bt GR16:$src1, i16immSExt8:$src2),
2998 (implicit EFLAGS)]>, OpSize, TB;
2999def BT32ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR32:$src1, i32i8imm:$src2),
3000 "bt{l}\t{$src2, $src1|$src1, $src2}",
3001 [(X86bt GR32:$src1, i32immSExt8:$src2),
3002 (implicit EFLAGS)]>, TB;
3003// Note that these instructions don't need FastBTMem because that
3004// only applies when the other operand is in a register. When it's
3005// an immediate, bt is still fast.
3006def BT16mi8 : Ii8<0xBA, MRM4m, (outs), (ins i16mem:$src1, i16i8imm:$src2),
3007 "bt{w}\t{$src2, $src1|$src1, $src2}",
3008 [(X86bt (loadi16 addr:$src1), i16immSExt8:$src2),
3009 (implicit EFLAGS)]>, OpSize, TB;
3010def BT32mi8 : Ii8<0xBA, MRM4m, (outs), (ins i32mem:$src1, i32i8imm:$src2),
3011 "bt{l}\t{$src2, $src1|$src1, $src2}",
3012 [(X86bt (loadi32 addr:$src1), i32immSExt8:$src2),
3013 (implicit EFLAGS)]>, TB;
Dan Gohman7fe9b7f2008-12-23 22:45:23 +00003014} // Defs = [EFLAGS]
3015
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003016// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00003017// Use movsbl intead of movsbw; we don't care about the high 16 bits
3018// of the register here. This has a smaller encoding and avoids a
3019// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003020def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003021 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3022 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003023def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003024 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3025 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003026def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003027 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003028 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003029def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003030 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003031 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003032def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003033 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003034 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003035def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003036 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003037 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
3038
Dan Gohman9203ab42008-07-30 18:09:17 +00003039// Use movzbl intead of movzbw; we don't care about the high 16 bits
3040// of the register here. This has a smaller encoding and avoids a
3041// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003042def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003043 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3044 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003045def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00003046 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
3047 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003048def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003049 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003050 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003051def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003052 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003053 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003054def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003055 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003056 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00003057def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00003058 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003059 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
3060
Dan Gohman744d4622009-04-13 16:09:41 +00003061// These are the same as the regular regular MOVZX32rr8 and MOVZX32rm8
3062// except that they use GR32_NOREX for the output operand register class
3063// instead of GR32. This allows them to operate on h registers on x86-64.
3064def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg,
3065 (outs GR32_NOREX:$dst), (ins GR8:$src),
3066 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3067 []>, TB;
Dan Gohman89f4cda2009-04-30 03:11:48 +00003068let mayLoad = 1 in
Dan Gohman744d4622009-04-13 16:09:41 +00003069def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem,
3070 (outs GR32_NOREX:$dst), (ins i8mem:$src),
3071 "movz{bl|x}\t{$src, $dst|$dst, $src} # NOREX",
3072 []>, TB;
3073
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003074let neverHasSideEffects = 1 in {
3075 let Defs = [AX], Uses = [AL] in
3076 def CBW : I<0x98, RawFrm, (outs), (ins),
3077 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
3078 let Defs = [EAX], Uses = [AX] in
3079 def CWDE : I<0x98, RawFrm, (outs), (ins),
3080 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003081
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00003082 let Defs = [AX,DX], Uses = [AX] in
3083 def CWD : I<0x99, RawFrm, (outs), (ins),
3084 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
3085 let Defs = [EAX,EDX], Uses = [EAX] in
3086 def CDQ : I<0x99, RawFrm, (outs), (ins),
3087 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
3088}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003089
3090//===----------------------------------------------------------------------===//
3091// Alias Instructions
3092//===----------------------------------------------------------------------===//
3093
3094// Alias instructions that map movr0 to xor.
3095// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00003096let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003097def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003098 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003099 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003100// Use xorl instead of xorw since we don't care about the high 16 bits,
3101// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00003102def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00003103 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
3104 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00003105def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00003106 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003107 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00003108}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003109
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003110//===----------------------------------------------------------------------===//
3111// Thread Local Storage Instructions
3112//
3113
Rafael Espindola7fc4b8d2009-04-24 12:59:40 +00003114// All calls clobber the non-callee saved registers. ESP is marked as
3115// a use to prevent stack-pointer assignments that appear immediately
3116// before calls from potentially appearing dead.
3117let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
3118 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
3119 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7,
3120 XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS],
Chris Lattnerf1940742009-06-20 20:38:48 +00003121 Uses = [ESP] in
3122def TLS_addr32 : I<0, Pseudo, (outs), (ins lea32mem:$sym),
3123 "leal\t$sym, %eax; "
Dan Gohman70a8a112009-04-27 15:13:28 +00003124 "call\t___tls_get_addr@PLT",
Chris Lattnerf1940742009-06-20 20:38:48 +00003125 [(X86tlsaddr tls32addr:$sym)]>,
Rafael Espindolaaf759ab2009-04-17 14:35:58 +00003126 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003127
sampo9cc09a32009-01-26 01:24:32 +00003128let AddedComplexity = 5 in
3129def GS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3130 "movl\t%gs:$src, $dst",
3131 [(set GR32:$dst, (gsload addr:$src))]>, SegGS;
3132
Chris Lattnera7c2d8a2009-05-05 18:52:19 +00003133let AddedComplexity = 5 in
3134def FS_MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
3135 "movl\t%fs:$src, $dst",
3136 [(set GR32:$dst, (fsload addr:$src))]>, SegFS;
3137
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003138//===----------------------------------------------------------------------===//
3139// DWARF Pseudo Instructions
3140//
3141
Evan Chengb783fa32007-07-19 01:14:50 +00003142def DWARF_LOC : I<0, Pseudo, (outs),
3143 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00003144 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003145 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
3146 (i32 imm:$file))]>;
3147
3148//===----------------------------------------------------------------------===//
3149// EH Pseudo Instructions
3150//
3151let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00003152 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00003153def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00003154 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003155 [(X86ehret GR32:$addr)]>;
3156
3157}
3158
3159//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003160// Atomic support
3161//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003162
Evan Cheng3e171562008-04-19 01:20:30 +00003163// Atomic swap. These are just normal xchg instructions. But since a memory
3164// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00003165let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00003166def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
3167 "xchg{l}\t{$val, $ptr|$ptr, $val}",
3168 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
3169def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
3170 "xchg{w}\t{$val, $ptr|$ptr, $val}",
3171 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
3172 OpSize;
3173def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
3174 "xchg{b}\t{$val, $ptr|$ptr, $val}",
3175 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
3176}
3177
Evan Chengd49dbb82008-04-18 20:55:36 +00003178// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003179let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003180def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003181 "lock\n\t"
3182 "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003183 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003184}
Dale Johannesenf160d802008-10-02 18:53:47 +00003185let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00003186def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dan Gohman70a8a112009-04-27 15:13:28 +00003187 "lock\n\t"
3188 "cmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00003189 [(X86cas8 addr:$ptr)]>, TB, LOCK;
3190}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003191
3192let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003193def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003194 "lock\n\t"
3195 "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003196 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003197}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00003198let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00003199def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dan Gohman70a8a112009-04-27 15:13:28 +00003200 "lock\n\t"
3201 "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00003202 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003203}
3204
Evan Chengd49dbb82008-04-18 20:55:36 +00003205// Atomic exchange and add
3206let Constraints = "$val = $dst", Defs = [EFLAGS] in {
3207def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003208 "lock\n\t"
3209 "xadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003210 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003211 TB, LOCK;
3212def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003213 "lock\n\t"
3214 "xadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003215 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003216 TB, OpSize, LOCK;
3217def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dan Gohman70a8a112009-04-27 15:13:28 +00003218 "lock\n\t"
3219 "xadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003220 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00003221 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00003222}
3223
Mon P Wang6bde9ec2008-06-25 08:15:39 +00003224// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00003225let Constraints = "$val = $dst", Defs = [EFLAGS],
3226 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003227def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003228 "#ATOMAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003229 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003230def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003231 "#ATOMOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003232 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003233def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003234 "#ATOMXOR32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003235 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00003236def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003237 "#ATOMNAND32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003238 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003239def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003240 "#ATOMMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003241 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003242def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003243 "#ATOMMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003244 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003245def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003246 "#ATOMUMIN32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003247 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00003248def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003249 "#ATOMUMAX32 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003250 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003251
3252def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003253 "#ATOMAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003254 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003255def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003256 "#ATOMOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003257 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003258def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003259 "#ATOMXOR16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003260 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003261def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003262 "#ATOMNAND16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003263 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003264def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003265 "#ATOMMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003266 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003267def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003268 "#ATOMMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003269 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003270def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003271 "#ATOMUMIN16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003272 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003273def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003274 "#ATOMUMAX16 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003275 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003276
3277def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003278 "#ATOMAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003279 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003280def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003281 "#ATOMOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003282 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003283def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003284 "#ATOMXOR8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003285 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00003286def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003287 "#ATOMNAND8 PSEUDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00003288 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00003289}
3290
Dale Johannesenf160d802008-10-02 18:53:47 +00003291let Constraints = "$val1 = $dst1, $val2 = $dst2",
3292 Defs = [EFLAGS, EAX, EBX, ECX, EDX],
3293 Uses = [EAX, EBX, ECX, EDX],
Dale Johannesen44eb5372008-10-03 19:41:08 +00003294 mayLoad = 1, mayStore = 1,
Dale Johannesenf160d802008-10-02 18:53:47 +00003295 usesCustomDAGSchedInserter = 1 in {
3296def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3297 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003298 "#ATOMAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003299def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3300 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003301 "#ATOMOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003302def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3303 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003304 "#ATOMXOR6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003305def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3306 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003307 "#ATOMNAND6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003308def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3309 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003310 "#ATOMADD6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003311def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3312 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003313 "#ATOMSUB6432 PSEUDO!", []>;
Dale Johannesen51c58ee2008-10-03 22:25:52 +00003314def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2),
3315 (ins i64mem:$ptr, GR32:$val1, GR32:$val2),
Nick Lewyckybfb9fd22008-12-07 03:49:52 +00003316 "#ATOMSWAP6432 PSEUDO!", []>;
Dale Johannesenf160d802008-10-02 18:53:47 +00003317}
3318
Andrew Lenharthe44f3902008-02-21 06:45:13 +00003319//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003320// Non-Instruction Patterns
3321//===----------------------------------------------------------------------===//
3322
Bill Wendlingfef06052008-09-16 21:48:12 +00003323// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003324def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
3325def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00003326def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003327def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
3328def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
3329
3330def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
3331 (ADD32ri GR32:$src1, tconstpool:$src2)>;
3332def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
3333 (ADD32ri GR32:$src1, tjumptable:$src2)>;
3334def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
3335 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
3336def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
3337 (ADD32ri GR32:$src1, texternalsym:$src2)>;
3338
3339def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
3340 (MOV32mi addr:$dst, tglobaladdr:$src)>;
3341def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
3342 (MOV32mi addr:$dst, texternalsym:$src)>;
3343
3344// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003345// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003346def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003347 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003348
3349def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003350 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003351def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00003352 (TAILCALL)>;
3353
3354def : Pat<(X86tcret GR32:$dst, imm:$off),
3355 (TCRETURNri GR32:$dst, imm:$off)>;
3356
3357def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
3358 (TCRETURNdi texternalsym:$dst, imm:$off)>;
3359
3360def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
3361 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003362
3363def : Pat<(X86call (i32 tglobaladdr:$dst)),
3364 (CALLpcrel32 tglobaladdr:$dst)>;
3365def : Pat<(X86call (i32 texternalsym:$dst)),
3366 (CALLpcrel32 texternalsym:$dst)>;
Evan Cheng6d35a4d2009-05-20 04:53:57 +00003367def : Pat<(X86call (i32 imm:$dst)),
3368 (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003369
3370// X86 specific add which produces a flag.
3371def : Pat<(addc GR32:$src1, GR32:$src2),
3372 (ADD32rr GR32:$src1, GR32:$src2)>;
3373def : Pat<(addc GR32:$src1, (load addr:$src2)),
3374 (ADD32rm GR32:$src1, addr:$src2)>;
3375def : Pat<(addc GR32:$src1, imm:$src2),
3376 (ADD32ri GR32:$src1, imm:$src2)>;
3377def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
3378 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3379
3380def : Pat<(subc GR32:$src1, GR32:$src2),
3381 (SUB32rr GR32:$src1, GR32:$src2)>;
3382def : Pat<(subc GR32:$src1, (load addr:$src2)),
3383 (SUB32rm GR32:$src1, addr:$src2)>;
3384def : Pat<(subc GR32:$src1, imm:$src2),
3385 (SUB32ri GR32:$src1, imm:$src2)>;
3386def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
3387 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3388
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003389// Comparisons.
3390
3391// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00003392def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003393 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003394def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003395 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00003396def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003397 (TEST32rr GR32:$src1, GR32:$src1)>;
3398
Dan Gohman0a3c5222009-01-07 01:00:24 +00003399// Conditional moves with folded loads with operands swapped and conditions
3400// inverted.
3401def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_B, EFLAGS),
3402 (CMOVAE16rm GR16:$src2, addr:$src1)>;
3403def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_B, EFLAGS),
3404 (CMOVAE32rm GR32:$src2, addr:$src1)>;
3405def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_AE, EFLAGS),
3406 (CMOVB16rm GR16:$src2, addr:$src1)>;
3407def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_AE, EFLAGS),
3408 (CMOVB32rm GR32:$src2, addr:$src1)>;
3409def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_E, EFLAGS),
3410 (CMOVNE16rm GR16:$src2, addr:$src1)>;
3411def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_E, EFLAGS),
3412 (CMOVNE32rm GR32:$src2, addr:$src1)>;
3413def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NE, EFLAGS),
3414 (CMOVE16rm GR16:$src2, addr:$src1)>;
3415def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NE, EFLAGS),
3416 (CMOVE32rm GR32:$src2, addr:$src1)>;
3417def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_BE, EFLAGS),
3418 (CMOVA16rm GR16:$src2, addr:$src1)>;
3419def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_BE, EFLAGS),
3420 (CMOVA32rm GR32:$src2, addr:$src1)>;
3421def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_A, EFLAGS),
3422 (CMOVBE16rm GR16:$src2, addr:$src1)>;
3423def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_A, EFLAGS),
3424 (CMOVBE32rm GR32:$src2, addr:$src1)>;
3425def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_L, EFLAGS),
3426 (CMOVGE16rm GR16:$src2, addr:$src1)>;
3427def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_L, EFLAGS),
3428 (CMOVGE32rm GR32:$src2, addr:$src1)>;
3429def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_GE, EFLAGS),
3430 (CMOVL16rm GR16:$src2, addr:$src1)>;
3431def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_GE, EFLAGS),
3432 (CMOVL32rm GR32:$src2, addr:$src1)>;
3433def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_LE, EFLAGS),
3434 (CMOVG16rm GR16:$src2, addr:$src1)>;
3435def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_LE, EFLAGS),
3436 (CMOVG32rm GR32:$src2, addr:$src1)>;
3437def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_G, EFLAGS),
3438 (CMOVLE16rm GR16:$src2, addr:$src1)>;
3439def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_G, EFLAGS),
3440 (CMOVLE32rm GR32:$src2, addr:$src1)>;
3441def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_P, EFLAGS),
3442 (CMOVNP16rm GR16:$src2, addr:$src1)>;
3443def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_P, EFLAGS),
3444 (CMOVNP32rm GR32:$src2, addr:$src1)>;
3445def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NP, EFLAGS),
3446 (CMOVP16rm GR16:$src2, addr:$src1)>;
3447def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NP, EFLAGS),
3448 (CMOVP32rm GR32:$src2, addr:$src1)>;
3449def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_S, EFLAGS),
3450 (CMOVNS16rm GR16:$src2, addr:$src1)>;
3451def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_S, EFLAGS),
3452 (CMOVNS32rm GR32:$src2, addr:$src1)>;
3453def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NS, EFLAGS),
3454 (CMOVS16rm GR16:$src2, addr:$src1)>;
3455def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NS, EFLAGS),
3456 (CMOVS32rm GR32:$src2, addr:$src1)>;
3457def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_O, EFLAGS),
3458 (CMOVNO16rm GR16:$src2, addr:$src1)>;
3459def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_O, EFLAGS),
3460 (CMOVNO32rm GR32:$src2, addr:$src1)>;
3461def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, X86_COND_NO, EFLAGS),
3462 (CMOVO16rm GR16:$src2, addr:$src1)>;
3463def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, X86_COND_NO, EFLAGS),
3464 (CMOVO32rm GR32:$src2, addr:$src1)>;
3465
Duncan Sands082524c2008-01-23 20:39:46 +00003466// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003467def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
3468def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
3469def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
3470
3471// extload bool -> extload byte
3472def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003473def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
3474 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003475def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003476def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
3477 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003478def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
3479def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
3480
Dan Gohmandd612bb2008-08-20 21:27:32 +00003481// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00003482def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
3483 Requires<[In32BitMode]>;
3484def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
3485 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003486def : Pat<(i32 (anyext GR16:$src)),
3487 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003488
Evan Chengf2abee72007-12-13 00:43:27 +00003489// (and (i32 load), 255) -> (zextload i8)
Evan Cheng1e5e5452008-09-29 17:26:18 +00003490def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 255))),
3491 (MOVZX32rm8 addr:$src)>;
3492def : Pat<(i32 (and (nvloadi32 addr:$src), (i32 65535))),
3493 (MOVZX32rm16 addr:$src)>;
Evan Chengf2abee72007-12-13 00:43:27 +00003494
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003495//===----------------------------------------------------------------------===//
3496// Some peepholes
3497//===----------------------------------------------------------------------===//
3498
Dan Gohman5a5e6e92008-10-17 01:33:43 +00003499// Odd encoding trick: -128 fits into an 8-bit immediate field while
3500// +128 doesn't, so in this special case use a sub instead of an add.
3501def : Pat<(add GR16:$src1, 128),
3502 (SUB16ri8 GR16:$src1, -128)>;
3503def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst),
3504 (SUB16mi8 addr:$dst, -128)>;
3505def : Pat<(add GR32:$src1, 128),
3506 (SUB32ri8 GR32:$src1, -128)>;
3507def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst),
3508 (SUB32mi8 addr:$dst, -128)>;
3509
Dan Gohman9203ab42008-07-30 18:09:17 +00003510// r & (2^16-1) ==> movz
3511def : Pat<(and GR32:$src1, 0xffff),
Dan Gohman744d4622009-04-13 16:09:41 +00003512 (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003513// r & (2^8-1) ==> movz
3514def : Pat<(and GR32:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003515 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src1, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003516 x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003517 Requires<[In32BitMode]>;
3518// r & (2^8-1) ==> movz
3519def : Pat<(and GR16:$src1, 0xff),
Dan Gohman6e438702009-04-27 16:33:14 +00003520 (MOVZX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src1, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003521 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003522 Requires<[In32BitMode]>;
3523
3524// sext_inreg patterns
3525def : Pat<(sext_inreg GR32:$src, i16),
Dan Gohman744d4622009-04-13 16:09:41 +00003526 (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003527def : Pat<(sext_inreg GR32:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003528 (MOVSX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003529 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003530 Requires<[In32BitMode]>;
3531def : Pat<(sext_inreg GR16:$src, i8),
Dan Gohman6e438702009-04-27 16:33:14 +00003532 (MOVSX16rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003533 x86_subreg_8bit))>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003534 Requires<[In32BitMode]>;
3535
3536// trunc patterns
3537def : Pat<(i16 (trunc GR32:$src)),
Dan Gohman744d4622009-04-13 16:09:41 +00003538 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00003539def : Pat<(i8 (trunc GR32:$src)),
Dan Gohman6e438702009-04-27 16:33:14 +00003540 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003541 x86_subreg_8bit)>,
Dan Gohmandd612bb2008-08-20 21:27:32 +00003542 Requires<[In32BitMode]>;
3543def : Pat<(i8 (trunc GR16:$src)),
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)>,
3546 Requires<[In32BitMode]>;
3547
3548// h-register tricks
3549def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003550 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003551 x86_subreg_8bit_hi)>,
3552 Requires<[In32BitMode]>;
3553def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))),
Dan Gohman6e438702009-04-27 16:33:14 +00003554 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003555 x86_subreg_8bit_hi)>,
3556 Requires<[In32BitMode]>;
3557def : Pat<(srl_su GR16:$src, (i8 8)),
3558 (EXTRACT_SUBREG
3559 (MOVZX32rr8
Dan Gohman6e438702009-04-27 16:33:14 +00003560 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003561 x86_subreg_8bit_hi)),
3562 x86_subreg_16bit)>,
3563 Requires<[In32BitMode]>;
Evan Cheng957ca282009-05-29 01:44:43 +00003564def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))),
3565 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD),
3566 x86_subreg_8bit_hi))>,
3567 Requires<[In32BitMode]>;
Dan Gohman744d4622009-04-13 16:09:41 +00003568def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)),
Dan Gohman6e438702009-04-27 16:33:14 +00003569 (MOVZX32rr8 (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD),
Dan Gohman744d4622009-04-13 16:09:41 +00003570 x86_subreg_8bit_hi))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00003571 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00003572
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003573// (shl x, 1) ==> (add x, x)
3574def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
3575def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
3576def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
3577
Evan Cheng76a64c72008-08-30 02:03:58 +00003578// (shl x (and y, 31)) ==> (shl x, y)
3579def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
3580 (SHL8rCL GR8:$src1)>;
3581def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
3582 (SHL16rCL GR16:$src1)>;
3583def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
3584 (SHL32rCL GR32:$src1)>;
3585def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3586 (SHL8mCL addr:$dst)>;
3587def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3588 (SHL16mCL addr:$dst)>;
3589def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3590 (SHL32mCL addr:$dst)>;
3591
3592def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
3593 (SHR8rCL GR8:$src1)>;
3594def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
3595 (SHR16rCL GR16:$src1)>;
3596def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
3597 (SHR32rCL GR32:$src1)>;
3598def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3599 (SHR8mCL addr:$dst)>;
3600def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3601 (SHR16mCL addr:$dst)>;
3602def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3603 (SHR32mCL addr:$dst)>;
3604
3605def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
3606 (SAR8rCL GR8:$src1)>;
3607def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
3608 (SAR16rCL GR16:$src1)>;
3609def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
3610 (SAR32rCL GR32:$src1)>;
3611def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3612 (SAR8mCL addr:$dst)>;
3613def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3614 (SAR16mCL addr:$dst)>;
3615def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
3616 (SAR32mCL addr:$dst)>;
3617
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003618// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
3619def : Pat<(or (srl GR32:$src1, CL:$amt),
3620 (shl GR32:$src2, (sub 32, CL:$amt))),
3621 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3622
3623def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
3624 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3625 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3626
Dan Gohman921581d2008-10-17 01:23:35 +00003627def : Pat<(or (srl GR32:$src1, (i8 (trunc ECX:$amt))),
3628 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3629 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
3630
3631def : Pat<(store (or (srl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3632 (shl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3633 addr:$dst),
3634 (SHRD32mrCL addr:$dst, GR32:$src2)>;
3635
3636def : Pat<(shrd GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3637 (SHRD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3638
3639def : Pat<(store (shrd (loadi32 addr:$dst), (i8 imm:$amt1),
3640 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3641 (SHRD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3642
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003643// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
3644def : Pat<(or (shl GR32:$src1, CL:$amt),
3645 (srl GR32:$src2, (sub 32, CL:$amt))),
3646 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3647
3648def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
3649 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
3650 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3651
Dan Gohman921581d2008-10-17 01:23:35 +00003652def : Pat<(or (shl GR32:$src1, (i8 (trunc ECX:$amt))),
3653 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3654 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
3655
3656def : Pat<(store (or (shl (loadi32 addr:$dst), (i8 (trunc ECX:$amt))),
3657 (srl GR32:$src2, (i8 (trunc (sub 32, ECX:$amt))))),
3658 addr:$dst),
3659 (SHLD32mrCL addr:$dst, GR32:$src2)>;
3660
3661def : Pat<(shld GR32:$src1, (i8 imm:$amt1), GR32:$src2, (i8 imm:$amt2)),
3662 (SHLD32rri8 GR32:$src1, GR32:$src2, (i8 imm:$amt1))>;
3663
3664def : Pat<(store (shld (loadi32 addr:$dst), (i8 imm:$amt1),
3665 GR32:$src2, (i8 imm:$amt2)), addr:$dst),
3666 (SHLD32mri8 addr:$dst, GR32:$src2, (i8 imm:$amt1))>;
3667
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003668// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
3669def : Pat<(or (srl GR16:$src1, CL:$amt),
3670 (shl GR16:$src2, (sub 16, CL:$amt))),
3671 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3672
3673def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
3674 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3675 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3676
Dan Gohman921581d2008-10-17 01:23:35 +00003677def : Pat<(or (srl GR16:$src1, (i8 (trunc CX:$amt))),
3678 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3679 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
3680
3681def : Pat<(store (or (srl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3682 (shl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3683 addr:$dst),
3684 (SHRD16mrCL addr:$dst, GR16:$src2)>;
3685
3686def : Pat<(shrd GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3687 (SHRD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3688
3689def : Pat<(store (shrd (loadi16 addr:$dst), (i8 imm:$amt1),
3690 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3691 (SHRD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3692
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003693// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
3694def : Pat<(or (shl GR16:$src1, CL:$amt),
3695 (srl GR16:$src2, (sub 16, CL:$amt))),
3696 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3697
3698def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
3699 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
3700 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3701
Dan Gohman921581d2008-10-17 01:23:35 +00003702def : Pat<(or (shl GR16:$src1, (i8 (trunc CX:$amt))),
3703 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3704 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
3705
3706def : Pat<(store (or (shl (loadi16 addr:$dst), (i8 (trunc CX:$amt))),
3707 (srl GR16:$src2, (i8 (trunc (sub 16, CX:$amt))))),
3708 addr:$dst),
3709 (SHLD16mrCL addr:$dst, GR16:$src2)>;
3710
3711def : Pat<(shld GR16:$src1, (i8 imm:$amt1), GR16:$src2, (i8 imm:$amt2)),
3712 (SHLD16rri8 GR16:$src1, GR16:$src2, (i8 imm:$amt1))>;
3713
3714def : Pat<(store (shld (loadi16 addr:$dst), (i8 imm:$amt1),
3715 GR16:$src2, (i8 imm:$amt2)), addr:$dst),
3716 (SHLD16mri8 addr:$dst, GR16:$src2, (i8 imm:$amt1))>;
3717
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003718//===----------------------------------------------------------------------===//
Dan Gohman99a12192009-03-04 19:44:21 +00003719// EFLAGS-defining Patterns
Bill Wendlingf5399032008-12-12 21:15:41 +00003720//===----------------------------------------------------------------------===//
3721
Dan Gohman99a12192009-03-04 19:44:21 +00003722// Register-Register Addition with EFLAGS result
3723def : Pat<(parallel (X86add_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003724 (implicit EFLAGS)),
3725 (ADD8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003726def : Pat<(parallel (X86add_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003727 (implicit EFLAGS)),
3728 (ADD16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003729def : Pat<(parallel (X86add_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003730 (implicit EFLAGS)),
3731 (ADD32rr GR32:$src1, GR32:$src2)>;
3732
Dan Gohman99a12192009-03-04 19:44:21 +00003733// Register-Memory Addition with EFLAGS result
3734def : Pat<(parallel (X86add_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003735 (implicit EFLAGS)),
3736 (ADD8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003737def : Pat<(parallel (X86add_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003738 (implicit EFLAGS)),
3739 (ADD16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003740def : Pat<(parallel (X86add_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003741 (implicit EFLAGS)),
3742 (ADD32rm GR32:$src1, addr:$src2)>;
3743
Dan Gohman99a12192009-03-04 19:44:21 +00003744// Register-Integer Addition with EFLAGS result
3745def : Pat<(parallel (X86add_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003746 (implicit EFLAGS)),
3747 (ADD8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003748def : Pat<(parallel (X86add_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003749 (implicit EFLAGS)),
3750 (ADD16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003751def : Pat<(parallel (X86add_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003752 (implicit EFLAGS)),
3753 (ADD32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003754def : Pat<(parallel (X86add_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003755 (implicit EFLAGS)),
3756 (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003757def : Pat<(parallel (X86add_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003758 (implicit EFLAGS)),
3759 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
3760
Dan Gohman99a12192009-03-04 19:44:21 +00003761// Memory-Register Addition with EFLAGS result
3762def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003763 addr:$dst),
3764 (implicit EFLAGS)),
3765 (ADD8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003766def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003767 addr:$dst),
3768 (implicit EFLAGS)),
3769 (ADD16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003770def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003771 addr:$dst),
3772 (implicit EFLAGS)),
3773 (ADD32mr addr:$dst, GR32:$src2)>;
Dale Johannesen06b83f12009-05-18 17:44:15 +00003774
3775// Memory-Integer Addition with EFLAGS result
Dan Gohman99a12192009-03-04 19:44:21 +00003776def : Pat<(parallel (store (X86add_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003777 addr:$dst),
3778 (implicit EFLAGS)),
3779 (ADD8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003780def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003781 addr:$dst),
3782 (implicit EFLAGS)),
3783 (ADD16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003784def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003785 addr:$dst),
3786 (implicit EFLAGS)),
3787 (ADD32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003788def : Pat<(parallel (store (X86add_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003789 addr:$dst),
3790 (implicit EFLAGS)),
3791 (ADD16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003792def : Pat<(parallel (store (X86add_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003793 addr:$dst),
3794 (implicit EFLAGS)),
3795 (ADD32mi8 addr:$dst, i32immSExt8:$src2)>;
3796
Dan Gohman99a12192009-03-04 19:44:21 +00003797// Register-Register Subtraction with EFLAGS result
3798def : Pat<(parallel (X86sub_flag GR8:$src1, GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003799 (implicit EFLAGS)),
3800 (SUB8rr GR8:$src1, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003801def : Pat<(parallel (X86sub_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003802 (implicit EFLAGS)),
3803 (SUB16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003804def : Pat<(parallel (X86sub_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003805 (implicit EFLAGS)),
3806 (SUB32rr GR32:$src1, GR32:$src2)>;
3807
Dan Gohman99a12192009-03-04 19:44:21 +00003808// Register-Memory Subtraction with EFLAGS result
3809def : Pat<(parallel (X86sub_flag GR8:$src1, (loadi8 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003810 (implicit EFLAGS)),
3811 (SUB8rm GR8:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003812def : Pat<(parallel (X86sub_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003813 (implicit EFLAGS)),
3814 (SUB16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003815def : Pat<(parallel (X86sub_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003816 (implicit EFLAGS)),
3817 (SUB32rm GR32:$src1, addr:$src2)>;
3818
Dan Gohman99a12192009-03-04 19:44:21 +00003819// Register-Integer Subtraction with EFLAGS result
3820def : Pat<(parallel (X86sub_flag GR8:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003821 (implicit EFLAGS)),
3822 (SUB8ri GR8:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003823def : Pat<(parallel (X86sub_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003824 (implicit EFLAGS)),
3825 (SUB16ri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003826def : Pat<(parallel (X86sub_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003827 (implicit EFLAGS)),
3828 (SUB32ri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003829def : Pat<(parallel (X86sub_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003830 (implicit EFLAGS)),
3831 (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003832def : Pat<(parallel (X86sub_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003833 (implicit EFLAGS)),
3834 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
3835
Dan Gohman99a12192009-03-04 19:44:21 +00003836// Memory-Register Subtraction with EFLAGS result
3837def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), GR8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003838 addr:$dst),
3839 (implicit EFLAGS)),
3840 (SUB8mr addr:$dst, GR8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003841def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003842 addr:$dst),
3843 (implicit EFLAGS)),
3844 (SUB16mr addr:$dst, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003845def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003846 addr:$dst),
3847 (implicit EFLAGS)),
3848 (SUB32mr addr:$dst, GR32:$src2)>;
3849
Dan Gohman99a12192009-03-04 19:44:21 +00003850// Memory-Integer Subtraction with EFLAGS result
3851def : Pat<(parallel (store (X86sub_flag (loadi8 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003852 addr:$dst),
3853 (implicit EFLAGS)),
3854 (SUB8mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003855def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003856 addr:$dst),
3857 (implicit EFLAGS)),
3858 (SUB16mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003859def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003860 addr:$dst),
3861 (implicit EFLAGS)),
3862 (SUB32mi addr:$dst, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003863def : Pat<(parallel (store (X86sub_flag (loadi16 addr:$dst), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003864 addr:$dst),
3865 (implicit EFLAGS)),
3866 (SUB16mi8 addr:$dst, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003867def : Pat<(parallel (store (X86sub_flag (loadi32 addr:$dst), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003868 addr:$dst),
3869 (implicit EFLAGS)),
3870 (SUB32mi8 addr:$dst, i32immSExt8:$src2)>;
3871
3872
Dan Gohman99a12192009-03-04 19:44:21 +00003873// Register-Register Signed Integer Multiply with EFLAGS result
3874def : Pat<(parallel (X86smul_flag GR16:$src1, GR16:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003875 (implicit EFLAGS)),
3876 (IMUL16rr GR16:$src1, GR16:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003877def : Pat<(parallel (X86smul_flag GR32:$src1, GR32:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003878 (implicit EFLAGS)),
3879 (IMUL32rr GR32:$src1, GR32:$src2)>;
3880
Dan Gohman99a12192009-03-04 19:44:21 +00003881// Register-Memory Signed Integer Multiply with EFLAGS result
3882def : Pat<(parallel (X86smul_flag GR16:$src1, (loadi16 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003883 (implicit EFLAGS)),
3884 (IMUL16rm GR16:$src1, addr:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003885def : Pat<(parallel (X86smul_flag GR32:$src1, (loadi32 addr:$src2)),
Bill Wendlingf5399032008-12-12 21:15:41 +00003886 (implicit EFLAGS)),
3887 (IMUL32rm GR32:$src1, addr:$src2)>;
3888
Dan Gohman99a12192009-03-04 19:44:21 +00003889// Register-Integer Signed Integer Multiply with EFLAGS result
3890def : Pat<(parallel (X86smul_flag GR16:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003891 (implicit EFLAGS)),
3892 (IMUL16rri GR16:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003893def : Pat<(parallel (X86smul_flag GR32:$src1, imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003894 (implicit EFLAGS)),
3895 (IMUL32rri GR32:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003896def : Pat<(parallel (X86smul_flag GR16:$src1, i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003897 (implicit EFLAGS)),
3898 (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003899def : Pat<(parallel (X86smul_flag GR32:$src1, i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003900 (implicit EFLAGS)),
3901 (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>;
3902
Dan Gohman99a12192009-03-04 19:44:21 +00003903// Memory-Integer Signed Integer Multiply with EFLAGS result
3904def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003905 (implicit EFLAGS)),
3906 (IMUL16rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003907def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), imm:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003908 (implicit EFLAGS)),
3909 (IMUL32rmi addr:$src1, imm:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003910def : Pat<(parallel (X86smul_flag (loadi16 addr:$src1), i16immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003911 (implicit EFLAGS)),
3912 (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>;
Dan Gohman99a12192009-03-04 19:44:21 +00003913def : Pat<(parallel (X86smul_flag (loadi32 addr:$src1), i32immSExt8:$src2),
Bill Wendlingf5399032008-12-12 21:15:41 +00003914 (implicit EFLAGS)),
3915 (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>;
3916
Dan Gohman99a12192009-03-04 19:44:21 +00003917// Optimize multiply by 2 with EFLAGS result.
Evan Cheng00cf7932009-01-27 03:30:42 +00003918let AddedComplexity = 2 in {
Dan Gohman99a12192009-03-04 19:44:21 +00003919def : Pat<(parallel (X86smul_flag GR16:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003920 (implicit EFLAGS)),
3921 (ADD16rr GR16:$src1, GR16:$src1)>;
3922
Dan Gohman99a12192009-03-04 19:44:21 +00003923def : Pat<(parallel (X86smul_flag GR32:$src1, 2),
Evan Cheng00cf7932009-01-27 03:30:42 +00003924 (implicit EFLAGS)),
3925 (ADD32rr GR32:$src1, GR32:$src1)>;
3926}
3927
Dan Gohman99a12192009-03-04 19:44:21 +00003928// INC and DEC with EFLAGS result. Note that these do not set CF.
3929def : Pat<(parallel (X86inc_flag GR8:$src), (implicit EFLAGS)),
3930 (INC8r GR8:$src)>;
3931def : Pat<(parallel (store (i8 (X86inc_flag (loadi8 addr:$dst))), addr:$dst),
3932 (implicit EFLAGS)),
3933 (INC8m addr:$dst)>;
3934def : Pat<(parallel (X86dec_flag GR8:$src), (implicit EFLAGS)),
3935 (DEC8r GR8:$src)>;
3936def : Pat<(parallel (store (i8 (X86dec_flag (loadi8 addr:$dst))), addr:$dst),
3937 (implicit EFLAGS)),
3938 (DEC8m addr:$dst)>;
3939
3940def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003941 (INC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003942def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst),
3943 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003944 (INC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003945def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003946 (DEC16r GR16:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003947def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst),
3948 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003949 (DEC16m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003950
3951def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003952 (INC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003953def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst),
3954 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003955 (INC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003956def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003957 (DEC32r GR32:$src)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003958def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst),
3959 (implicit EFLAGS)),
Dan Gohmaneebcac72009-03-05 21:32:23 +00003960 (DEC32m addr:$dst)>, Requires<[In32BitMode]>;
Dan Gohman99a12192009-03-04 19:44:21 +00003961
Bill Wendlingf5399032008-12-12 21:15:41 +00003962//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003963// Floating Point Stack Support
3964//===----------------------------------------------------------------------===//
3965
3966include "X86InstrFPStack.td"
3967
3968//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00003969// X86-64 Support
3970//===----------------------------------------------------------------------===//
3971
Chris Lattner2de8d2b2008-01-10 05:50:42 +00003972include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00003973
3974//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00003975// XMM Floating point support (requires SSE / SSE2)
3976//===----------------------------------------------------------------------===//
3977
3978include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00003979
3980//===----------------------------------------------------------------------===//
3981// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
3982//===----------------------------------------------------------------------===//
3983
3984include "X86InstrMMX.td"