blob: bd61c3aed460b187e234ddd8801b8e6893203e44 [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
Evan Cheng621216e2007-09-29 00:00:36 +000030def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000031 [SDTCisVT<0, OtherVT>,
32 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000033
Evan Cheng621216e2007-09-29 00:00:36 +000034def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000035 [SDTCisVT<0, i8>,
36 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000038def SDTX86cas : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisInt<1>,
39 SDTCisVT<2, i8>]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000040def SDTX86cas8 : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000041
Chris Lattnerb56cc342008-03-11 03:23:40 +000042def SDTX86Ret : SDTypeProfile<0, -1, [SDTCisVT<0, i16>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000043
Bill Wendling7173da52007-11-13 09:19:02 +000044def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
45def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
46 SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000047
Dan Gohman3329ffe2008-05-29 19:57:41 +000048def SDT_X86Call : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000049
50def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
51
52def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
53
54def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
55
56def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
57
58def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
59
60def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
61
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000062def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
63
Evan Cheng48679f42007-12-14 02:13:44 +000064def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
65def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
67def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
68
Evan Cheng621216e2007-09-29 00:00:36 +000069def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000070
Evan Cheng621216e2007-09-29 00:00:36 +000071def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000072def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000073 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000074def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000075
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000076def X86cas : SDNode<"X86ISD::LCMPXCHG_DAG", SDTX86cas,
77 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
78 SDNPMayLoad]>;
Andrew Lenharth81580822008-03-05 01:15:49 +000079def X86cas8 : SDNode<"X86ISD::LCMPXCHG8_DAG", SDTX86cas8,
80 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
81 SDNPMayLoad]>;
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +000082
Dan Gohmanf17a25c2007-07-18 16:29:46 +000083def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
84 [SDNPHasChain, SDNPOptInFlag]>;
85
86def X86callseq_start :
87 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
88 [SDNPHasChain, SDNPOutFlag]>;
89def X86callseq_end :
90 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000091 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000092
93def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
94 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
95
96def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
97 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
98
99def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000100 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000101def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +0000102 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
103 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000104
105def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000106 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000107
108def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
109def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
110
111def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +0000112 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000113def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
114
115def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
116 [SDNPHasChain]>;
117
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000118def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
119 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000120
121//===----------------------------------------------------------------------===//
122// X86 Operand Definitions.
123//
124
125// *mem - Operand definitions for the funky X86 addressing mode operands.
126//
127class X86MemOperand<string printMethod> : Operand<iPTR> {
128 let PrintMethod = printMethod;
129 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
130}
131
132def i8mem : X86MemOperand<"printi8mem">;
133def i16mem : X86MemOperand<"printi16mem">;
134def i32mem : X86MemOperand<"printi32mem">;
135def i64mem : X86MemOperand<"printi64mem">;
136def i128mem : X86MemOperand<"printi128mem">;
137def f32mem : X86MemOperand<"printf32mem">;
138def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000139def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000140def f128mem : X86MemOperand<"printf128mem">;
141
142def lea32mem : Operand<i32> {
143 let PrintMethod = "printi32mem";
144 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
145}
146
147def SSECC : Operand<i8> {
148 let PrintMethod = "printSSECC";
149}
150
151def piclabel: Operand<i32> {
152 let PrintMethod = "printPICLabel";
153}
154
155// A couple of more descriptive operand definitions.
156// 16-bits but only 8 bits are significant.
157def i16i8imm : Operand<i16>;
158// 32-bits but only 8 bits are significant.
159def i32i8imm : Operand<i32>;
160
161// Branch targets have OtherVT type.
162def brtarget : Operand<OtherVT>;
163
164//===----------------------------------------------------------------------===//
165// X86 Complex Pattern Definitions.
166//
167
168// Define X86 specific addressing mode.
169def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
170def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
171 [add, mul, shl, or, frameindex], []>;
172
173//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000174// X86 Instruction Predicate Definitions.
175def HasMMX : Predicate<"Subtarget->hasMMX()">;
176def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
177def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
178def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
179def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Nate Begemanb2975562008-02-03 07:18:54 +0000180def HasSSE41 : Predicate<"Subtarget->hasSSE41()">;
181def HasSSE42 : Predicate<"Subtarget->hasSSE42()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000182def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
183def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000184def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
185def In64BitMode : Predicate<"Subtarget->is64Bit()">;
186def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
187def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
188def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
189
190//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000191// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000192//
193
Evan Cheng86ab7d32007-07-31 08:04:03 +0000194include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195
196//===----------------------------------------------------------------------===//
197// Pattern fragments...
198//
199
200// X86 specific condition code. These correspond to CondCode in
201// X86InstrInfo.h. They must be kept in synch.
202def X86_COND_A : PatLeaf<(i8 0)>;
203def X86_COND_AE : PatLeaf<(i8 1)>;
204def X86_COND_B : PatLeaf<(i8 2)>;
205def X86_COND_BE : PatLeaf<(i8 3)>;
206def X86_COND_E : PatLeaf<(i8 4)>;
207def X86_COND_G : PatLeaf<(i8 5)>;
208def X86_COND_GE : PatLeaf<(i8 6)>;
209def X86_COND_L : PatLeaf<(i8 7)>;
210def X86_COND_LE : PatLeaf<(i8 8)>;
211def X86_COND_NE : PatLeaf<(i8 9)>;
212def X86_COND_NO : PatLeaf<(i8 10)>;
213def X86_COND_NP : PatLeaf<(i8 11)>;
214def X86_COND_NS : PatLeaf<(i8 12)>;
215def X86_COND_O : PatLeaf<(i8 13)>;
216def X86_COND_P : PatLeaf<(i8 14)>;
217def X86_COND_S : PatLeaf<(i8 15)>;
218
219def i16immSExt8 : PatLeaf<(i16 imm), [{
220 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
221 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000222 return (int16_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000223}]>;
224
225def i32immSExt8 : PatLeaf<(i32 imm), [{
226 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
227 // sign extended field.
Dan Gohmanfaeb4a32008-09-12 16:56:44 +0000228 return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000229}]>;
230
231// Helper fragments for loads.
Evan Chengb3e25ea2008-05-13 18:59:59 +0000232// It's always safe to treat a anyext i16 load as a i32 load if the i16 is
233// known to be 32-bit aligned or better. Ditto for i8 to i16.
Evan Cheng8b765e92008-05-13 00:54:02 +0000234def loadi16 : PatFrag<(ops node:$ptr), (i16 (ld node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000235 LoadSDNode *LD = cast<LoadSDNode>(N);
236 if (LD->getAddressingMode() != ISD::UNINDEXED)
237 return false;
238 ISD::LoadExtType ExtType = LD->getExtensionType();
239 if (ExtType == ISD::NON_EXTLOAD)
240 return true;
241 if (ExtType == ISD::EXTLOAD)
242 return LD->getAlignment() >= 2 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000243 return false;
244}]>;
245
Evan Cheng56ec77b2008-09-24 23:27:55 +0000246def loadi16_anyext : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
247 LoadSDNode *LD = cast<LoadSDNode>(N);
248 if (LD->getAddressingMode() != ISD::UNINDEXED)
249 return false;
250 ISD::LoadExtType ExtType = LD->getExtensionType();
251 if (ExtType == ISD::EXTLOAD)
252 return LD->getAlignment() >= 2 && !LD->isVolatile();
253 return false;
254}]>;
255
Evan Cheng8b765e92008-05-13 00:54:02 +0000256def loadi32 : PatFrag<(ops node:$ptr), (i32 (ld node:$ptr)), [{
Dan Gohman8335c412008-08-20 15:24:22 +0000257 LoadSDNode *LD = cast<LoadSDNode>(N);
258 if (LD->getAddressingMode() != ISD::UNINDEXED)
259 return false;
260 ISD::LoadExtType ExtType = LD->getExtensionType();
261 if (ExtType == ISD::NON_EXTLOAD)
262 return true;
263 if (ExtType == ISD::EXTLOAD)
264 return LD->getAlignment() >= 4 && !LD->isVolatile();
Evan Cheng8b765e92008-05-13 00:54:02 +0000265 return false;
266}]>;
267
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000268def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
270
271def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
272def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000273def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
276def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
277def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
278
279def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
280def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
281def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
282def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
283def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
284def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
285
286def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
287def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
288def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
289def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
290def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
291def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
292
Chris Lattner21da6382008-02-19 17:37:35 +0000293
294// An 'and' node with a single use.
295def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
Evan Cheng9123cfa2008-03-04 00:40:35 +0000296 return N->hasOneUse();
Chris Lattner21da6382008-02-19 17:37:35 +0000297}]>;
298
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000299//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300// Instruction list...
301//
302
303// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
304// a stack adjustment and the codegen must know that they may modify the stack
305// pointer before prolog-epilog rewriting occurs.
Chris Lattnerb56cc342008-03-11 03:23:40 +0000306// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become
307// sub / add which can clobber EFLAGS.
Evan Cheng037364a2007-09-28 01:19:48 +0000308let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Bill Wendling22f8deb2007-11-13 00:44:25 +0000309def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt),
310 "#ADJCALLSTACKDOWN",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000311 [(X86callseq_start imm:$amt)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000312def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 "#ADJCALLSTACKUP",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000314 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
315}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316
317// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000318let neverHasSideEffects = 1 in
319 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320
Evan Cheng0729ccf2008-01-05 00:41:47 +0000321// PIC base
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000322let neverHasSideEffects = 1, isNotDuplicable = 1 in
323 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
324 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325
326//===----------------------------------------------------------------------===//
327// Control Flow Instructions...
328//
329
330// Return instructions.
331let isTerminator = 1, isReturn = 1, isBarrier = 1,
Chris Lattnerb56cc342008-03-11 03:23:40 +0000332 hasCtrlDep = 1, FPForm = SpecialFP, FPFormBits = SpecialFP.Value in {
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000333 def RET : I <0xC3, RawFrm, (outs), (ins variable_ops),
Chris Lattnerb56cc342008-03-11 03:23:40 +0000334 "ret",
Dan Gohman2c4be2a2008-05-31 02:11:25 +0000335 [(X86retflag 0)]>;
Chris Lattnerb56cc342008-03-11 03:23:40 +0000336 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt, variable_ops),
337 "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000338 [(X86retflag imm:$amt)]>;
339}
340
341// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000342let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000343 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
344 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000345
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000347 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000348
Owen Andersonf8053082007-11-12 07:39:39 +0000349// Indirect branches
350let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000351 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000352 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000353 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 [(brind (loadi32 addr:$dst))]>;
355}
356
357// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000358let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000359def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000360 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000361def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000362 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000363def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000364 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000365def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000366 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000367def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000368 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000369def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000370 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371
Dan Gohman91888f02007-07-31 20:11:57 +0000372def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000373 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000374def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000375 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000376def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000377 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000378def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000379 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000380
Dan Gohman91888f02007-07-31 20:11:57 +0000381def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000382 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000383def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000384 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000385def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000386 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000387def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000388 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000389def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000390 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000391def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000392 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000393} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394
395//===----------------------------------------------------------------------===//
396// Call Instructions...
397//
Evan Cheng37e7c752007-07-21 00:34:19 +0000398let isCall = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399 // All calls clobber the non-callee saved registers...
400 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
401 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng950aac02007-09-25 01:57:46 +0000402 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000403 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
404 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000405 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000406 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000407 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohmanea4faba2008-05-29 21:50:34 +0000408 "call\t{*}$dst", [(X86call (loadi32 addr:$dst))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409 }
410
411// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000412
Chris Lattnerb56cc342008-03-11 03:23:40 +0000413def TAILCALL : I<0, Pseudo, (outs), (ins),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000414 "#TAILCALL",
415 []>;
416
Evan Cheng37e7c752007-07-21 00:34:19 +0000417let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000418def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000419 "#TC_RETURN $dst $offset",
420 []>;
421
422let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofer6fd37ac2008-03-19 16:39:45 +0000423def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset, variable_ops),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000424 "#TC_RETURN $dst $offset",
425 []>;
426
427let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofera0032722008-04-30 09:16:33 +0000428
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000429 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000430 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000431let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000432 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
433 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000434let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000435 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000436 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000437
438//===----------------------------------------------------------------------===//
439// Miscellaneous Instructions...
440//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000441let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000443 (outs), (ins), "leave", []>;
444
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000445let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
446let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000447def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000448
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000449let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000450def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000451}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000453let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000454def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000455let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000456def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000457
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458let isTwoAddress = 1 in // GR32 = bswap GR32
459 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000460 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000461 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000462 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
463
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464
Evan Cheng48679f42007-12-14 02:13:44 +0000465// Bit scan instructions.
466let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000467def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000468 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000469 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000470def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000471 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000472 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
473 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000474def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000475 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000476 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000477def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000478 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000479 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
480 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000481
Evan Cheng4e33de92007-12-14 18:49:43 +0000482def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000483 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000484 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000485def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000486 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000487 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
488 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000489def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000490 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000491 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000492def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000493 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000494 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
495 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000496} // Defs = [EFLAGS]
497
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000498let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000499def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000500 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000501 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Evan Cheng1ea8e6b2008-03-27 01:41:09 +0000502let isReMaterializable = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000503def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000504 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000505 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000506 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
507
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000508let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000509def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000510 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000511def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000512 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000513def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000514 [(X86rep_movs i32)]>, REP;
515}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000517let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000518def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000519 [(X86rep_stos i8)]>, REP;
520let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000521def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000522 [(X86rep_stos i16)]>, REP, OpSize;
523let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000524def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000525 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000527let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000528def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000529 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000531let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000532def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000533}
534
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535//===----------------------------------------------------------------------===//
536// Input/Output Instructions...
537//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000538let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000539def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000540 "in{b}\t{%dx, %al|%AL, %DX}", []>;
541let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000542def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000543 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
544let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000545def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000546 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000548let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000549def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000550 "in{b}\t{$port, %al|%AL, $port}", []>;
551let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000552def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000553 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
554let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000555def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000556 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000557
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000558let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000559def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000560 "out{b}\t{%al, %dx|%DX, %AL}", []>;
561let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000562def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000563 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
564let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000565def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000566 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000567
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000568let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000569def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000570 "out{b}\t{%al, $port|$port, %AL}", []>;
571let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000572def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000573 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
574let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000575def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000576 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577
578//===----------------------------------------------------------------------===//
579// Move Instructions...
580//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000581let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000582def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000583 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000584def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000585 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000586def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000587 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000588}
Evan Cheng6f26e8b2008-06-18 08:13:07 +0000589let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000590def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000591 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000593def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000594 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000596def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000597 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598 [(set GR32:$dst, imm:$src)]>;
599}
Evan Chengb783fa32007-07-19 01:14:50 +0000600def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000601 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000602 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000603def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000604 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000605 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000606def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000607 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000608 [(store (i32 imm:$src), addr:$dst)]>;
609
Chris Lattner1a1932c2008-01-06 23:38:27 +0000610let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000611def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000612 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000613 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000614def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000615 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000616 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000617def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000618 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000619 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000620}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621
Evan Chengb783fa32007-07-19 01:14:50 +0000622def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000623 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000624 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000625def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000626 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000628def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000629 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000630 [(store GR32:$src, addr:$dst)]>;
631
632//===----------------------------------------------------------------------===//
633// Fixed-Register Multiplication and Division Instructions...
634//
635
636// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000637let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000638def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
640 // This probably ought to be moved to a def : Pat<> if the
641 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000642 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000643let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000644def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000645 OpSize; // AX,DX = AX*GR16
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000646let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000647def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
648 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000649let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000650def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000651 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000652 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
653 // This probably ought to be moved to a def : Pat<> if the
654 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000655 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000656let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000657let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000658def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000659 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng55687072007-09-14 21:48:26 +0000660let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000661def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000662 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000663}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000664
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000665let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000666let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000667def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
668 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000669let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000670def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000671 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000672let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000673def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
674 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000675let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000676let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000677def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000678 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000679let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000680def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000681 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
682let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000683def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000684 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000685}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686
687// unsigned division/remainder
Evan Cheng55687072007-09-14 21:48:26 +0000688let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000689def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000690 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000691let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000692def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000693 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000694let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000695def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000696 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000697let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000698let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000699def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000700 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000701let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000702def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000703 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000704let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000705def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000706 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000707}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708
709// Signed division/remainder.
Evan Cheng55687072007-09-14 21:48:26 +0000710let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000711def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000712 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000713let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000714def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000715 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000716let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000717def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000718 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000719let mayLoad = 1, mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000720let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000721def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000722 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000723let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000724def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000725 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000726let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000727def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000728 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000729}
730} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731
732//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000733// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734//
735let isTwoAddress = 1 in {
736
737// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000738let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000739let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000740def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000741 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000742 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000744 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000747 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000748 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000750 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752
753def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000754 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000755 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000757 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000760 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000761 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000763 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000766 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000767 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000769 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000772 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000773 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000775 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000778 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000779 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000781 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000784 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000785 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000787 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000790 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000791 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000793 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000794 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000796 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000797 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000799 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000800 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000802 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000803 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000805 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000808 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000809 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000811 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000814 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000815 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000817 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000818 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000820 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000821 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000822 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000823 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000824 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000826 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000829 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000831def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000832 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000833 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000835 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000838 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000839 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000841 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000844 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000845 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000847 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000850 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000851 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000853 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000856 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000857 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000859 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000862 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000863 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000865 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000868 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000869 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000871 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000874 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000875 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000877 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000878 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000880 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000881 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000883 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000886 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000887 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000889 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000892 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000893 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000894 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000895 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000897def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000898 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000899 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000901 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000903def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000904 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000905 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000907 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000908 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000909} // isCommutable = 1
910
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000912 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000913 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000915 X86_COND_NP, EFLAGS))]>,
916 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000917
918def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
919 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
920 "cmovb\t{$src2, $dst|$dst, $src2}",
921 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
922 X86_COND_B, EFLAGS))]>,
923 TB, OpSize;
924def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
925 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
926 "cmovb\t{$src2, $dst|$dst, $src2}",
927 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
928 X86_COND_B, EFLAGS))]>,
929 TB;
930def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
931 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
932 "cmovae\t{$src2, $dst|$dst, $src2}",
933 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
934 X86_COND_AE, EFLAGS))]>,
935 TB, OpSize;
936def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
937 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
938 "cmovae\t{$src2, $dst|$dst, $src2}",
939 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
940 X86_COND_AE, EFLAGS))]>,
941 TB;
942def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
943 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
944 "cmove\t{$src2, $dst|$dst, $src2}",
945 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
946 X86_COND_E, EFLAGS))]>,
947 TB, OpSize;
948def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
949 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
950 "cmove\t{$src2, $dst|$dst, $src2}",
951 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
952 X86_COND_E, EFLAGS))]>,
953 TB;
954def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
955 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
956 "cmovne\t{$src2, $dst|$dst, $src2}",
957 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
958 X86_COND_NE, EFLAGS))]>,
959 TB, OpSize;
960def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
961 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
962 "cmovne\t{$src2, $dst|$dst, $src2}",
963 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
964 X86_COND_NE, EFLAGS))]>,
965 TB;
966def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
967 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
968 "cmovbe\t{$src2, $dst|$dst, $src2}",
969 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
970 X86_COND_BE, EFLAGS))]>,
971 TB, OpSize;
972def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
973 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
974 "cmovbe\t{$src2, $dst|$dst, $src2}",
975 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
976 X86_COND_BE, EFLAGS))]>,
977 TB;
978def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
979 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
980 "cmova\t{$src2, $dst|$dst, $src2}",
981 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
982 X86_COND_A, EFLAGS))]>,
983 TB, OpSize;
984def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
985 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
986 "cmova\t{$src2, $dst|$dst, $src2}",
987 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
988 X86_COND_A, EFLAGS))]>,
989 TB;
990def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
991 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
992 "cmovl\t{$src2, $dst|$dst, $src2}",
993 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
994 X86_COND_L, EFLAGS))]>,
995 TB, OpSize;
996def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
997 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
998 "cmovl\t{$src2, $dst|$dst, $src2}",
999 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1000 X86_COND_L, EFLAGS))]>,
1001 TB;
1002def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
1003 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1004 "cmovge\t{$src2, $dst|$dst, $src2}",
1005 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1006 X86_COND_GE, EFLAGS))]>,
1007 TB, OpSize;
1008def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
1009 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1010 "cmovge\t{$src2, $dst|$dst, $src2}",
1011 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1012 X86_COND_GE, EFLAGS))]>,
1013 TB;
1014def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
1015 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1016 "cmovle\t{$src2, $dst|$dst, $src2}",
1017 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1018 X86_COND_LE, EFLAGS))]>,
1019 TB, OpSize;
1020def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
1021 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1022 "cmovle\t{$src2, $dst|$dst, $src2}",
1023 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1024 X86_COND_LE, EFLAGS))]>,
1025 TB;
1026def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
1027 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1028 "cmovg\t{$src2, $dst|$dst, $src2}",
1029 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1030 X86_COND_G, EFLAGS))]>,
1031 TB, OpSize;
1032def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
1033 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1034 "cmovg\t{$src2, $dst|$dst, $src2}",
1035 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1036 X86_COND_G, EFLAGS))]>,
1037 TB;
1038def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1039 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1040 "cmovs\t{$src2, $dst|$dst, $src2}",
1041 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1042 X86_COND_S, EFLAGS))]>,
1043 TB, OpSize;
1044def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1045 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1046 "cmovs\t{$src2, $dst|$dst, $src2}",
1047 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1048 X86_COND_S, EFLAGS))]>,
1049 TB;
1050def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1051 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1052 "cmovns\t{$src2, $dst|$dst, $src2}",
1053 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1054 X86_COND_NS, EFLAGS))]>,
1055 TB, OpSize;
1056def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1057 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1058 "cmovns\t{$src2, $dst|$dst, $src2}",
1059 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1060 X86_COND_NS, EFLAGS))]>,
1061 TB;
1062def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1063 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1064 "cmovp\t{$src2, $dst|$dst, $src2}",
1065 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1066 X86_COND_P, EFLAGS))]>,
1067 TB, OpSize;
1068def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1069 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1070 "cmovp\t{$src2, $dst|$dst, $src2}",
1071 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1072 X86_COND_P, EFLAGS))]>,
1073 TB;
1074def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1075 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1076 "cmovnp\t{$src2, $dst|$dst, $src2}",
1077 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1078 X86_COND_NP, EFLAGS))]>,
1079 TB, OpSize;
Evan Cheng950aac02007-09-25 01:57:46 +00001080} // Uses = [EFLAGS]
1081
1082
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083// unary instructions
1084let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001085let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001086def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001088def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001090def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 [(set GR32:$dst, (ineg GR32:$src))]>;
1092let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001093 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001095 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001097 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1099
1100}
Evan Cheng55687072007-09-14 21:48:26 +00001101} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102
Dan Gohman91888f02007-07-31 20:11:57 +00001103def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001105def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001107def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108 [(set GR32:$dst, (not GR32:$src))]>;
1109let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001110 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001112 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001114 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1116}
1117} // CodeSize
1118
1119// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001120let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001122def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001123 [(set GR8:$dst, (add GR8:$src, 1))]>;
1124let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001125def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126 [(set GR16:$dst, (add GR16:$src, 1))]>,
1127 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001128def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1130}
1131let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001132 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001134 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001135 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1136 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001137 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001138 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1139 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140}
1141
1142let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001143def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001144 [(set GR8:$dst, (add GR8:$src, -1))]>;
1145let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001146def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001147 [(set GR16:$dst, (add GR16:$src, -1))]>,
1148 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001149def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1151}
1152
1153let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001154 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001155 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001156 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001157 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1158 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001159 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001160 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1161 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162}
Evan Cheng55687072007-09-14 21:48:26 +00001163} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164
1165// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001166let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001167let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1168def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001169 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001170 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001171 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1172def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001173 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001174 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1176def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001177 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001178 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1180}
1181
1182def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001183 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001184 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1186def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001187 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001188 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001189 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1190def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001191 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001192 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1194
1195def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001196 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001197 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1199def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001200 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001201 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1203def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001204 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001205 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1207def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001208 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001209 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1211 OpSize;
1212def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001213 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001214 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1216
1217let isTwoAddress = 0 in {
1218 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001219 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001220 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001221 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1222 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001223 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001224 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1226 OpSize;
1227 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001228 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001229 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1231 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001232 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001233 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1235 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001236 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001237 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001238 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1239 OpSize;
1240 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001241 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001242 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1244 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001245 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001246 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1248 OpSize;
1249 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001250 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001251 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1253}
1254
1255
1256let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001257def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001258 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001260def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001261 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001262 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001263def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001264 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1266}
Evan Chengb783fa32007-07-19 01:14:50 +00001267def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001268 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001270def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001271 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001273def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001274 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001275 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1276
Evan Chengb783fa32007-07-19 01:14:50 +00001277def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001278 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001280def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001281 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001283def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001284 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1286
Evan Chengb783fa32007-07-19 01:14:50 +00001287def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001288 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001290def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001291 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001292 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1293let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001294 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001295 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001297 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001298 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001300 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001301 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001303 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001304 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001306 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001307 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1309 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001310 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001311 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001313 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001314 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001315 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1316 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001317 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001318 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001320} // isTwoAddress = 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001321
1322
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001323let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001324 def XOR8rr : I<0x30, MRMDestReg,
1325 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
1326 "xor{b}\t{$src2, $dst|$dst, $src2}",
1327 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1328 def XOR16rr : I<0x31, MRMDestReg,
1329 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
1330 "xor{w}\t{$src2, $dst|$dst, $src2}",
1331 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1332 def XOR32rr : I<0x31, MRMDestReg,
1333 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
1334 "xor{l}\t{$src2, $dst|$dst, $src2}",
1335 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
Evan Cheng6f26e8b2008-06-18 08:13:07 +00001336} // isCommutable = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337
1338def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001339 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001340 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1342def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001343 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001344 "xor{w}\t{$src2, $dst|$dst, $src2}",
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001345 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>,
1346 OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001347def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001348 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001349 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1351
Bill Wendlingbac38eb2008-05-29 03:46:36 +00001352def XOR8ri : Ii8<0x80, MRM6r,
1353 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
1354 "xor{b}\t{$src2, $dst|$dst, $src2}",
1355 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1356def XOR16ri : Ii16<0x81, MRM6r,
1357 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
1358 "xor{w}\t{$src2, $dst|$dst, $src2}",
1359 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1360def XOR32ri : Ii32<0x81, MRM6r,
1361 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
1362 "xor{l}\t{$src2, $dst|$dst, $src2}",
1363 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1364def XOR16ri8 : Ii8<0x83, MRM6r,
1365 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
1366 "xor{w}\t{$src2, $dst|$dst, $src2}",
1367 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1368 OpSize;
1369def XOR32ri8 : Ii8<0x83, MRM6r,
1370 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
1371 "xor{l}\t{$src2, $dst|$dst, $src2}",
1372 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001373
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374let isTwoAddress = 0 in {
1375 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001376 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001377 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1379 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001380 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001381 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001382 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1383 OpSize;
1384 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001385 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001386 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001387 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1388 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001389 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001390 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001391 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1392 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001393 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001394 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1396 OpSize;
1397 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001398 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001399 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001400 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1401 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001402 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001403 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1405 OpSize;
1406 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001407 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001408 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001410} // isTwoAddress = 0
Evan Cheng55687072007-09-14 21:48:26 +00001411} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412
1413// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001414let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001415let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001416def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001418 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001419def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001420 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001421 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001422def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001423 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001424 [(set GR32:$dst, (shl GR32:$src, CL))]>;
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001425} // Uses = [CL]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426
Evan Chengb783fa32007-07-19 01:14:50 +00001427def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001428 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001429 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1430let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001431def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001432 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001433 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001434def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001436 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001437// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1438// cheaper.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00001439} // isConvertibleToThreeAddress = 1
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440
1441let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001442 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001443 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001444 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001445 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001446 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001447 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001448 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001449 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001451 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1452 }
Evan Chengb783fa32007-07-19 01:14:50 +00001453 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001454 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001456 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001457 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001458 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1459 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001460 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001461 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001462 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1463
1464 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001465 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001466 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001468 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001470 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1471 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001472 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001473 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001474 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1475}
1476
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001477let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001478def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001479 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001480 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001481def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001482 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001483 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001484def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001485 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001486 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1487}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001488
Evan Chengb783fa32007-07-19 01:14:50 +00001489def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001490 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001491 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001492def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001493 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001495def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001496 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001497 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1498
1499// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001500def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001501 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001502 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001503def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001504 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001506def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001507 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001508 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1509
1510let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001511 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001512 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001513 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001514 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001515 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001516 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001518 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001519 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001520 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001521 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1522 }
Evan Chengb783fa32007-07-19 01:14:50 +00001523 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001524 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001526 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001527 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1529 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001530 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001531 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001532 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1533
1534 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001535 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001538 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001539 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001541 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1544}
1545
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001546let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001547def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001548 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001549 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001550def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001552 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001553def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001554 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001555 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1556}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557
Evan Chengb783fa32007-07-19 01:14:50 +00001558def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001561def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001562 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001563 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1564 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001565def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001566 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1568
1569// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001570def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001573def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001574 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001576def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001577 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1579
1580let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001581 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001582 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001583 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001584 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001585 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001586 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001587 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001588 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001589 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001590 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1591 }
Evan Chengb783fa32007-07-19 01:14:50 +00001592 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001593 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001594 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001595 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001596 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001597 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1598 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001599 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001600 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1602
1603 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001604 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001605 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001607 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001608 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1610 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001611 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001612 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001613 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1614}
1615
1616// Rotate instructions
1617// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001618let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001619def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001620 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001621 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001622def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001623 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001624 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001625def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001626 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001627 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1628}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001629
Evan Chengb783fa32007-07-19 01:14:50 +00001630def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001631 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001633def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001634 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001635 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001636def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001637 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001638 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1639
1640// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001641def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001642 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001643 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001644def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001645 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001646 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001647def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001648 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001649 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1650
1651let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001652 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001653 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001654 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001655 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001656 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001657 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001658 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001659 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001660 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001661 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1662 }
Evan Chengb783fa32007-07-19 01:14:50 +00001663 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001666 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001667 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001668 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1669 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001670 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1673
1674 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001675 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001676 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001678 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001679 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001680 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1681 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001682 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1685}
1686
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001687let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001688def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001690 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001691def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001692 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001693 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001694def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001695 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001696 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1697}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001698
Evan Chengb783fa32007-07-19 01:14:50 +00001699def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001700 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001702def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001703 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001704 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001705def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1708
1709// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001710def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001711 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001712 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001713def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001715 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001716def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001717 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001718 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1719
1720let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001721 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001722 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001723 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001724 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001725 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001726 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001727 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001728 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001730 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1731 }
Evan Chengb783fa32007-07-19 01:14:50 +00001732 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001733 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001734 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001735 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1738 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001739 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1742
1743 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001744 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001745 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001746 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001747 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001748 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001749 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1750 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001751 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001752 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001753 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1754}
1755
1756
1757
1758// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001759let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001760def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001762 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001763def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001765 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001766def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001767 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001768 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001769 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001770def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001771 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001772 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001773 TB, OpSize;
1774}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775
1776let isCommutable = 1 in { // These instructions commute to each other.
1777def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001778 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001779 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001780 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1781 (i8 imm:$src3)))]>,
1782 TB;
1783def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001784 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001785 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001786 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1787 (i8 imm:$src3)))]>,
1788 TB;
1789def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001790 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001791 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1793 (i8 imm:$src3)))]>,
1794 TB, OpSize;
1795def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001796 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1799 (i8 imm:$src3)))]>,
1800 TB, OpSize;
1801}
1802
1803let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001804 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001805 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001807 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001808 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001809 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001810 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001811 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001812 addr:$dst)]>, TB;
1813 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001814 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001815 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001816 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001817 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1818 (i8 imm:$src3)), addr:$dst)]>,
1819 TB;
1820 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001821 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001822 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1824 (i8 imm:$src3)), addr:$dst)]>,
1825 TB;
1826
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001827 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001828 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001831 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001832 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001833 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001834 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001835 addr:$dst)]>, TB, OpSize;
1836 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001838 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001839 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1841 (i8 imm:$src3)), addr:$dst)]>,
1842 TB, OpSize;
1843 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001844 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001845 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001846 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1847 (i8 imm:$src3)), addr:$dst)]>,
1848 TB, OpSize;
1849}
Evan Cheng55687072007-09-14 21:48:26 +00001850} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001851
1852
1853// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001854let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001856def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1857 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001858 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001859 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1860let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001861def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1862 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001865def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1866 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001868 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1869} // end isConvertibleToThreeAddress
1870} // end isCommutable
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001871def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1872 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001873 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001874 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001875def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1876 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001877 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001878 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1879def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1880 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001881 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001882 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1883
Evan Chengb783fa32007-07-19 01:14:50 +00001884def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1887
1888let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001889def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1890 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001891 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001892 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001893def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1894 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001895 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001896 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001897def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1898 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001900 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1901def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1902 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001903 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001904 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001905}
1906
1907let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001908 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001909 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001910 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001911 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001914 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001915 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001916 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001917 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001918 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001919 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001920 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001921 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001924 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001925 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001926 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001928 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001930 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001931 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001932 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001933 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001934 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1935}
1936
Evan Cheng259471d2007-10-05 17:59:57 +00001937let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001938let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001939def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001941 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1942}
Evan Chengb783fa32007-07-19 01:14:50 +00001943def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001946def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001947 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001948 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001949def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001950 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001951 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1952
1953let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001954 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001957 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001958 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001959 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001960 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001961 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001962 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1963}
Evan Cheng259471d2007-10-05 17:59:57 +00001964} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001965
Evan Chengb783fa32007-07-19 01:14:50 +00001966def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001967 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001968 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001969def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001970 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001971 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001972def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001973 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001974 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001975def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001976 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001978def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001981def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001983 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1984
Evan Chengb783fa32007-07-19 01:14:50 +00001985def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001986 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001987 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001988def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001989 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001990 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001991def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001992 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001994def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng55687072007-09-14 21:48:26 +00001997 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001998def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001999 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002000 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
2001let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002002 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002003 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002004 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002005 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002006 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002007 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002008 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002009 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002010 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002012 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002015 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002016 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002018 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002019 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002020 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002021 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002022 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002023 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002024 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00002025 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002026 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
2029}
2030
Evan Cheng259471d2007-10-05 17:59:57 +00002031let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002032def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002034 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002035
2036let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002037 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002040 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002041 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002042 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002043 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002044 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002045 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002046 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002047 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002048 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049}
Evan Chengb783fa32007-07-19 01:14:50 +00002050def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002051 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002052 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002053def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002054 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002056def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002057 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002058 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002059} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002060} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061
Evan Cheng55687072007-09-14 21:48:26 +00002062let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002063let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002064def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002065 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002066 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002067def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002068 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002069 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2070}
Evan Chengb783fa32007-07-19 01:14:50 +00002071def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002072 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002073 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2074 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002075def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002076 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002078} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002079} // end Two Address instructions
2080
2081// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002082let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002083def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002084 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002086 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2087def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002088 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002089 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002090 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2091def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002092 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002093 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002094 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2095 OpSize;
2096def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002097 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002098 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002099 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2100
2101def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002102 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002103 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2105 OpSize;
2106def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002107 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002108 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2110def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002111 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002112 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2114 OpSize;
2115def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002116 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002117 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00002119} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002120
2121//===----------------------------------------------------------------------===//
2122// Test instructions are just like AND, except they don't generate a result.
2123//
Evan Cheng950aac02007-09-25 01:57:46 +00002124let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002125let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002126def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002127 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002128 [(X86cmp (and_su GR8:$src1, GR8:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002129 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002130def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002131 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002132 [(X86cmp (and_su GR16:$src1, GR16:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002133 (implicit EFLAGS)]>,
2134 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002135def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002136 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002137 [(X86cmp (and_su GR32:$src1, GR32:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002138 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139}
2140
Evan Chengb783fa32007-07-19 01:14:50 +00002141def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002142 "test{b}\t{$src2, $src1|$src1, $src2}",
2143 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2144 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002145def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002146 "test{w}\t{$src2, $src1|$src1, $src2}",
2147 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2148 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002149def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002150 "test{l}\t{$src2, $src1|$src1, $src2}",
2151 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2152 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153
2154def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002155 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002156 "test{b}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002157 [(X86cmp (and_su GR8:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002158 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002159def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002160 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002161 "test{w}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002162 [(X86cmp (and_su GR16:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002163 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002165 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002166 "test{l}\t{$src2, $src1|$src1, $src2}",
Chris Lattner21da6382008-02-19 17:37:35 +00002167 [(X86cmp (and_su GR32:$src1, imm:$src2), 0),
Evan Cheng621216e2007-09-29 00:00:36 +00002168 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002169
Evan Cheng621216e2007-09-29 00:00:36 +00002170def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002171 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002172 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002173 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2174 (implicit EFLAGS)]>;
2175def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002176 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002177 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002178 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2179 (implicit EFLAGS)]>, OpSize;
2180def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002181 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002182 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002183 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002184 (implicit EFLAGS)]>;
2185} // Defs = [EFLAGS]
2186
2187
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002189let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002190def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002191let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002192def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002193
Evan Cheng950aac02007-09-25 01:57:46 +00002194let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002195def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002196 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002197 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002198 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002199 TB; // GR8 = ==
2200def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002201 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002202 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002203 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204 TB; // [mem8] = ==
2205def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002206 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002207 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002208 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002209 TB; // GR8 = !=
2210def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002211 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002212 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002213 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 TB; // [mem8] = !=
2215def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002216 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002218 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002219 TB; // GR8 = < signed
2220def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002221 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002222 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002223 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002224 TB; // [mem8] = < signed
2225def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002226 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002227 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002228 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002229 TB; // GR8 = >= signed
2230def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002231 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002232 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002233 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234 TB; // [mem8] = >= signed
2235def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002236 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002237 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002238 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002239 TB; // GR8 = <= signed
2240def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002241 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002242 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002243 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002244 TB; // [mem8] = <= signed
2245def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002246 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002247 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002248 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002249 TB; // GR8 = > signed
2250def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002251 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002253 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002254 TB; // [mem8] = > signed
2255
2256def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002257 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002258 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002259 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002260 TB; // GR8 = < unsign
2261def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002262 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002263 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002264 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002265 TB; // [mem8] = < unsign
2266def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002267 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002268 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002269 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002270 TB; // GR8 = >= unsign
2271def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002272 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002273 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002274 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002275 TB; // [mem8] = >= unsign
2276def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002277 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002278 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002279 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280 TB; // GR8 = <= unsign
2281def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002282 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002283 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002284 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002285 TB; // [mem8] = <= unsign
2286def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002287 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002288 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002289 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290 TB; // GR8 = > signed
2291def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002292 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002293 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002294 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002295 TB; // [mem8] = > signed
2296
2297def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002298 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002299 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002300 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002301 TB; // GR8 = <sign bit>
2302def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002303 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002304 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002305 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002306 TB; // [mem8] = <sign bit>
2307def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002308 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002309 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002310 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002311 TB; // GR8 = !<sign bit>
2312def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002313 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002314 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002315 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002316 TB; // [mem8] = !<sign bit>
2317def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002318 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002319 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002320 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002321 TB; // GR8 = parity
2322def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002323 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002324 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002325 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002326 TB; // [mem8] = parity
2327def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002328 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002329 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002330 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002331 TB; // GR8 = not parity
2332def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002333 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002334 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002335 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002336 TB; // [mem8] = not parity
Evan Cheng950aac02007-09-25 01:57:46 +00002337} // Uses = [EFLAGS]
2338
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002339
2340// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002341let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002342def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002343 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002344 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002345 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002346def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002347 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002348 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002349 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002350def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002351 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002352 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002353 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002354def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002355 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002356 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002357 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2358 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002359def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002360 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002361 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002362 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2363 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002364def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002365 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002366 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002367 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2368 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002369def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002370 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002372 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2373 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002374def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002375 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002376 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002377 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2378 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002379def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002380 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002381 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002382 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2383 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002385 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002386 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002387 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002388def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002389 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002390 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002391 [(X86cmp GR16:$src1, imm:$src2),
2392 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002393def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002394 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002395 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002396 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002397def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002398 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002399 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002400 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2401 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002402def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002403 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002404 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002405 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2406 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002407def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002408 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002409 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002410 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2411 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002412def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002413 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002414 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002415 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2416 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002417def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002418 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002419 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002420 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2421 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002422def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002423 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002424 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002425 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2426 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002427def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002428 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002429 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002430 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002431 (implicit EFLAGS)]>;
2432} // Defs = [EFLAGS]
2433
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002434// Sign/Zero extenders
Dan Gohman9203ab42008-07-30 18:09:17 +00002435// Use movsbl intead of movsbw; we don't care about the high 16 bits
2436// of the register here. This has a smaller encoding and avoids a
2437// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002438def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002439 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2440 [(set GR16:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002441def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002442 "movs{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2443 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002444def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002445 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002446 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002447def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002448 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002449 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002450def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002451 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002452 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002453def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002454 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002455 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2456
Dan Gohman9203ab42008-07-30 18:09:17 +00002457// Use movzbl intead of movzbw; we don't care about the high 16 bits
2458// of the register here. This has a smaller encoding and avoids a
2459// partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002460def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002461 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2462 [(set GR16:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002463def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman9203ab42008-07-30 18:09:17 +00002464 "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}",
2465 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002466def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002467 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002468 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002469def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002470 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002471 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002472def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002473 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002474 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002475def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002476 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002477 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2478
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002479let neverHasSideEffects = 1 in {
2480 let Defs = [AX], Uses = [AL] in
2481 def CBW : I<0x98, RawFrm, (outs), (ins),
2482 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2483 let Defs = [EAX], Uses = [AX] in
2484 def CWDE : I<0x98, RawFrm, (outs), (ins),
2485 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002486
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002487 let Defs = [AX,DX], Uses = [AX] in
2488 def CWD : I<0x99, RawFrm, (outs), (ins),
2489 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2490 let Defs = [EAX,EDX], Uses = [EAX] in
2491 def CDQ : I<0x99, RawFrm, (outs), (ins),
2492 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2493}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002494
2495//===----------------------------------------------------------------------===//
2496// Alias Instructions
2497//===----------------------------------------------------------------------===//
2498
2499// Alias instructions that map movr0 to xor.
2500// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Bill Wendlingba5d5b02008-05-29 01:02:09 +00002501let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002502def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002503 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002504 [(set GR8:$dst, 0)]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002505// Use xorl instead of xorw since we don't care about the high 16 bits,
2506// it's smaller, and it avoids a partial-register update.
Evan Chengb783fa32007-07-19 01:14:50 +00002507def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman9203ab42008-07-30 18:09:17 +00002508 "xor{l}\t${dst:subreg32}, ${dst:subreg32}",
2509 [(set GR16:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002510def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002511 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002512 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002513}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002514
2515// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2516// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002517let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002518def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002519 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002520def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002521 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002522
Evan Chengb783fa32007-07-19 01:14:50 +00002523def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002524 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002525def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002526 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002527} // neverHasSideEffects
2528
2529let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002530def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002531 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002532def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002533 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002534}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002535let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002536def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002537 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002538def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002539 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002540}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002541
2542//===----------------------------------------------------------------------===//
2543// Thread Local Storage Instructions
2544//
2545
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002546let Uses = [EBX] in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002547def TLS_addr32 : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
2548 "leal\t${sym:mem}(,%ebx,1), $dst",
2549 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002550
2551let AddedComplexity = 10 in
Anton Korobeynikov4fbf00b2008-05-04 21:36:32 +00002552def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002553 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002554 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2555
2556let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002557def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002558 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002559 [(set GR32:$dst,
2560 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2561
Evan Chengb783fa32007-07-19 01:14:50 +00002562def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002563 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002564 [(set GR32:$dst, X86TLStp)]>;
2565
2566//===----------------------------------------------------------------------===//
2567// DWARF Pseudo Instructions
2568//
2569
Evan Chengb783fa32007-07-19 01:14:50 +00002570def DWARF_LOC : I<0, Pseudo, (outs),
2571 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002572 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002573 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2574 (i32 imm:$file))]>;
2575
2576//===----------------------------------------------------------------------===//
2577// EH Pseudo Instructions
2578//
2579let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002580 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002581def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002582 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002583 [(X86ehret GR32:$addr)]>;
2584
2585}
2586
2587//===----------------------------------------------------------------------===//
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002588// Atomic support
2589//
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002590
Evan Cheng3e171562008-04-19 01:20:30 +00002591// Atomic swap. These are just normal xchg instructions. But since a memory
2592// operand is referenced, the atomicity is ensured.
Dan Gohmana41a1c092008-08-06 15:52:50 +00002593let Constraints = "$val = $dst" in {
Evan Cheng3e171562008-04-19 01:20:30 +00002594def XCHG32rm : I<0x87, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
2595 "xchg{l}\t{$val, $ptr|$ptr, $val}",
2596 [(set GR32:$dst, (atomic_swap_32 addr:$ptr, GR32:$val))]>;
2597def XCHG16rm : I<0x87, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2598 "xchg{w}\t{$val, $ptr|$ptr, $val}",
2599 [(set GR16:$dst, (atomic_swap_16 addr:$ptr, GR16:$val))]>,
2600 OpSize;
2601def XCHG8rm : I<0x86, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
2602 "xchg{b}\t{$val, $ptr|$ptr, $val}",
2603 [(set GR8:$dst, (atomic_swap_8 addr:$ptr, GR8:$val))]>;
2604}
2605
Evan Chengd49dbb82008-04-18 20:55:36 +00002606// Atomic compare and swap.
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002607let Defs = [EAX, EFLAGS], Uses = [EAX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002608def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002609 "lock\n\tcmpxchg{l}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002610 [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002611}
Andrew Lenharth81580822008-03-05 01:15:49 +00002612let Defs = [EAX, EBX, ECX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in {
Anton Korobeynikovc4067392008-07-22 16:22:48 +00002613def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i32mem:$ptr),
Dale Johannesend20e4452008-08-19 18:47:28 +00002614 "lock\n\tcmpxchg8b\t$ptr",
Andrew Lenharth81580822008-03-05 01:15:49 +00002615 [(X86cas8 addr:$ptr)]>, TB, LOCK;
2616}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002617
2618let Defs = [AX, EFLAGS], Uses = [AX] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002619def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002620 "lock\n\tcmpxchg{w}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002621 [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002622}
Andrew Lenharth7dfe23f2008-03-01 21:52:34 +00002623let Defs = [AL, EFLAGS], Uses = [AL] in {
Evan Chengd49dbb82008-04-18 20:55:36 +00002624def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap),
Dale Johannesend20e4452008-08-19 18:47:28 +00002625 "lock\n\tcmpxchg{b}\t{$swap, $ptr|$ptr, $swap}",
Evan Cheng09fbdee2008-03-04 03:20:06 +00002626 [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002627}
2628
Evan Chengd49dbb82008-04-18 20:55:36 +00002629// Atomic exchange and add
2630let Constraints = "$val = $dst", Defs = [EFLAGS] in {
2631def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002632 "lock\n\txadd{l}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002633 [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002634 TB, LOCK;
2635def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002636 "lock\n\txadd{w}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002637 [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002638 TB, OpSize, LOCK;
2639def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins i8mem:$ptr, GR8:$val),
Dale Johannesend20e4452008-08-19 18:47:28 +00002640 "lock\n\txadd{b}\t{$val, $ptr|$ptr, $val}",
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002641 [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>,
Evan Chengd49dbb82008-04-18 20:55:36 +00002642 TB, LOCK;
Andrew Lenharth7a5a4b22008-03-01 13:37:02 +00002643}
2644
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002645// Atomic exchange, and, or, xor
Mon P Wang078a62d2008-05-05 19:05:59 +00002646let Constraints = "$val = $dst", Defs = [EFLAGS],
2647 usesCustomDAGSchedInserter = 1 in {
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002648def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002649 "#ATOMAND32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002650 [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002651def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002652 "#ATOMOR32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002653 [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002654def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002655 "#ATOMXOR32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002656 [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>;
Andrew Lenharthaf02d592008-06-14 05:48:15 +00002657def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang6bde9ec2008-06-25 08:15:39 +00002658 "#ATOMNAND32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002659 [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002660def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002661 "#ATOMMIN32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002662 [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002663def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002664 "#ATOMMAX32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002665 [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002666def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002667 "#ATOMUMIN32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002668 [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>;
Dan Gohman8aeb61f2008-05-12 20:22:45 +00002669def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val),
Mon P Wang078a62d2008-05-05 19:05:59 +00002670 "#ATOMUMAX32 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002671 [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002672
2673def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2674 "#ATOMAND16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002675 [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002676def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2677 "#ATOMOR16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002678 [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002679def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2680 "#ATOMXOR16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002681 [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002682def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2683 "#ATOMNAND16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002684 [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002685def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val),
2686 "#ATOMMIN16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002687 [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002688def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2689 "#ATOMMAX16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002690 [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002691def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2692 "#ATOMUMIN16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002693 [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002694def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val),
2695 "#ATOMUMAX16 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002696 [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002697
2698def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2699 "#ATOMAND8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002700 [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002701def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2702 "#ATOMOR8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002703 [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002704def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2705 "#ATOMXOR8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002706 [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>;
Dale Johannesend20e4452008-08-19 18:47:28 +00002707def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val),
2708 "#ATOMNAND8 PSUEDO!",
Dale Johannesenbc187662008-08-28 02:44:49 +00002709 [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>;
Mon P Wang078a62d2008-05-05 19:05:59 +00002710}
2711
Andrew Lenharthe44f3902008-02-21 06:45:13 +00002712//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002713// Non-Instruction Patterns
2714//===----------------------------------------------------------------------===//
2715
Bill Wendlingfef06052008-09-16 21:48:12 +00002716// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002717def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2718def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
Nate Begemanb52948972008-04-12 00:47:57 +00002719def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002720def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2721def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2722
2723def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2724 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2725def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2726 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2727def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2728 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2729def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2730 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2731
2732def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2733 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2734def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2735 (MOV32mi addr:$dst, texternalsym:$src)>;
2736
2737// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002738// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002739def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002740 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002741
2742def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002743 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002744def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002745 (TAILCALL)>;
2746
2747def : Pat<(X86tcret GR32:$dst, imm:$off),
2748 (TCRETURNri GR32:$dst, imm:$off)>;
2749
2750def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2751 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2752
2753def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2754 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002755
2756def : Pat<(X86call (i32 tglobaladdr:$dst)),
2757 (CALLpcrel32 tglobaladdr:$dst)>;
2758def : Pat<(X86call (i32 texternalsym:$dst)),
2759 (CALLpcrel32 texternalsym:$dst)>;
2760
2761// X86 specific add which produces a flag.
2762def : Pat<(addc GR32:$src1, GR32:$src2),
2763 (ADD32rr GR32:$src1, GR32:$src2)>;
2764def : Pat<(addc GR32:$src1, (load addr:$src2)),
2765 (ADD32rm GR32:$src1, addr:$src2)>;
2766def : Pat<(addc GR32:$src1, imm:$src2),
2767 (ADD32ri GR32:$src1, imm:$src2)>;
2768def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2769 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2770
2771def : Pat<(subc GR32:$src1, GR32:$src2),
2772 (SUB32rr GR32:$src1, GR32:$src2)>;
2773def : Pat<(subc GR32:$src1, (load addr:$src2)),
2774 (SUB32rm GR32:$src1, addr:$src2)>;
2775def : Pat<(subc GR32:$src1, imm:$src2),
2776 (SUB32ri GR32:$src1, imm:$src2)>;
2777def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2778 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2779
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002780// Comparisons.
2781
2782// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00002783def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002784 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002785def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002786 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002787def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002788 (TEST32rr GR32:$src1, GR32:$src1)>;
2789
Duncan Sands082524c2008-01-23 20:39:46 +00002790// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002791def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2792def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2793def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2794
2795// extload bool -> extload byte
2796def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002797def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>,
2798 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002799def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002800def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>,
2801 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002802def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2803def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2804
Dan Gohmandd612bb2008-08-20 21:27:32 +00002805// anyext
Bill Wendlingce1c5c12008-08-22 20:51:05 +00002806def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>,
2807 Requires<[In32BitMode]>;
2808def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>,
2809 Requires<[In32BitMode]>;
Dan Gohmandd612bb2008-08-20 21:27:32 +00002810def : Pat<(i32 (anyext GR16:$src)),
2811 (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002812
Evan Chengf2abee72007-12-13 00:43:27 +00002813// (and (i32 load), 255) -> (zextload i8)
2814def : Pat<(i32 (and (loadi32 addr:$src), (i32 255))), (MOVZX32rm8 addr:$src)>;
2815def : Pat<(i32 (and (loadi32 addr:$src), (i32 65535))),(MOVZX32rm16 addr:$src)>;
2816
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002817//===----------------------------------------------------------------------===//
2818// Some peepholes
2819//===----------------------------------------------------------------------===//
2820
Dan Gohman9203ab42008-07-30 18:09:17 +00002821// r & (2^16-1) ==> movz
2822def : Pat<(and GR32:$src1, 0xffff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002823 (MOVZX32rr16 (i16 (EXTRACT_SUBREG GR32:$src1, x86_subreg_16bit)))>;
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002824// r & (2^8-1) ==> movz
2825def : Pat<(and GR32:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002826 (MOVZX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src1),
2827 x86_subreg_8bit)))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002828 Requires<[In32BitMode]>;
2829// r & (2^8-1) ==> movz
2830def : Pat<(and GR16:$src1, 0xff),
Dan Gohmandd612bb2008-08-20 21:27:32 +00002831 (MOVZX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src1),
2832 x86_subreg_8bit)))>,
2833 Requires<[In32BitMode]>;
2834
2835// sext_inreg patterns
2836def : Pat<(sext_inreg GR32:$src, i16),
2837 (MOVSX32rr16 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit)))>;
2838def : Pat<(sext_inreg GR32:$src, i8),
2839 (MOVSX32rr8 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src),
2840 x86_subreg_8bit)))>,
2841 Requires<[In32BitMode]>;
2842def : Pat<(sext_inreg GR16:$src, i8),
2843 (MOVSX16rr8 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src),
2844 x86_subreg_8bit)))>,
2845 Requires<[In32BitMode]>;
2846
2847// trunc patterns
2848def : Pat<(i16 (trunc GR32:$src)),
2849 (i16 (EXTRACT_SUBREG GR32:$src, x86_subreg_16bit))>;
2850def : Pat<(i8 (trunc GR32:$src)),
2851 (i8 (EXTRACT_SUBREG (MOV32to32_ GR32:$src), x86_subreg_8bit))>,
2852 Requires<[In32BitMode]>;
2853def : Pat<(i8 (trunc GR16:$src)),
2854 (i8 (EXTRACT_SUBREG (MOV16to16_ GR16:$src), x86_subreg_8bit))>,
Dan Gohman5beb1ff2008-08-06 18:27:21 +00002855 Requires<[In32BitMode]>;
Dan Gohman9203ab42008-07-30 18:09:17 +00002856
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002857// (shl x, 1) ==> (add x, x)
2858def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2859def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2860def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2861
Evan Cheng76a64c72008-08-30 02:03:58 +00002862// (shl x (and y, 31)) ==> (shl x, y)
2863def : Pat<(shl GR8:$src1, (and CL:$amt, 31)),
2864 (SHL8rCL GR8:$src1)>;
2865def : Pat<(shl GR16:$src1, (and CL:$amt, 31)),
2866 (SHL16rCL GR16:$src1)>;
2867def : Pat<(shl GR32:$src1, (and CL:$amt, 31)),
2868 (SHL32rCL GR32:$src1)>;
2869def : Pat<(store (shl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2870 (SHL8mCL addr:$dst)>;
2871def : Pat<(store (shl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2872 (SHL16mCL addr:$dst)>;
2873def : Pat<(store (shl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2874 (SHL32mCL addr:$dst)>;
2875
2876def : Pat<(srl GR8:$src1, (and CL:$amt, 31)),
2877 (SHR8rCL GR8:$src1)>;
2878def : Pat<(srl GR16:$src1, (and CL:$amt, 31)),
2879 (SHR16rCL GR16:$src1)>;
2880def : Pat<(srl GR32:$src1, (and CL:$amt, 31)),
2881 (SHR32rCL GR32:$src1)>;
2882def : Pat<(store (srl (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2883 (SHR8mCL addr:$dst)>;
2884def : Pat<(store (srl (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2885 (SHR16mCL addr:$dst)>;
2886def : Pat<(store (srl (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2887 (SHR32mCL addr:$dst)>;
2888
2889def : Pat<(sra GR8:$src1, (and CL:$amt, 31)),
2890 (SAR8rCL GR8:$src1)>;
2891def : Pat<(sra GR16:$src1, (and CL:$amt, 31)),
2892 (SAR16rCL GR16:$src1)>;
2893def : Pat<(sra GR32:$src1, (and CL:$amt, 31)),
2894 (SAR32rCL GR32:$src1)>;
2895def : Pat<(store (sra (loadi8 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2896 (SAR8mCL addr:$dst)>;
2897def : Pat<(store (sra (loadi16 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2898 (SAR16mCL addr:$dst)>;
2899def : Pat<(store (sra (loadi32 addr:$dst), (and CL:$amt, 31)), addr:$dst),
2900 (SAR32mCL addr:$dst)>;
2901
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002902// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2903def : Pat<(or (srl GR32:$src1, CL:$amt),
2904 (shl GR32:$src2, (sub 32, CL:$amt))),
2905 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2906
2907def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2908 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2909 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2910
2911// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2912def : Pat<(or (shl GR32:$src1, CL:$amt),
2913 (srl GR32:$src2, (sub 32, CL:$amt))),
2914 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2915
2916def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2917 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2918 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2919
2920// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2921def : Pat<(or (srl GR16:$src1, CL:$amt),
2922 (shl GR16:$src2, (sub 16, CL:$amt))),
2923 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2924
2925def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2926 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2927 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2928
2929// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2930def : Pat<(or (shl GR16:$src1, CL:$amt),
2931 (srl GR16:$src2, (sub 16, CL:$amt))),
2932 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2933
2934def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2935 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2936 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2937
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002938//===----------------------------------------------------------------------===//
2939// Floating Point Stack Support
2940//===----------------------------------------------------------------------===//
2941
2942include "X86InstrFPStack.td"
2943
2944//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00002945// X86-64 Support
2946//===----------------------------------------------------------------------===//
2947
Chris Lattner2de8d2b2008-01-10 05:50:42 +00002948include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00002949
2950//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002951// XMM Floating point support (requires SSE / SSE2)
2952//===----------------------------------------------------------------------===//
2953
2954include "X86InstrSSE.td"
Evan Cheng5e4d1e72008-04-25 18:19:54 +00002955
2956//===----------------------------------------------------------------------===//
2957// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2958//===----------------------------------------------------------------------===//
2959
2960include "X86InstrMMX.td"