blob: 478007b2073bcefaaead36aecccd5ae8cca5e847 [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
38def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
39
Bill Wendling7173da52007-11-13 09:19:02 +000040def SDT_X86CallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
41def SDT_X86CallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
42 SDTCisVT<1, i32> ]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000043
44def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
45
46def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
47
48def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
49
50def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
51
52def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
53
54def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
55
56def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
57
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000058def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
59
Evan Cheng48679f42007-12-14 02:13:44 +000060def X86bsf : SDNode<"X86ISD::BSF", SDTIntUnaryOp>;
61def X86bsr : SDNode<"X86ISD::BSR", SDTIntUnaryOp>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
63def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
64
Evan Cheng621216e2007-09-29 00:00:36 +000065def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066
Evan Cheng621216e2007-09-29 00:00:36 +000067def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000069 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000070def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000071
72def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
73 [SDNPHasChain, SDNPOptInFlag]>;
74
75def X86callseq_start :
76 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
77 [SDNPHasChain, SDNPOutFlag]>;
78def X86callseq_end :
79 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000080 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000081
82def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
83 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
84
85def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
86 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
87
88def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +000089 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000090def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
Chris Lattnerca4e0fe2008-01-10 05:12:37 +000091 [SDNPHasChain, SDNPInFlag, SDNPOutFlag, SDNPMayStore,
92 SDNPMayLoad]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000093
94def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
Chris Lattnerc90ee9c2008-01-10 07:59:24 +000095 [SDNPHasChain, SDNPOutFlag, SDNPSideEffect]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000096
97def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
98def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
99
100def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
101 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
102def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
103
104def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
105 [SDNPHasChain]>;
106
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000107def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
108 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000109
110//===----------------------------------------------------------------------===//
111// X86 Operand Definitions.
112//
113
114// *mem - Operand definitions for the funky X86 addressing mode operands.
115//
116class X86MemOperand<string printMethod> : Operand<iPTR> {
117 let PrintMethod = printMethod;
118 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
119}
120
121def i8mem : X86MemOperand<"printi8mem">;
122def i16mem : X86MemOperand<"printi16mem">;
123def i32mem : X86MemOperand<"printi32mem">;
124def i64mem : X86MemOperand<"printi64mem">;
125def i128mem : X86MemOperand<"printi128mem">;
126def f32mem : X86MemOperand<"printf32mem">;
127def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000128def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000129def f128mem : X86MemOperand<"printf128mem">;
130
131def lea32mem : Operand<i32> {
132 let PrintMethod = "printi32mem";
133 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
134}
135
136def SSECC : Operand<i8> {
137 let PrintMethod = "printSSECC";
138}
139
140def piclabel: Operand<i32> {
141 let PrintMethod = "printPICLabel";
142}
143
144// A couple of more descriptive operand definitions.
145// 16-bits but only 8 bits are significant.
146def i16i8imm : Operand<i16>;
147// 32-bits but only 8 bits are significant.
148def i32i8imm : Operand<i32>;
149
150// Branch targets have OtherVT type.
151def brtarget : Operand<OtherVT>;
152
153//===----------------------------------------------------------------------===//
154// X86 Complex Pattern Definitions.
155//
156
157// Define X86 specific addressing mode.
158def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
159def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
160 [add, mul, shl, or, frameindex], []>;
161
162//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000163// X86 Instruction Predicate Definitions.
164def HasMMX : Predicate<"Subtarget->hasMMX()">;
165def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
166def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
167def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
168def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000169def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
170def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
172def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Evan Cheng09e13792007-08-01 23:45:51 +0000173def HasLow4G : Predicate<"Subtarget->hasLow4GUserSpaceAddress()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000174def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
175def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
176def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
177
178//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000179// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000180//
181
Evan Cheng86ab7d32007-07-31 08:04:03 +0000182include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000183
184//===----------------------------------------------------------------------===//
185// Pattern fragments...
186//
187
188// X86 specific condition code. These correspond to CondCode in
189// X86InstrInfo.h. They must be kept in synch.
190def X86_COND_A : PatLeaf<(i8 0)>;
191def X86_COND_AE : PatLeaf<(i8 1)>;
192def X86_COND_B : PatLeaf<(i8 2)>;
193def X86_COND_BE : PatLeaf<(i8 3)>;
194def X86_COND_E : PatLeaf<(i8 4)>;
195def X86_COND_G : PatLeaf<(i8 5)>;
196def X86_COND_GE : PatLeaf<(i8 6)>;
197def X86_COND_L : PatLeaf<(i8 7)>;
198def X86_COND_LE : PatLeaf<(i8 8)>;
199def X86_COND_NE : PatLeaf<(i8 9)>;
200def X86_COND_NO : PatLeaf<(i8 10)>;
201def X86_COND_NP : PatLeaf<(i8 11)>;
202def X86_COND_NS : PatLeaf<(i8 12)>;
203def X86_COND_O : PatLeaf<(i8 13)>;
204def X86_COND_P : PatLeaf<(i8 14)>;
205def X86_COND_S : PatLeaf<(i8 15)>;
206
207def i16immSExt8 : PatLeaf<(i16 imm), [{
208 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
209 // sign extended field.
210 return (int16_t)N->getValue() == (int8_t)N->getValue();
211}]>;
212
213def i32immSExt8 : PatLeaf<(i32 imm), [{
214 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
215 // sign extended field.
216 return (int32_t)N->getValue() == (int8_t)N->getValue();
217}]>;
218
219// Helper fragments for loads.
220def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
221def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
222def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
223def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
224
225def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
226def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000227def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000228
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000229def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
230def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
231def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
232
233def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
234def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
235def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
236def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
237def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
238def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
239
240def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
241def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
242def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
243def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
244def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
245def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
246
247//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000248// Instruction list...
249//
250
251// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
252// a stack adjustment and the codegen must know that they may modify the stack
253// pointer before prolog-epilog rewriting occurs.
Evan Chenge4f1f572007-09-28 01:35:02 +0000254// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become sub / add
Evan Cheng037364a2007-09-28 01:19:48 +0000255// which can clobber EFLAGS.
256let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Bill Wendling22f8deb2007-11-13 00:44:25 +0000257def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt),
258 "#ADJCALLSTACKDOWN",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000259 [(X86callseq_start imm:$amt)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000260def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000261 "#ADJCALLSTACKUP",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000262 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
263}
Evan Chenge399fbb2007-12-12 23:12:09 +0000264let isImplicitDef = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000265def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266 "#IMPLICIT_DEF $dst",
267 [(set GR8:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000268def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269 "#IMPLICIT_DEF $dst",
270 [(set GR16:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000271def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272 "#IMPLICIT_DEF $dst",
273 [(set GR32:$dst, (undef))]>;
Evan Chenge399fbb2007-12-12 23:12:09 +0000274}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275
276// Nop
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000277let neverHasSideEffects = 1 in
278 def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000279
Evan Cheng0729ccf2008-01-05 00:41:47 +0000280// PIC base
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000281let neverHasSideEffects = 1, isNotDuplicable = 1 in
282 def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins piclabel:$label),
283 "call\t$label\n\tpop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284
285//===----------------------------------------------------------------------===//
286// Control Flow Instructions...
287//
288
289// Return instructions.
290let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +0000291 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000292 def RET : I<0xC3, RawFrm, (outs), (ins), "ret", [(X86retflag 0)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000293 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt), "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294 [(X86retflag imm:$amt)]>;
295}
296
297// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000298let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000299 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
300 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000301
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000302let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000303 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304
Owen Andersonf8053082007-11-12 07:39:39 +0000305// Indirect branches
306let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000307 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000308 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000309 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000310 [(brind (loadi32 addr:$dst))]>;
311}
312
313// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000314let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000315def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000316 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000317def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000318 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000319def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000320 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000321def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000322 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000323def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000324 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000325def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000326 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327
Dan Gohman91888f02007-07-31 20:11:57 +0000328def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000329 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000330def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000331 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000332def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000333 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000334def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000335 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000336
Dan Gohman91888f02007-07-31 20:11:57 +0000337def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000338 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000339def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000340 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000341def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000342 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000343def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000344 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000345def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000346 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000347def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000348 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000349} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000350
351//===----------------------------------------------------------------------===//
352// Call Instructions...
353//
Evan Cheng37e7c752007-07-21 00:34:19 +0000354let isCall = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000355 // All calls clobber the non-callee saved registers...
356 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
357 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng950aac02007-09-25 01:57:46 +0000358 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS] in {
Evan Cheng34f93712007-12-22 02:26:46 +0000359 def CALLpcrel32 : Ii32<0xE8, RawFrm, (outs), (ins i32imm:$dst,variable_ops),
360 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000361 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000362 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000363 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000364 "call\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365 }
366
367// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000368
369def TAILCALL : I<0, Pseudo, (outs), (ins ),
370 "#TAILCALL",
371 []>;
372
Evan Cheng37e7c752007-07-21 00:34:19 +0000373let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000374def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset),
375 "#TC_RETURN $dst $offset",
376 []>;
377
378let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
379def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset),
380 "#TC_RETURN $dst $offset",
381 []>;
382
383let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
384 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000386let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000387 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
388 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000389let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000390 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000391 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000392
393//===----------------------------------------------------------------------===//
394// Miscellaneous Instructions...
395//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000396let Defs = [EBP, ESP], Uses = [EBP, ESP], mayLoad = 1, neverHasSideEffects=1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000397def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000398 (outs), (ins), "leave", []>;
399
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000400let Defs = [ESP], Uses = [ESP], neverHasSideEffects=1 in {
401let mayLoad = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000402def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000403
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000404let mayStore = 1 in
Evan Chengd8434332007-09-26 01:29:06 +0000405def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000406}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000408let Defs = [ESP, EFLAGS], Uses = [ESP], mayLoad = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000409def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000410let Defs = [ESP], Uses = [ESP, EFLAGS], mayStore = 1, neverHasSideEffects=1 in
Evan Chengf1341312007-09-26 21:28:00 +0000411def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000412
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413let isTwoAddress = 1 in // GR32 = bswap GR32
414 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000415 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000416 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
418
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000419
Evan Cheng48679f42007-12-14 02:13:44 +0000420// Bit scan instructions.
421let Defs = [EFLAGS] in {
Evan Cheng4e33de92007-12-14 18:49:43 +0000422def BSF16rr : I<0xBC, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000423 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000424 [(set GR16:$dst, (X86bsf GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000425def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000426 "bsf{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000427 [(set GR16:$dst, (X86bsf (loadi16 addr:$src))),
428 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000429def BSF32rr : I<0xBC, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000430 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000431 [(set GR32:$dst, (X86bsf GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000432def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000433 "bsf{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000434 [(set GR32:$dst, (X86bsf (loadi32 addr:$src))),
435 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000436
Evan Cheng4e33de92007-12-14 18:49:43 +0000437def BSR16rr : I<0xBD, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000438 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000439 [(set GR16:$dst, (X86bsr GR16:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000440def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000441 "bsr{w}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000442 [(set GR16:$dst, (X86bsr (loadi16 addr:$src))),
443 (implicit EFLAGS)]>, TB;
Evan Cheng4e33de92007-12-14 18:49:43 +0000444def BSR32rr : I<0xBD, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000445 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000446 [(set GR32:$dst, (X86bsr GR32:$src)), (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000447def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohmancdb54c62007-12-14 15:10:00 +0000448 "bsr{l}\t{$src, $dst|$dst, $src}",
Evan Cheng7cfbfe32007-12-14 08:30:15 +0000449 [(set GR32:$dst, (X86bsr (loadi32 addr:$src))),
450 (implicit EFLAGS)]>, TB;
Evan Cheng48679f42007-12-14 02:13:44 +0000451} // Defs = [EFLAGS]
452
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000453let neverHasSideEffects = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000454def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000455 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000456 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000457def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000458 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000459 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
461
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000462let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000463def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000464 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000465def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000466 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000467def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000468 [(X86rep_movs i32)]>, REP;
469}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000470
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000471let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000472def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000473 [(X86rep_stos i8)]>, REP;
474let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000475def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000476 [(X86rep_stos i16)]>, REP, OpSize;
477let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000478def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000479 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000480
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000481let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000482def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000483 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000484
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000485let isBarrier = 1, hasCtrlDep = 1 in {
Chris Lattner56b941f2008-01-15 21:58:22 +0000486def TRAP : I<0x0B, RawFrm, (outs), (ins), "ud2", [(trap)]>, TB;
Anton Korobeynikov39d40ba2008-01-15 07:02:33 +0000487}
488
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000489//===----------------------------------------------------------------------===//
490// Input/Output Instructions...
491//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000492let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000493def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000494 "in{b}\t{%dx, %al|%AL, %DX}", []>;
495let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000496def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000497 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
498let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000499def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000500 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000502let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000503def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000504 "in{b}\t{$port, %al|%AL, $port}", []>;
505let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000506def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000507 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
508let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000509def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000510 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000511
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000512let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000513def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000514 "out{b}\t{%al, %dx|%DX, %AL}", []>;
515let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000516def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000517 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
518let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000519def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000520 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000521
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000522let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000523def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000524 "out{b}\t{%al, $port|$port, %AL}", []>;
525let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000526def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000527 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
528let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000529def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000530 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000531
532//===----------------------------------------------------------------------===//
533// Move Instructions...
534//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000535let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000536def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000537 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000538def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000539 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000540def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000541 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000542}
Chris Lattner17dab4a2008-01-10 05:45:39 +0000543let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000544def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000545 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000546 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000547def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000548 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000549 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000550def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000551 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000552 [(set GR32:$dst, imm:$src)]>;
553}
Evan Chengb783fa32007-07-19 01:14:50 +0000554def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000555 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000557def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000558 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000560def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000561 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000562 [(store (i32 imm:$src), addr:$dst)]>;
563
Chris Lattner1a1932c2008-01-06 23:38:27 +0000564let isSimpleLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000565def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000566 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000567 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000568def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000569 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000571def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000572 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000574}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575
Evan Chengb783fa32007-07-19 01:14:50 +0000576def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000577 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000578 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000579def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000580 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000581 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000582def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000583 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 [(store GR32:$src, addr:$dst)]>;
585
586//===----------------------------------------------------------------------===//
587// Fixed-Register Multiplication and Division Instructions...
588//
589
590// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000591let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000592def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000593 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
594 // This probably ought to be moved to a def : Pat<> if the
595 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000596 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000597let Defs = [AX,DX,EFLAGS], Uses = [AX], neverHasSideEffects = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000598def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000599 OpSize; // AX,DX = AX*GR16
Chris Lattnerc7e96e72008-01-11 07:18:17 +0000600let Defs = [EAX,EDX,EFLAGS], Uses = [EAX], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000601def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
602 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000603let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000604def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000605 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000606 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
607 // This probably ought to be moved to a def : Pat<> if the
608 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000609 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000610let mayLoad = 1, neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000611let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000612def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000613 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng55687072007-09-14 21:48:26 +0000614let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000615def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000616 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000617}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000618
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000619let neverHasSideEffects = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000620let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000621def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
622 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000623let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000624def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000625 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000626let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000627def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
628 // EAX,EDX = EAX*GR32
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000629let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000630let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000631def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000632 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000633let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000634def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000635 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
636let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000637def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000638 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000639}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000640
641// unsigned division/remainder
Evan Cheng55687072007-09-14 21:48:26 +0000642let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000643def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000644 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000645let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000646def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000647 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000648let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000649def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000650 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000651let mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000652let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000653def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000654 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000655let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000656def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000657 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000658let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000659def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000660 "div{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000661}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662
663// Signed division/remainder.
Evan Cheng55687072007-09-14 21:48:26 +0000664let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000665def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000666 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000667let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000668def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000669 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000670let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000671def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000672 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000673let mayLoad = 1, mayLoad = 1 in {
Evan Cheng55687072007-09-14 21:48:26 +0000674let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000675def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000676 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000677let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000678def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000679 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000680let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000681def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000682 "idiv{l}\t$src", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000683}
684} // neverHasSideEffects
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000685
686//===----------------------------------------------------------------------===//
Chris Lattnerc90ee9c2008-01-10 07:59:24 +0000687// Two address Instructions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000688//
689let isTwoAddress = 1 in {
690
691// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000692let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000693let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000695 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000696 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000697 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000698 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000699 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000701 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000702 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000704 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706
707def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000708 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000709 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000711 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000714 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000715 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000717 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000720 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000721 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000723 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000724 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000726 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000727 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000729 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000732 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000733 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000735 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000736 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000738 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000739 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000740 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000741 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000742 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000744 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000745 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000747 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000748 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000750 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000753 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000755def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000756 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000757 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000759 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000761def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000762 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000763 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000765 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000768 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000769 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000771 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000772 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000774 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000775 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000777 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000780 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000781 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000783 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000786 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000787 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000789 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000790 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000792 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000793 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000794 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000795 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000797def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000798 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000799 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000800 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000801 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000804 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000805 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000807 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000810 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000811 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000813 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000816 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000817 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000818 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000819 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000822 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000823 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000824 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000825 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000828 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000829 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000831 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000834 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000835 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000837 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000840 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000841 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000843 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000844 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000846 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000847 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000849 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000852 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000853 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000855 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000858 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000859 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000861 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000863} // isCommutable = 1
864
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000866 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000867 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000869 X86_COND_NP, EFLAGS))]>,
870 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000871
872def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
873 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
874 "cmovb\t{$src2, $dst|$dst, $src2}",
875 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
876 X86_COND_B, EFLAGS))]>,
877 TB, OpSize;
878def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
879 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
880 "cmovb\t{$src2, $dst|$dst, $src2}",
881 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
882 X86_COND_B, EFLAGS))]>,
883 TB;
884def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
885 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
886 "cmovae\t{$src2, $dst|$dst, $src2}",
887 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
888 X86_COND_AE, EFLAGS))]>,
889 TB, OpSize;
890def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
891 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
892 "cmovae\t{$src2, $dst|$dst, $src2}",
893 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
894 X86_COND_AE, EFLAGS))]>,
895 TB;
896def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
897 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
898 "cmove\t{$src2, $dst|$dst, $src2}",
899 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
900 X86_COND_E, EFLAGS))]>,
901 TB, OpSize;
902def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
903 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
904 "cmove\t{$src2, $dst|$dst, $src2}",
905 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
906 X86_COND_E, EFLAGS))]>,
907 TB;
908def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
909 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
910 "cmovne\t{$src2, $dst|$dst, $src2}",
911 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
912 X86_COND_NE, EFLAGS))]>,
913 TB, OpSize;
914def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
915 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
916 "cmovne\t{$src2, $dst|$dst, $src2}",
917 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
918 X86_COND_NE, EFLAGS))]>,
919 TB;
920def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
921 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
922 "cmovbe\t{$src2, $dst|$dst, $src2}",
923 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
924 X86_COND_BE, EFLAGS))]>,
925 TB, OpSize;
926def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
927 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
928 "cmovbe\t{$src2, $dst|$dst, $src2}",
929 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
930 X86_COND_BE, EFLAGS))]>,
931 TB;
932def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
933 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
934 "cmova\t{$src2, $dst|$dst, $src2}",
935 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
936 X86_COND_A, EFLAGS))]>,
937 TB, OpSize;
938def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
939 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
940 "cmova\t{$src2, $dst|$dst, $src2}",
941 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
942 X86_COND_A, EFLAGS))]>,
943 TB;
944def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
945 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
946 "cmovl\t{$src2, $dst|$dst, $src2}",
947 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
948 X86_COND_L, EFLAGS))]>,
949 TB, OpSize;
950def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
951 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
952 "cmovl\t{$src2, $dst|$dst, $src2}",
953 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
954 X86_COND_L, EFLAGS))]>,
955 TB;
956def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
957 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
958 "cmovge\t{$src2, $dst|$dst, $src2}",
959 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
960 X86_COND_GE, EFLAGS))]>,
961 TB, OpSize;
962def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
963 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
964 "cmovge\t{$src2, $dst|$dst, $src2}",
965 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
966 X86_COND_GE, EFLAGS))]>,
967 TB;
968def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
969 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
970 "cmovle\t{$src2, $dst|$dst, $src2}",
971 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
972 X86_COND_LE, EFLAGS))]>,
973 TB, OpSize;
974def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
975 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
976 "cmovle\t{$src2, $dst|$dst, $src2}",
977 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
978 X86_COND_LE, EFLAGS))]>,
979 TB;
980def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
981 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
982 "cmovg\t{$src2, $dst|$dst, $src2}",
983 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
984 X86_COND_G, EFLAGS))]>,
985 TB, OpSize;
986def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
987 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
988 "cmovg\t{$src2, $dst|$dst, $src2}",
989 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
990 X86_COND_G, EFLAGS))]>,
991 TB;
992def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
993 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
994 "cmovs\t{$src2, $dst|$dst, $src2}",
995 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
996 X86_COND_S, EFLAGS))]>,
997 TB, OpSize;
998def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
999 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1000 "cmovs\t{$src2, $dst|$dst, $src2}",
1001 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1002 X86_COND_S, EFLAGS))]>,
1003 TB;
1004def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1005 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1006 "cmovns\t{$src2, $dst|$dst, $src2}",
1007 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1008 X86_COND_NS, EFLAGS))]>,
1009 TB, OpSize;
1010def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1011 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1012 "cmovns\t{$src2, $dst|$dst, $src2}",
1013 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1014 X86_COND_NS, EFLAGS))]>,
1015 TB;
1016def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1017 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1018 "cmovp\t{$src2, $dst|$dst, $src2}",
1019 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1020 X86_COND_P, EFLAGS))]>,
1021 TB, OpSize;
1022def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1023 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1024 "cmovp\t{$src2, $dst|$dst, $src2}",
1025 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1026 X86_COND_P, EFLAGS))]>,
1027 TB;
1028def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1029 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1030 "cmovnp\t{$src2, $dst|$dst, $src2}",
1031 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1032 X86_COND_NP, EFLAGS))]>,
1033 TB, OpSize;
Evan Cheng950aac02007-09-25 01:57:46 +00001034} // Uses = [EFLAGS]
1035
1036
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037// unary instructions
1038let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001039let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001040def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001041 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001042def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001044def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 [(set GR32:$dst, (ineg GR32:$src))]>;
1046let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001047 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001049 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001051 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1053
1054}
Evan Cheng55687072007-09-14 21:48:26 +00001055} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056
Dan Gohman91888f02007-07-31 20:11:57 +00001057def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001059def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001061def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062 [(set GR32:$dst, (not GR32:$src))]>;
1063let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001064 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001066 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001068 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001069 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1070}
1071} // CodeSize
1072
1073// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001074let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001076def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 [(set GR8:$dst, (add GR8:$src, 1))]>;
1078let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001079def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001080 [(set GR16:$dst, (add GR16:$src, 1))]>,
1081 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001082def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1084}
1085let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001086 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001088 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001089 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1090 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001091 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001092 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1093 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094}
1095
1096let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001097def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 [(set GR8:$dst, (add GR8:$src, -1))]>;
1099let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001100def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001101 [(set GR16:$dst, (add GR16:$src, -1))]>,
1102 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001103def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1105}
1106
1107let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001108 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001110 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001111 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1112 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001113 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001114 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1115 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001116}
Evan Cheng55687072007-09-14 21:48:26 +00001117} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001118
1119// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001120let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1122def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001123 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001124 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001125 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1126def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001127 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001128 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1130def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001131 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001132 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1134}
1135
1136def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001137 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001138 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1140def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001141 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001142 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1144def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001145 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001146 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001147 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1148
1149def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001150 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001151 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1153def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001154 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001155 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1157def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001158 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001159 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1161def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001162 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001163 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1165 OpSize;
1166def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001167 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001168 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1170
1171let isTwoAddress = 0 in {
1172 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001173 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001174 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1176 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001177 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001178 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1180 OpSize;
1181 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001182 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001183 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1185 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001186 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001187 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1189 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001190 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001191 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001192 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1193 OpSize;
1194 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001195 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001196 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001197 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1198 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001199 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001200 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001201 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1202 OpSize;
1203 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001204 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001205 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1207}
1208
1209
1210let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001211def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001212 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001213 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001214def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001215 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001217def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001218 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001219 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1220}
Evan Chengb783fa32007-07-19 01:14:50 +00001221def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001222 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001224def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001225 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001226 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001227def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001228 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001229 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1230
Evan Chengb783fa32007-07-19 01:14:50 +00001231def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001232 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001234def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001235 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001237def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001238 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001239 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1240
Evan Chengb783fa32007-07-19 01:14:50 +00001241def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001242 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001244def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001245 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1247let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001248 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001249 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001250 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001251 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001252 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001254 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001255 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001257 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001258 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001260 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001261 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001262 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1263 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001264 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001265 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001267 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001268 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1270 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001271 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001272 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1274}
1275
1276
1277let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1278def XOR8rr : I<0x30, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001279 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1282def XOR16rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001283 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001284 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1286def XOR32rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001287 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001288 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1290}
1291
1292def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001293 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001294 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1296def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001297 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001298 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1300def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001301 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001302 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001303 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1304
1305def XOR8ri : Ii8<0x80, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001306 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001307 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1309def XOR16ri : Ii16<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001310 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001311 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001312 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1313def XOR32ri : Ii32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001314 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001315 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001316 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1317def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001318 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001319 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001320 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1321 OpSize;
1322def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001323 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001324 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1326let isTwoAddress = 0 in {
1327 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001328 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001329 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1331 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001332 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001333 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1335 OpSize;
1336 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001337 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001338 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1340 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001341 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001342 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001343 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1344 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001345 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001346 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001347 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1348 OpSize;
1349 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001350 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001351 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1353 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001354 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001355 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1357 OpSize;
1358 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001359 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001360 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1362}
Evan Cheng55687072007-09-14 21:48:26 +00001363} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364
1365// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001366let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001367let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001368def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001369 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001370 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001371def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001372 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001373 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001374def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001375 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001376 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1377}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378
Evan Chengb783fa32007-07-19 01:14:50 +00001379def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001380 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1382let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001383def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001384 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001385 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001386def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001387 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001388 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf4005a82008-01-11 18:00:50 +00001389// NOTE: We don't use shifts of a register by one, because 'add reg,reg' is
1390// cheaper.
Chris Lattnerc7e96e72008-01-11 07:18:17 +00001391}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001392
1393let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001394 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001395 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001396 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001397 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001398 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001399 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001400 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001401 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001402 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001403 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1404 }
Evan Chengb783fa32007-07-19 01:14:50 +00001405 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001406 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001407 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001408 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001409 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001410 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1411 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001412 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001413 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001414 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1415
1416 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001417 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001418 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001420 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001421 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1423 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001424 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1427}
1428
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001429let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001430def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001431 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001432 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001433def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001434 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001435 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001436def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001437 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001438 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1439}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440
Evan Chengb783fa32007-07-19 01:14:50 +00001441def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001442 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001443 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001444def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001445 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001446 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001447def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001448 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001449 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1450
1451// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001452def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001453 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001454 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001455def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001456 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001457 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001458def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001459 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001460 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1461
1462let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001463 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001464 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001465 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001466 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001467 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001468 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001469 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001470 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001471 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001472 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001473 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1474 }
Evan Chengb783fa32007-07-19 01:14:50 +00001475 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001476 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001477 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001478 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001479 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001480 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1481 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001482 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001483 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001484 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1485
1486 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001487 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001488 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001490 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001491 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001492 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001493 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001494 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001495 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1496}
1497
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001498let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001499def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001500 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001501 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001502def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001503 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001504 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001505def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001507 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1508}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001509
Evan Chengb783fa32007-07-19 01:14:50 +00001510def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001511 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001512 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001513def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001515 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1516 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001517def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001518 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001519 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1520
1521// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001522def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001523 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001525def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001526 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001527 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001528def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001529 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001530 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1531
1532let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001533 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001534 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001535 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001536 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001537 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001538 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001539 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001540 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001542 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1543 }
Evan Chengb783fa32007-07-19 01:14:50 +00001544 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001545 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001546 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001547 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001548 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001549 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1550 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001551 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001552 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001553 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1554
1555 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001556 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001557 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001558 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001559 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001560 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001561 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1562 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001563 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001564 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1566}
1567
1568// Rotate instructions
1569// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001570let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001571def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001572 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001573 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001574def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001575 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001576 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001577def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001578 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001579 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1580}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581
Evan Chengb783fa32007-07-19 01:14:50 +00001582def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001583 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001584 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001585def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001586 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001587 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001588def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001589 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001590 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1591
1592// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001593def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001594 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001596def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001597 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001598 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001599def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001600 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1602
1603let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001604 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001605 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001607 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001608 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001609 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001610 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001611 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001612 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001613 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1614 }
Evan Chengb783fa32007-07-19 01:14:50 +00001615 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001616 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001618 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001619 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1621 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001622 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001623 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001624 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1625
1626 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001627 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001629 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001630 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001631 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1633 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001634 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001635 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1637}
1638
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001639let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001640def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001642 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001643def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001644 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001645 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001646def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001648 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1649}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650
Evan Chengb783fa32007-07-19 01:14:50 +00001651def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001652 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001654def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001657def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1660
1661// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001662def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001664 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001665def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001666 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001668def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001669 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001670 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1671
1672let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001673 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001674 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001675 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001676 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001677 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001678 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001679 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001680 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001681 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001682 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1683 }
Evan Chengb783fa32007-07-19 01:14:50 +00001684 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001685 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001686 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001687 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001688 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001689 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1690 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001691 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001692 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001693 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1694
1695 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001696 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001698 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001699 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001700 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001701 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1702 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001703 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001704 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001705 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1706}
1707
1708
1709
1710// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001711let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001712def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001713 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001714 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001715def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001717 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001718def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001719 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001720 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001721 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001722def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001723 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001724 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001725 TB, OpSize;
1726}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727
1728let isCommutable = 1 in { // These instructions commute to each other.
1729def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001730 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001731 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001732 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1733 (i8 imm:$src3)))]>,
1734 TB;
1735def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001736 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001737 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1739 (i8 imm:$src3)))]>,
1740 TB;
1741def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001742 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001743 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001744 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1745 (i8 imm:$src3)))]>,
1746 TB, OpSize;
1747def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001748 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001749 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001750 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1751 (i8 imm:$src3)))]>,
1752 TB, OpSize;
1753}
1754
1755let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001756 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001757 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001758 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001759 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001760 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001761 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001762 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001763 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001764 addr:$dst)]>, TB;
1765 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001767 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001769 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1770 (i8 imm:$src3)), addr:$dst)]>,
1771 TB;
1772 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001773 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001774 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1776 (i8 imm:$src3)), addr:$dst)]>,
1777 TB;
1778
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001779 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001780 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001781 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001782 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001783 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001784 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001785 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001786 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001787 addr:$dst)]>, TB, OpSize;
1788 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001789 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001790 (outs), (ins i16mem:$dst, 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 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1793 (i8 imm:$src3)), addr:$dst)]>,
1794 TB, OpSize;
1795 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001796 (outs), (ins i16mem:$dst, 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 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1799 (i8 imm:$src3)), addr:$dst)]>,
1800 TB, OpSize;
1801}
Evan Cheng55687072007-09-14 21:48:26 +00001802} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803
1804
1805// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001806let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001807let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001808def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1809 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001810 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001811 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1812let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001813def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1814 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001815 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001817def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1818 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001819 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001820 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1821} // end isConvertibleToThreeAddress
1822} // end isCommutable
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001823def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1824 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001827def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1828 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001830 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1831def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1832 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001833 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001834 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1835
Evan Chengb783fa32007-07-19 01:14:50 +00001836def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001837 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001838 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1839
1840let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001841def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1842 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001843 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001844 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001845def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1846 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001847 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001848 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001849def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1850 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001851 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001852 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1853def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1854 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001855 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001856 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857}
1858
1859let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001860 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001863 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001864 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001865 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001866 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001867 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001868 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001870 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001873 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001874 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001875 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001876 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001877 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001880 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001881 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001882 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001883 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001884 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1887}
1888
Evan Cheng259471d2007-10-05 17:59:57 +00001889let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001890let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001891def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001892 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001893 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1894}
Evan Chengb783fa32007-07-19 01:14:50 +00001895def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001896 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001897 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001898def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001900 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001901def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1904
1905let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001906 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001909 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001910 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001911 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001912 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001913 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001914 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1915}
Evan Cheng259471d2007-10-05 17:59:57 +00001916} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001917
Evan Chengb783fa32007-07-19 01:14:50 +00001918def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001919 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001920 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001921def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001924def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001927def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001930def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001931 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001933def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001935 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1936
Evan Chengb783fa32007-07-19 01:14:50 +00001937def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001940def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001941 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001943def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001946def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001947 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001948 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng55687072007-09-14 21:48:26 +00001949 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001950def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001951 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001952 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1953let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001954 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001957 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001958 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001959 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001960 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001961 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001964 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001965 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001966 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001967 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001970 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001971 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001972 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001974 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001977 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001978 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1981}
1982
Evan Cheng259471d2007-10-05 17:59:57 +00001983let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001984def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001985 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00001986 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001987
1988let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001989 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001990 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001992 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001993 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001994 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001995 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001996 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001997 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001998 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001999 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002000 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001}
Evan Chengb783fa32007-07-19 01:14:50 +00002002def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002003 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002004 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002005def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002006 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002007 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002008def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002009 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002011} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002012} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002013
Evan Cheng55687072007-09-14 21:48:26 +00002014let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002016def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002017 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002018 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002019def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002020 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002021 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2022}
Evan Chengb783fa32007-07-19 01:14:50 +00002023def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002024 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002025 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2026 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002027def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002028 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002030} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002031} // end Two Address instructions
2032
2033// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002034let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002035def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002036 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002037 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002038 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2039def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002040 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002041 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002042 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2043def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002044 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2047 OpSize;
2048def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002049 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002050 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002051 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2052
2053def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002054 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002055 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002056 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2057 OpSize;
2058def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002059 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2062def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002063 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2066 OpSize;
2067def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002068 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00002071} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072
2073//===----------------------------------------------------------------------===//
2074// Test instructions are just like AND, except they don't generate a result.
2075//
Evan Cheng950aac02007-09-25 01:57:46 +00002076let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002078def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002079 "test{b}\t{$src2, $src1|$src1, $src2}",
2080 [(X86cmp (and GR8:$src1, GR8:$src2), 0),
2081 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002082def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002083 "test{w}\t{$src2, $src1|$src1, $src2}",
2084 [(X86cmp (and GR16:$src1, GR16:$src2), 0),
2085 (implicit EFLAGS)]>,
2086 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002087def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002088 "test{l}\t{$src2, $src1|$src1, $src2}",
2089 [(X86cmp (and GR32:$src1, GR32:$src2), 0),
2090 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002091}
2092
Evan Chengb783fa32007-07-19 01:14:50 +00002093def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002094 "test{b}\t{$src2, $src1|$src1, $src2}",
2095 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2096 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002097def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002098 "test{w}\t{$src2, $src1|$src1, $src2}",
2099 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2100 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002101def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002102 "test{l}\t{$src2, $src1|$src1, $src2}",
2103 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2104 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002105
2106def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002107 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002108 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002109 [(X86cmp (and GR8:$src1, imm:$src2), 0),
2110 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002111def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002112 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002113 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002114 [(X86cmp (and GR16:$src1, imm:$src2), 0),
2115 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002116def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002117 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002118 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002119 [(X86cmp (and GR32:$src1, imm:$src2), 0),
2120 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121
Evan Cheng621216e2007-09-29 00:00:36 +00002122def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002123 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002124 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002125 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2126 (implicit EFLAGS)]>;
2127def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002128 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002129 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002130 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2131 (implicit EFLAGS)]>, OpSize;
2132def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002133 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002134 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002135 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002136 (implicit EFLAGS)]>;
2137} // Defs = [EFLAGS]
2138
2139
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002140// Condition code ops, incl. set if equal/not equal/...
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002141let Defs = [EFLAGS], Uses = [AH], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002142def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002143let Defs = [AH], Uses = [EFLAGS], neverHasSideEffects = 1 in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002144def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002145
Evan Cheng950aac02007-09-25 01:57:46 +00002146let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002147def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002148 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002149 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002150 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002151 TB; // GR8 = ==
2152def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002153 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002155 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002156 TB; // [mem8] = ==
2157def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002158 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002160 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002161 TB; // GR8 = !=
2162def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002163 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002164 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002165 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002166 TB; // [mem8] = !=
2167def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002168 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002169 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002170 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002171 TB; // GR8 = < signed
2172def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002173 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002174 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002175 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002176 TB; // [mem8] = < signed
2177def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002178 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002179 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002180 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002181 TB; // GR8 = >= signed
2182def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002183 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002184 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002185 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 TB; // [mem8] = >= signed
2187def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002188 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002189 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002190 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002191 TB; // GR8 = <= signed
2192def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002193 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002194 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002195 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196 TB; // [mem8] = <= signed
2197def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002198 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002199 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002200 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002201 TB; // GR8 = > signed
2202def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002203 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002204 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002205 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206 TB; // [mem8] = > signed
2207
2208def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002209 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002210 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002211 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002212 TB; // GR8 = < unsign
2213def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002214 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002215 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002216 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002217 TB; // [mem8] = < unsign
2218def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002219 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002220 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002221 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002222 TB; // GR8 = >= unsign
2223def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002224 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002226 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002227 TB; // [mem8] = >= unsign
2228def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002229 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002230 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002231 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002232 TB; // GR8 = <= unsign
2233def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002234 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002235 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002236 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002237 TB; // [mem8] = <= unsign
2238def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002239 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002241 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002242 TB; // GR8 = > signed
2243def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002244 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002245 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002246 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002247 TB; // [mem8] = > signed
2248
2249def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002250 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002251 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002252 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002253 TB; // GR8 = <sign bit>
2254def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002255 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002257 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002258 TB; // [mem8] = <sign bit>
2259def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002260 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002261 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002262 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263 TB; // GR8 = !<sign bit>
2264def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002265 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002266 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002267 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002268 TB; // [mem8] = !<sign bit>
2269def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002270 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002271 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002272 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273 TB; // GR8 = parity
2274def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002275 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002276 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002277 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002278 TB; // [mem8] = parity
2279def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002280 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002281 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002282 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002283 TB; // GR8 = not parity
2284def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002285 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002287 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002288 TB; // [mem8] = not parity
Evan Cheng950aac02007-09-25 01:57:46 +00002289} // Uses = [EFLAGS]
2290
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002291
2292// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002293let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002294def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002295 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002296 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002297 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002298def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002299 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002300 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002301 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002302def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002303 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002304 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002305 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002306def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002307 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002308 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002309 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2310 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002311def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002312 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002313 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002314 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2315 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002316def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002317 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002318 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002319 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2320 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002321def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002322 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002323 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002324 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2325 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002326def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002327 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002328 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002329 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2330 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002331def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002332 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002334 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2335 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002336def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002337 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002338 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002339 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002340def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002341 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002342 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002343 [(X86cmp GR16:$src1, imm:$src2),
2344 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002345def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002346 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002347 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002348 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002349def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002350 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002351 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002352 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2353 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002354def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002355 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002356 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002357 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2358 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002359def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002360 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002361 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002362 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2363 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002364def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002365 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002366 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002367 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2368 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002369def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002370 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002372 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2373 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002374def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002375 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002376 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002377 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2378 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002379def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002380 (outs), (ins GR32:$src1, i32i8imm:$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, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002383 (implicit EFLAGS)]>;
2384} // Defs = [EFLAGS]
2385
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002386// Sign/Zero extenders
Evan Chengb783fa32007-07-19 01:14:50 +00002387def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002388 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002389 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002390def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002391 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002392 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002393def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002394 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002395 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002396def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002397 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002398 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002399def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002400 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002401 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002402def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002403 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002404 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2405
Evan Chengb783fa32007-07-19 01:14:50 +00002406def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002407 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002408 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002409def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002410 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002411 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002412def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002413 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002414 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002415def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002416 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002417 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002418def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002419 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002420 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002421def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002422 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002423 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2424
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002425let neverHasSideEffects = 1 in {
2426 let Defs = [AX], Uses = [AL] in
2427 def CBW : I<0x98, RawFrm, (outs), (ins),
2428 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2429 let Defs = [EAX], Uses = [AX] in
2430 def CWDE : I<0x98, RawFrm, (outs), (ins),
2431 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002432
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002433 let Defs = [AX,DX], Uses = [AX] in
2434 def CWD : I<0x99, RawFrm, (outs), (ins),
2435 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2436 let Defs = [EAX,EDX], Uses = [EAX] in
2437 def CDQ : I<0x99, RawFrm, (outs), (ins),
2438 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
2439}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002440
2441//===----------------------------------------------------------------------===//
2442// Alias Instructions
2443//===----------------------------------------------------------------------===//
2444
2445// Alias instructions that map movr0 to xor.
2446// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Chris Lattner17dab4a2008-01-10 05:45:39 +00002447let Defs = [EFLAGS], isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002448def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002449 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002450 [(set GR8:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002451def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002452 "xor{w}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002453 [(set GR16:$dst, 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002454def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002455 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002456 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002457}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002458
2459// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2460// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002461let neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002462def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002463 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002464def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002465 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002466
Evan Chengb783fa32007-07-19 01:14:50 +00002467def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002468 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002469def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002470 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002471} // neverHasSideEffects
2472
2473let isSimpleLoad = 1, mayLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002474def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002475 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002476def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002477 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002478}
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002479let mayStore = 1, neverHasSideEffects = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002480def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002481 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002482def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002483 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Chris Lattnerc90ee9c2008-01-10 07:59:24 +00002484}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002485
2486//===----------------------------------------------------------------------===//
2487// Thread Local Storage Instructions
2488//
2489
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002490let Uses = [EBX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002491def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
Dan Gohman91888f02007-07-31 20:11:57 +00002492 "leal\t${sym:mem}(,%ebx,1), $dst",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002493 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002494
2495let AddedComplexity = 10 in
Evan Chengb783fa32007-07-19 01:14:50 +00002496def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002497 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002498 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2499
2500let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002501def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002502 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002503 [(set GR32:$dst,
2504 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2505
Evan Chengb783fa32007-07-19 01:14:50 +00002506def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002507 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002508 [(set GR32:$dst, X86TLStp)]>;
2509
2510//===----------------------------------------------------------------------===//
2511// DWARF Pseudo Instructions
2512//
2513
Evan Chengb783fa32007-07-19 01:14:50 +00002514def DWARF_LOC : I<0, Pseudo, (outs),
2515 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002516 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002517 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2518 (i32 imm:$file))]>;
2519
2520//===----------------------------------------------------------------------===//
2521// EH Pseudo Instructions
2522//
2523let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002524 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002525def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002526 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002527 [(X86ehret GR32:$addr)]>;
2528
2529}
2530
2531//===----------------------------------------------------------------------===//
2532// Non-Instruction Patterns
2533//===----------------------------------------------------------------------===//
2534
2535// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2536def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2537def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2538def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2539def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2540def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2541
2542def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2543 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2544def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2545 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2546def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2547 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2548def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2549 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2550
2551def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2552 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2553def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2554 (MOV32mi addr:$dst, texternalsym:$src)>;
2555
2556// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002557// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002558def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002559 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002560
2561def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002562 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002563def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002564 (TAILCALL)>;
2565
2566def : Pat<(X86tcret GR32:$dst, imm:$off),
2567 (TCRETURNri GR32:$dst, imm:$off)>;
2568
2569def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2570 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2571
2572def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2573 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002574
2575def : Pat<(X86call (i32 tglobaladdr:$dst)),
2576 (CALLpcrel32 tglobaladdr:$dst)>;
2577def : Pat<(X86call (i32 texternalsym:$dst)),
2578 (CALLpcrel32 texternalsym:$dst)>;
2579
2580// X86 specific add which produces a flag.
2581def : Pat<(addc GR32:$src1, GR32:$src2),
2582 (ADD32rr GR32:$src1, GR32:$src2)>;
2583def : Pat<(addc GR32:$src1, (load addr:$src2)),
2584 (ADD32rm GR32:$src1, addr:$src2)>;
2585def : Pat<(addc GR32:$src1, imm:$src2),
2586 (ADD32ri GR32:$src1, imm:$src2)>;
2587def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2588 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2589
2590def : Pat<(subc GR32:$src1, GR32:$src2),
2591 (SUB32rr GR32:$src1, GR32:$src2)>;
2592def : Pat<(subc GR32:$src1, (load addr:$src2)),
2593 (SUB32rm GR32:$src1, addr:$src2)>;
2594def : Pat<(subc GR32:$src1, imm:$src2),
2595 (SUB32ri GR32:$src1, imm:$src2)>;
2596def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2597 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2598
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002599// Comparisons.
2600
2601// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00002602def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002603 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002604def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002605 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002606def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002607 (TEST32rr GR32:$src1, GR32:$src1)>;
2608
Duncan Sands082524c2008-01-23 20:39:46 +00002609// zextload bool -> zextload byte
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002610def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2611def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2612def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2613
2614// extload bool -> extload byte
2615def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2616def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2617def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2618def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2619def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2620def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2621
2622// anyext -> zext
2623def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2624def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2625def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2626def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2627def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2628def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2629
Evan Chengf2abee72007-12-13 00:43:27 +00002630// (and (i32 load), 255) -> (zextload i8)
2631def : Pat<(i32 (and (loadi32 addr:$src), (i32 255))), (MOVZX32rm8 addr:$src)>;
2632def : Pat<(i32 (and (loadi32 addr:$src), (i32 65535))),(MOVZX32rm16 addr:$src)>;
2633
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002634//===----------------------------------------------------------------------===//
2635// Some peepholes
2636//===----------------------------------------------------------------------===//
2637
2638// (shl x, 1) ==> (add x, x)
2639def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2640def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2641def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2642
2643// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2644def : Pat<(or (srl GR32:$src1, CL:$amt),
2645 (shl GR32:$src2, (sub 32, CL:$amt))),
2646 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2647
2648def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2649 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2650 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2651
2652// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2653def : Pat<(or (shl GR32:$src1, CL:$amt),
2654 (srl GR32:$src2, (sub 32, CL:$amt))),
2655 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2656
2657def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2658 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2659 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2660
2661// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2662def : Pat<(or (srl GR16:$src1, CL:$amt),
2663 (shl GR16:$src2, (sub 16, CL:$amt))),
2664 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2665
2666def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2667 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2668 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2669
2670// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2671def : Pat<(or (shl GR16:$src1, CL:$amt),
2672 (srl GR16:$src2, (sub 16, CL:$amt))),
2673 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2674
2675def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2676 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2677 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2678
2679
2680//===----------------------------------------------------------------------===//
2681// Floating Point Stack Support
2682//===----------------------------------------------------------------------===//
2683
2684include "X86InstrFPStack.td"
2685
2686//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00002687// X86-64 Support
2688//===----------------------------------------------------------------------===//
2689
Chris Lattner2de8d2b2008-01-10 05:50:42 +00002690include "X86Instr64bit.td"
Evan Cheng86ab7d32007-07-31 08:04:03 +00002691
2692//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002693// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2694//===----------------------------------------------------------------------===//
2695
2696include "X86InstrMMX.td"
2697
2698//===----------------------------------------------------------------------===//
2699// XMM Floating point support (requires SSE / SSE2)
2700//===----------------------------------------------------------------------===//
2701
2702include "X86InstrSSE.td"