blob: 28ef8388a90162d307984fa2a9a0c4f61d06ba09 [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//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
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,
89 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
90def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
91 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
92
93def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
94 [SDNPHasChain, SDNPOutFlag]>;
95
96def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
97def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
98
99def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
100 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
101def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
102
103def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
104 [SDNPHasChain]>;
105
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000106def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
107 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000108
109//===----------------------------------------------------------------------===//
110// X86 Operand Definitions.
111//
112
113// *mem - Operand definitions for the funky X86 addressing mode operands.
114//
115class X86MemOperand<string printMethod> : Operand<iPTR> {
116 let PrintMethod = printMethod;
117 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
118}
119
120def i8mem : X86MemOperand<"printi8mem">;
121def i16mem : X86MemOperand<"printi16mem">;
122def i32mem : X86MemOperand<"printi32mem">;
123def i64mem : X86MemOperand<"printi64mem">;
124def i128mem : X86MemOperand<"printi128mem">;
125def f32mem : X86MemOperand<"printf32mem">;
126def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000127def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000128def f128mem : X86MemOperand<"printf128mem">;
129
130def lea32mem : Operand<i32> {
131 let PrintMethod = "printi32mem";
132 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
133}
134
135def SSECC : Operand<i8> {
136 let PrintMethod = "printSSECC";
137}
138
139def piclabel: Operand<i32> {
140 let PrintMethod = "printPICLabel";
141}
142
143// A couple of more descriptive operand definitions.
144// 16-bits but only 8 bits are significant.
145def i16i8imm : Operand<i16>;
146// 32-bits but only 8 bits are significant.
147def i32i8imm : Operand<i32>;
148
149// Branch targets have OtherVT type.
150def brtarget : Operand<OtherVT>;
151
152//===----------------------------------------------------------------------===//
153// X86 Complex Pattern Definitions.
154//
155
156// Define X86 specific addressing mode.
157def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
158def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
159 [add, mul, shl, or, frameindex], []>;
160
161//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000162// X86 Instruction Predicate Definitions.
163def HasMMX : Predicate<"Subtarget->hasMMX()">;
164def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
165def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
166def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
167def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000168def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
169def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000170def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
171def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Evan Cheng09e13792007-08-01 23:45:51 +0000172def HasLow4G : Predicate<"Subtarget->hasLow4GUserSpaceAddress()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
174def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
175def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
176
177//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000178// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179//
180
Evan Cheng86ab7d32007-07-31 08:04:03 +0000181include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000182
183//===----------------------------------------------------------------------===//
184// Pattern fragments...
185//
186
187// X86 specific condition code. These correspond to CondCode in
188// X86InstrInfo.h. They must be kept in synch.
189def X86_COND_A : PatLeaf<(i8 0)>;
190def X86_COND_AE : PatLeaf<(i8 1)>;
191def X86_COND_B : PatLeaf<(i8 2)>;
192def X86_COND_BE : PatLeaf<(i8 3)>;
193def X86_COND_E : PatLeaf<(i8 4)>;
194def X86_COND_G : PatLeaf<(i8 5)>;
195def X86_COND_GE : PatLeaf<(i8 6)>;
196def X86_COND_L : PatLeaf<(i8 7)>;
197def X86_COND_LE : PatLeaf<(i8 8)>;
198def X86_COND_NE : PatLeaf<(i8 9)>;
199def X86_COND_NO : PatLeaf<(i8 10)>;
200def X86_COND_NP : PatLeaf<(i8 11)>;
201def X86_COND_NS : PatLeaf<(i8 12)>;
202def X86_COND_O : PatLeaf<(i8 13)>;
203def X86_COND_P : PatLeaf<(i8 14)>;
204def X86_COND_S : PatLeaf<(i8 15)>;
205
206def i16immSExt8 : PatLeaf<(i16 imm), [{
207 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
208 // sign extended field.
209 return (int16_t)N->getValue() == (int8_t)N->getValue();
210}]>;
211
212def i32immSExt8 : PatLeaf<(i32 imm), [{
213 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
214 // sign extended field.
215 return (int32_t)N->getValue() == (int8_t)N->getValue();
216}]>;
217
218// Helper fragments for loads.
219def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
220def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
221def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
222def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
223
224def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
225def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000226def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000227
228def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
229def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
230def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
231def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
232def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
233
234def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
235def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
236def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
237def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
238def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
239def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
240
241def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
242def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
243def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
244def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
245def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
246def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
247
248//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000249// Instruction list...
250//
251
252// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
253// a stack adjustment and the codegen must know that they may modify the stack
254// pointer before prolog-epilog rewriting occurs.
Evan Chenge4f1f572007-09-28 01:35:02 +0000255// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become sub / add
Evan Cheng037364a2007-09-28 01:19:48 +0000256// which can clobber EFLAGS.
257let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Bill Wendling22f8deb2007-11-13 00:44:25 +0000258def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt),
259 "#ADJCALLSTACKDOWN",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000260 [(X86callseq_start imm:$amt)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000261def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262 "#ADJCALLSTACKUP",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000263 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
264}
Evan Chengb783fa32007-07-19 01:14:50 +0000265def IMPLICIT_USE : I<0, Pseudo, (outs), (ins variable_ops),
266 "#IMPLICIT_USE", []>;
Evan Chenge399fbb2007-12-12 23:12:09 +0000267let isImplicitDef = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000268def IMPLICIT_DEF : I<0, Pseudo, (outs variable_ops), (ins),
269 "#IMPLICIT_DEF", []>;
270def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271 "#IMPLICIT_DEF $dst",
272 [(set GR8:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000273def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274 "#IMPLICIT_DEF $dst",
275 [(set GR16:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000276def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000277 "#IMPLICIT_DEF $dst",
278 [(set GR32:$dst, (undef))]>;
Evan Chenge399fbb2007-12-12 23:12:09 +0000279}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280
281// Nop
Evan Chengb783fa32007-07-19 01:14:50 +0000282def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000283
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 Chengb783fa32007-07-19 01:14:50 +0000359 def CALLpcrel32 : I<0xE8, RawFrm, (outs), (ins i32imm:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000360 "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//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000396let Defs = [EBP, ESP], Uses = [EBP, ESP] 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
400let Defs = [ESP], Uses = [ESP] in {
Evan Chengd8434332007-09-26 01:29:06 +0000401def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000402
Evan Chengd8434332007-09-26 01:29:06 +0000403def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000404}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405
Evan Chengd8434332007-09-26 01:29:06 +0000406let Defs = [ESP, EFLAGS], Uses = [ESP] in
Evan Chengf1341312007-09-26 21:28:00 +0000407def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000408let Defs = [ESP], Uses = [ESP, EFLAGS] in
Evan Chengf1341312007-09-26 21:28:00 +0000409def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000410
Evan Chengb783fa32007-07-19 01:14:50 +0000411def MovePCtoStack : I<0, Pseudo, (outs), (ins piclabel:$label),
Dan Gohman91888f02007-07-31 20:11:57 +0000412 "call\t$label", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413
414let isTwoAddress = 1 in // GR32 = bswap GR32
415 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000416 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000417 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000418 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
419
Evan Chengb783fa32007-07-19 01:14:50 +0000420// FIXME: Model xchg* as two address instructions?
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000421def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
Evan Chengb783fa32007-07-19 01:14:50 +0000422 (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000423 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000425 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000426 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000427def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000428 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000429 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000430
431def XCHG8mr : I<0x86, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000432 (outs), (ins i8mem:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000433 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434def XCHG16mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000435 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000436 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000437def XCHG32mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000438 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000439 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000440def XCHG8rm : I<0x86, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000441 (outs), (ins GR8:$src1, i8mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000442 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000443def XCHG16rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000444 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000445 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446def XCHG32rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000447 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000448 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000449
Evan Cheng48679f42007-12-14 02:13:44 +0000450// Bit scan instructions.
451let Defs = [EFLAGS] in {
452def BSF16rr : I<0xBC, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
453 "bsf{w}\t{$src, $dst||$dst, $src}",
454 [(set GR16:$dst, (X86bsf GR16:$src))]>, TB;
455def BSF16rm : I<0xBC, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
456 "bsf{w}\t{$src, $dst||$dst, $src}",
457 [(set GR16:$dst, (X86bsf (loadi16 addr:$src)))]>, TB;
458def BSF32rr : I<0xBC, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
459 "bsf{l}\t{$src, $dst||$dst, $src}",
460 [(set GR32:$dst, (X86bsf GR32:$src))]>, TB;
461def BSF32rm : I<0xBC, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
462 "bsf{l}\t{$src, $dst||$dst, $src}",
463 [(set GR32:$dst, (X86bsf (loadi32 addr:$src)))]>, TB;
464
465def BSR16rr : I<0xBD, AddRegFrm, (outs GR16:$dst), (ins GR16:$src),
466 "bsr{w}\t{$src, $dst||$dst, $src}",
467 [(set GR16:$dst, (X86bsr GR16:$src))]>, TB;
468def BSR16rm : I<0xBD, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
469 "bsr{w}\t{$src, $dst||$dst, $src}",
470 [(set GR16:$dst, (X86bsr (loadi16 addr:$src)))]>, TB;
471def BSR32rr : I<0xBD, AddRegFrm, (outs GR32:$dst), (ins GR32:$src),
472 "bsr{l}\t{$src, $dst||$dst, $src}",
473 [(set GR32:$dst, (X86bsr GR32:$src))]>, TB;
474def BSR32rm : I<0xBD, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
475 "bsr{l}\t{$src, $dst||$dst, $src}",
476 [(set GR32:$dst, (X86bsr (loadi32 addr:$src)))]>, TB;
477} // Defs = [EFLAGS]
478
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000479def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000480 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000481 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000482def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000483 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000484 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
486
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000487let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000488def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000489 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000490def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000491 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000492def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000493 [(X86rep_movs i32)]>, REP;
494}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000495
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000496let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000497def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000498 [(X86rep_stos i8)]>, REP;
499let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000500def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000501 [(X86rep_stos i16)]>, REP, OpSize;
502let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000503def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000504 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000505
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000506let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000507def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000508 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509
510//===----------------------------------------------------------------------===//
511// Input/Output Instructions...
512//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000513let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000514def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000515 "in{b}\t{%dx, %al|%AL, %DX}", []>;
516let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000517def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000518 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
519let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000520def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000521 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000523let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000524def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000525 "in{b}\t{$port, %al|%AL, $port}", []>;
526let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000527def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000528 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
529let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000530def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000531 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000533let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000534def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000535 "out{b}\t{%al, %dx|%DX, %AL}", []>;
536let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000537def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000538 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
539let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000540def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000541 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000543let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000544def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000545 "out{b}\t{%al, $port|$port, %AL}", []>;
546let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000547def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000548 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
549let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000550def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000551 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000552
553//===----------------------------------------------------------------------===//
554// Move Instructions...
555//
Evan Chengb783fa32007-07-19 01:14:50 +0000556def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000557 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000558def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000559 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000560def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000561 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000562let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000563def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000564 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000565 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000566def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000567 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000569def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000570 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000571 [(set GR32:$dst, imm:$src)]>;
572}
Evan Chengb783fa32007-07-19 01:14:50 +0000573def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000574 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000576def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000577 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000578 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000579def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000580 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000581 [(store (i32 imm:$src), addr:$dst)]>;
582
Evan Cheng4e84e452007-08-30 05:49:43 +0000583let isLoad = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000584def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000585 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000586 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000587def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000588 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000589 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000590def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000591 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000593}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594
Evan Chengb783fa32007-07-19 01:14:50 +0000595def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000596 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000597 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000598def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000599 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000601def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000602 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000603 [(store GR32:$src, addr:$dst)]>;
604
605//===----------------------------------------------------------------------===//
606// Fixed-Register Multiplication and Division Instructions...
607//
608
609// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000610let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000611def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
613 // This probably ought to be moved to a def : Pat<> if the
614 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000615 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000616let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000617def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000618 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000619let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000620def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
621 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000622let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000623def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000624 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
626 // This probably ought to be moved to a def : Pat<> if the
627 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000628 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000629let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000630def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000631 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng55687072007-09-14 21:48:26 +0000632let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000633def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000634 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635
Evan Cheng55687072007-09-14 21:48:26 +0000636let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000637def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
638 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000639let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000640def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000641 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000642let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000643def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
644 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000645let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000646def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000647 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000648let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000649def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000650 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
651let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000652def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000653 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000654
655// unsigned division/remainder
Evan Cheng55687072007-09-14 21:48:26 +0000656let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000657def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000658 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000659let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000660def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000661 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000662let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000663def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000664 "div{l}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000665let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000666def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000667 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000668let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000669def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000670 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000671let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000672def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000673 "div{l}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000674
675// Signed division/remainder.
Evan Cheng55687072007-09-14 21:48:26 +0000676let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000677def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000678 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000679let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000680def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000681 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000682let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000683def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000684 "idiv{l}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000685let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000686def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000687 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000688let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000689def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000690 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000691let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000692def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000693 "idiv{l}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000694
695
696//===----------------------------------------------------------------------===//
697// Two address Instructions...
698//
699let isTwoAddress = 1 in {
700
701// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000702let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000703let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000704def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000705 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000706 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000707 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000708 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000711 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000712 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000714 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000715 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716
717def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000718 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000719 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000721 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000722 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000724 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000725 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000726 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000727 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000730 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000731 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000732 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000733 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000736 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000737 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000738 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000739 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000740 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000742 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000743 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000744 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000745 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000748 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000749 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000750 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000751 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000754 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000755 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000757 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000760 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000761 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000763 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000766 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000767 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000769 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000772 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000773 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000775 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000778 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000779 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000781 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000784 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000785 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000787 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000790 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000791 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000793 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000794 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000796 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000797 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000799 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000800 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000802 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000803 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000805 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000808 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000809 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000811 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000814 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000815 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000817 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000818 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000820 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000821 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000822 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000823 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000824 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000826 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000829 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000831def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000832 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000833 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000835 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000838 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000839 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000841 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000844 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000845 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000847 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000849def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000850 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000851 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000853 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000856 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000857 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000859 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000862 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000863 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000865 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000868 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000869 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000871 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000872 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000873} // isCommutable = 1
874
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000876 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000877 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000878 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000879 X86_COND_NP, EFLAGS))]>,
880 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000881
882def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
883 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
884 "cmovb\t{$src2, $dst|$dst, $src2}",
885 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
886 X86_COND_B, EFLAGS))]>,
887 TB, OpSize;
888def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
889 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
890 "cmovb\t{$src2, $dst|$dst, $src2}",
891 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
892 X86_COND_B, EFLAGS))]>,
893 TB;
894def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
895 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
896 "cmovae\t{$src2, $dst|$dst, $src2}",
897 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
898 X86_COND_AE, EFLAGS))]>,
899 TB, OpSize;
900def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
901 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
902 "cmovae\t{$src2, $dst|$dst, $src2}",
903 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
904 X86_COND_AE, EFLAGS))]>,
905 TB;
906def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
907 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
908 "cmove\t{$src2, $dst|$dst, $src2}",
909 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
910 X86_COND_E, EFLAGS))]>,
911 TB, OpSize;
912def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
913 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
914 "cmove\t{$src2, $dst|$dst, $src2}",
915 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
916 X86_COND_E, EFLAGS))]>,
917 TB;
918def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
919 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
920 "cmovne\t{$src2, $dst|$dst, $src2}",
921 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
922 X86_COND_NE, EFLAGS))]>,
923 TB, OpSize;
924def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
925 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
926 "cmovne\t{$src2, $dst|$dst, $src2}",
927 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
928 X86_COND_NE, EFLAGS))]>,
929 TB;
930def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
931 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
932 "cmovbe\t{$src2, $dst|$dst, $src2}",
933 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
934 X86_COND_BE, EFLAGS))]>,
935 TB, OpSize;
936def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
937 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
938 "cmovbe\t{$src2, $dst|$dst, $src2}",
939 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
940 X86_COND_BE, EFLAGS))]>,
941 TB;
942def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
943 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
944 "cmova\t{$src2, $dst|$dst, $src2}",
945 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
946 X86_COND_A, EFLAGS))]>,
947 TB, OpSize;
948def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
949 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
950 "cmova\t{$src2, $dst|$dst, $src2}",
951 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
952 X86_COND_A, EFLAGS))]>,
953 TB;
954def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
955 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
956 "cmovl\t{$src2, $dst|$dst, $src2}",
957 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
958 X86_COND_L, EFLAGS))]>,
959 TB, OpSize;
960def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
961 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
962 "cmovl\t{$src2, $dst|$dst, $src2}",
963 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
964 X86_COND_L, EFLAGS))]>,
965 TB;
966def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
967 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
968 "cmovge\t{$src2, $dst|$dst, $src2}",
969 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
970 X86_COND_GE, EFLAGS))]>,
971 TB, OpSize;
972def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
973 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
974 "cmovge\t{$src2, $dst|$dst, $src2}",
975 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
976 X86_COND_GE, EFLAGS))]>,
977 TB;
978def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
979 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
980 "cmovle\t{$src2, $dst|$dst, $src2}",
981 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
982 X86_COND_LE, EFLAGS))]>,
983 TB, OpSize;
984def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
985 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
986 "cmovle\t{$src2, $dst|$dst, $src2}",
987 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
988 X86_COND_LE, EFLAGS))]>,
989 TB;
990def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
991 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
992 "cmovg\t{$src2, $dst|$dst, $src2}",
993 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
994 X86_COND_G, EFLAGS))]>,
995 TB, OpSize;
996def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
997 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
998 "cmovg\t{$src2, $dst|$dst, $src2}",
999 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1000 X86_COND_G, EFLAGS))]>,
1001 TB;
1002def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
1003 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1004 "cmovs\t{$src2, $dst|$dst, $src2}",
1005 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1006 X86_COND_S, EFLAGS))]>,
1007 TB, OpSize;
1008def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
1009 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1010 "cmovs\t{$src2, $dst|$dst, $src2}",
1011 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1012 X86_COND_S, EFLAGS))]>,
1013 TB;
1014def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
1015 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1016 "cmovns\t{$src2, $dst|$dst, $src2}",
1017 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1018 X86_COND_NS, EFLAGS))]>,
1019 TB, OpSize;
1020def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
1021 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1022 "cmovns\t{$src2, $dst|$dst, $src2}",
1023 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1024 X86_COND_NS, EFLAGS))]>,
1025 TB;
1026def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
1027 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1028 "cmovp\t{$src2, $dst|$dst, $src2}",
1029 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1030 X86_COND_P, EFLAGS))]>,
1031 TB, OpSize;
1032def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1033 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1034 "cmovp\t{$src2, $dst|$dst, $src2}",
1035 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1036 X86_COND_P, EFLAGS))]>,
1037 TB;
1038def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1039 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1040 "cmovnp\t{$src2, $dst|$dst, $src2}",
1041 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1042 X86_COND_NP, EFLAGS))]>,
1043 TB, OpSize;
Evan Cheng950aac02007-09-25 01:57:46 +00001044} // Uses = [EFLAGS]
1045
1046
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047// unary instructions
1048let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001049let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001050def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001051 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001052def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001054def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055 [(set GR32:$dst, (ineg GR32:$src))]>;
1056let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001057 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001059 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001061 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1063
1064}
Evan Cheng55687072007-09-14 21:48:26 +00001065} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001066
Dan Gohman91888f02007-07-31 20:11:57 +00001067def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001069def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001071def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072 [(set GR32:$dst, (not GR32:$src))]>;
1073let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001074 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001076 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001078 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1080}
1081} // CodeSize
1082
1083// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001084let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001086def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 [(set GR8:$dst, (add GR8:$src, 1))]>;
1088let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001089def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090 [(set GR16:$dst, (add GR16:$src, 1))]>,
1091 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001092def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1094}
1095let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001096 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001097 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001098 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001099 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1100 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001101 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001102 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1103 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104}
1105
1106let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001107def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108 [(set GR8:$dst, (add GR8:$src, -1))]>;
1109let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001110def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111 [(set GR16:$dst, (add GR16:$src, -1))]>,
1112 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001113def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001114 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1115}
1116
1117let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001118 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001120 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001121 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1122 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001123 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001124 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1125 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126}
Evan Cheng55687072007-09-14 21:48:26 +00001127} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001128
1129// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001130let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001131let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1132def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001133 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001134 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1136def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001137 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001138 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001139 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1140def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001141 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001142 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1144}
1145
1146def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001147 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001148 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001149 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1150def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001151 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001152 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1154def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001155 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001156 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001157 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1158
1159def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001160 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001161 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1163def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001164 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001165 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1167def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001168 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001169 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1171def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001172 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001173 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1175 OpSize;
1176def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001177 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001178 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1180
1181let isTwoAddress = 0 in {
1182 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001183 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001184 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1186 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001187 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001188 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001189 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1190 OpSize;
1191 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001192 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001193 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1195 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001196 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001197 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1199 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001200 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001201 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1203 OpSize;
1204 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001205 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001206 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1208 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001209 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001210 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1212 OpSize;
1213 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001214 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001215 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1217}
1218
1219
1220let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001221def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$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, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001224def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$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, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001227def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$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, GR32:$src2))]>;
1230}
Evan Chengb783fa32007-07-19 01:14:50 +00001231def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$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, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001234def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$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, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001237def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$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, (load addr:$src2)))]>;
1240
Evan Chengb783fa32007-07-19 01:14:50 +00001241def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001242 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001244def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001245 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001247def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001248 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1250
Evan Chengb783fa32007-07-19 01:14:50 +00001251def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001252 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001253 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001254def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001255 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1257let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001258 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001259 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001261 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001264 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$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 (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001267 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001268 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001270 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001271 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1273 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001274 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001275 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001277 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001278 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1280 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001281 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001282 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1284}
1285
1286
1287let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1288def XOR8rr : I<0x30, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001289 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001290 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1292def XOR16rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001293 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001294 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1296def XOR32rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001297 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001298 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1300}
1301
1302def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001303 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001304 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1306def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001307 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001308 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001309 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1310def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001311 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001312 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1314
1315def XOR8ri : Ii8<0x80, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001316 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001317 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001318 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1319def XOR16ri : Ii16<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001320 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001321 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1323def XOR32ri : Ii32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001324 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001325 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001326 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1327def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001328 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001329 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1331 OpSize;
1332def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001333 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001334 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1336let isTwoAddress = 0 in {
1337 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001338 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001339 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1341 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001342 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001343 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001344 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1345 OpSize;
1346 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001347 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001348 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1350 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001351 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001352 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001353 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1354 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001355 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001356 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001357 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1358 OpSize;
1359 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001360 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001361 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1363 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001364 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001365 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001366 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1367 OpSize;
1368 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001369 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001370 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1372}
Evan Cheng55687072007-09-14 21:48:26 +00001373} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374
1375// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001376let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001377let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001378def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001379 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001380 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001381def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001382 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001383 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001384def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001385 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001386 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1387}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001388
Evan Chengb783fa32007-07-19 01:14:50 +00001389def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001390 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001391 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1392let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001393def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001394 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001396def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001397 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001398 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1399}
1400
1401// Shift left by one. Not used because (add x, x) is slightly cheaper.
Evan Chengb783fa32007-07-19 01:14:50 +00001402def SHL8r1 : I<0xD0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001403 "shl{b}\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001404def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001405 "shl{w}\t$dst", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001406def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001407 "shl{l}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408
1409let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001410 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001411 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001412 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001413 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001414 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001415 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001416 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001417 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001418 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001419 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1420 }
Evan Chengb783fa32007-07-19 01:14:50 +00001421 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001422 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001423 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001424 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1427 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001428 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001429 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001430 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1431
1432 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001433 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001434 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001435 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001436 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001437 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1439 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001440 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001441 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1443}
1444
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001445let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001446def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001447 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001448 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001449def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001451 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001452def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001453 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001454 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1455}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001456
Evan Chengb783fa32007-07-19 01:14:50 +00001457def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001459 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001460def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001461 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001462 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001463def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001465 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1466
1467// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001468def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001470 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001471def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001472 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001474def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001475 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1477
1478let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001479 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001480 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001482 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001483 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001484 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001485 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001486 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001487 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001488 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001489 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1490 }
Evan Chengb783fa32007-07-19 01:14:50 +00001491 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001492 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001493 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001494 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001495 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001496 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1497 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001498 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001499 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001500 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1501
1502 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001503 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001504 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001506 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001507 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001508 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001509 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001510 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1512}
1513
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001514let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001515def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001516 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001517 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001518def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001519 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001520 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001521def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001522 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001523 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1524}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525
Evan Chengb783fa32007-07-19 01:14:50 +00001526def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001527 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001529def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001530 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001531 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1532 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001533def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001534 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001535 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1536
1537// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001538def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001539 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001541def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001544def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001545 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001546 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1547
1548let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001549 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001550 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001552 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001553 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001554 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001555 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001556 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001557 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001558 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1559 }
Evan Chengb783fa32007-07-19 01:14:50 +00001560 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001561 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001562 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001563 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001564 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1566 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001567 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001568 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1570
1571 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001572 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001573 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001574 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001575 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001576 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001577 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1578 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001579 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001580 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1582}
1583
1584// Rotate instructions
1585// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001586let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001587def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001588 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001589 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001590def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001591 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001592 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001593def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001594 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001595 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1596}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001597
Evan Chengb783fa32007-07-19 01:14:50 +00001598def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001599 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001601def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001604def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001605 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001606 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1607
1608// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001609def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001610 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001611 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001612def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001613 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001615def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001616 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1618
1619let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001620 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001621 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001622 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001623 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001624 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001625 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001626 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001627 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001629 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1630 }
Evan Chengb783fa32007-07-19 01:14:50 +00001631 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001632 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001633 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001634 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001635 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1637 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001638 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001639 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001640 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1641
1642 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001643 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001644 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001646 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1649 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001650 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001651 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001652 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1653}
1654
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001655let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001656def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001657 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001658 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001659def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001660 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001661 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001662def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001664 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1665}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001666
Evan Chengb783fa32007-07-19 01:14:50 +00001667def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001668 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001669 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001670def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001673def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001675 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1676
1677// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001678def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001679 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001680 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001681def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001682 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001683 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001684def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001685 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001686 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1687
1688let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001689 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001690 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001691 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001692 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001693 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001694 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001695 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001696 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001698 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1699 }
Evan Chengb783fa32007-07-19 01:14:50 +00001700 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001701 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001702 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001703 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001704 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001705 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1706 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001707 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001709 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1710
1711 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001712 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001713 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001714 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001715 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1718 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001719 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1722}
1723
1724
1725
1726// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001727let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001728def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001730 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001731def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001732 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001733 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001734def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001736 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001737 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001738def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001739 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001741 TB, OpSize;
1742}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001743
1744let isCommutable = 1 in { // These instructions commute to each other.
1745def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001746 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001747 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001748 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1749 (i8 imm:$src3)))]>,
1750 TB;
1751def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001752 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001753 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001754 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1755 (i8 imm:$src3)))]>,
1756 TB;
1757def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001758 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001760 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1761 (i8 imm:$src3)))]>,
1762 TB, OpSize;
1763def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001764 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001765 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1767 (i8 imm:$src3)))]>,
1768 TB, OpSize;
1769}
1770
1771let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001772 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001773 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001774 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001776 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001777 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001780 addr:$dst)]>, TB;
1781 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001782 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001783 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001784 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001785 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1786 (i8 imm:$src3)), addr:$dst)]>,
1787 TB;
1788 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001789 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001790 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001791 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1792 (i8 imm:$src3)), addr:$dst)]>,
1793 TB;
1794
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001795 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001796 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001799 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001800 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001801 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001803 addr:$dst)]>, TB, OpSize;
1804 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001805 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001806 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001808 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1809 (i8 imm:$src3)), addr:$dst)]>,
1810 TB, OpSize;
1811 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001812 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001814 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1815 (i8 imm:$src3)), addr:$dst)]>,
1816 TB, OpSize;
1817}
Evan Cheng55687072007-09-14 21:48:26 +00001818} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001819
1820
1821// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001822let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001824def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1825 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001826 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1828let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001829def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1830 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001833def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1834 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1837} // end isConvertibleToThreeAddress
1838} // end isCommutable
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001839def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1840 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001842 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001843def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1844 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001845 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001846 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1847def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1848 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001849 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001850 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1851
Evan Chengb783fa32007-07-19 01:14:50 +00001852def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001853 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1855
1856let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001857def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1858 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001861def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1862 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001865def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1866 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001868 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1869def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1870 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001872 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001873}
1874
1875let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001876 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001877 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001878 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001879 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001881 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001882 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001883 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001884 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001885 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001886 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001889 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001892 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001893 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001896 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001897 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001899 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001900 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1903}
1904
Evan Cheng259471d2007-10-05 17:59:57 +00001905let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001906let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001907def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1910}
Evan Chengb783fa32007-07-19 01:14:50 +00001911def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001914def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001915 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001916 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001917def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001919 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1920
1921let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001922 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001923 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001924 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001925 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001926 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001928 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001930 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1931}
Evan Cheng259471d2007-10-05 17:59:57 +00001932} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001933
Evan Chengb783fa32007-07-19 01:14:50 +00001934def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001935 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001936 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001937def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001940def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001941 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001943def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001946def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$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, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001949def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001950 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001951 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1952
Evan Chengb783fa32007-07-19 01:14:50 +00001953def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001954 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001955 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001956def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001959def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001960 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001962def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001963 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng55687072007-09-14 21:48:26 +00001965 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001966def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001967 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001968 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1969let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001970 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001971 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001973 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001974 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001976 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001977 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001978 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001979 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001980 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001981 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001982 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001983 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001984 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001985 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001986 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001987 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001988 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001989 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001990 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001991 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001993 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001994 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1997}
1998
Evan Cheng259471d2007-10-05 17:59:57 +00001999let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00002000def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002001 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002002 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002003
2004let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002005 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002006 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002007 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002008 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002009 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002011 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002012 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002013 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002014 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002015 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00002016 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002017}
Evan Chengb783fa32007-07-19 01:14:50 +00002018def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002019 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002020 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002021def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002024def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002025 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002026 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00002027} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00002028} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029
Evan Cheng55687072007-09-14 21:48:26 +00002030let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002031let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00002032def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002035def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002036 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002037 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2038}
Evan Chengb783fa32007-07-19 01:14:50 +00002039def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002040 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2042 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002043def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002044 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002045 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002046} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047} // end Two Address instructions
2048
2049// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002050let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002051def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002052 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002053 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002054 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2055def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002056 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002057 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002058 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2059def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002060 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002061 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002062 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2063 OpSize;
2064def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002065 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2068
2069def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002070 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002071 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2073 OpSize;
2074def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002075 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002076 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2078def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002079 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2082 OpSize;
2083def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002084 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002086 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00002087} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088
2089//===----------------------------------------------------------------------===//
2090// Test instructions are just like AND, except they don't generate a result.
2091//
Evan Cheng950aac02007-09-25 01:57:46 +00002092let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002093let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002094def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002095 "test{b}\t{$src2, $src1|$src1, $src2}",
2096 [(X86cmp (and GR8:$src1, GR8:$src2), 0),
2097 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002098def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002099 "test{w}\t{$src2, $src1|$src1, $src2}",
2100 [(X86cmp (and GR16:$src1, GR16:$src2), 0),
2101 (implicit EFLAGS)]>,
2102 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002103def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002104 "test{l}\t{$src2, $src1|$src1, $src2}",
2105 [(X86cmp (and GR32:$src1, GR32:$src2), 0),
2106 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107}
2108
Evan Chengb783fa32007-07-19 01:14:50 +00002109def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002110 "test{b}\t{$src2, $src1|$src1, $src2}",
2111 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2112 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002113def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002114 "test{w}\t{$src2, $src1|$src1, $src2}",
2115 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2116 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002117def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002118 "test{l}\t{$src2, $src1|$src1, $src2}",
2119 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2120 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121
2122def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002123 (outs), (ins GR8:$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 GR8:$src1, imm:$src2), 0),
2126 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002127def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002128 (outs), (ins GR16:$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 GR16:$src1, imm:$src2), 0),
2131 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002132def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002133 (outs), (ins GR32:$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 GR32:$src1, imm:$src2), 0),
2136 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137
Evan Cheng621216e2007-09-29 00:00:36 +00002138def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002139 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002140 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002141 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2142 (implicit EFLAGS)]>;
2143def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002144 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002145 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002146 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2147 (implicit EFLAGS)]>, OpSize;
2148def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002149 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002150 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002151 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002152 (implicit EFLAGS)]>;
2153} // Defs = [EFLAGS]
2154
2155
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002156// Condition code ops, incl. set if equal/not equal/...
Evan Cheng55687072007-09-14 21:48:26 +00002157let Defs = [EFLAGS], Uses = [AH] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002158def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Evan Cheng55687072007-09-14 21:48:26 +00002159let Defs = [AH], Uses = [EFLAGS] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002160def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002161
Evan Cheng950aac02007-09-25 01:57:46 +00002162let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002164 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002165 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002166 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167 TB; // GR8 = ==
2168def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002169 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002170 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002171 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002172 TB; // [mem8] = ==
2173def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002174 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002175 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002176 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002177 TB; // GR8 = !=
2178def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002179 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002180 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002181 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182 TB; // [mem8] = !=
2183def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002184 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002186 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002187 TB; // GR8 = < signed
2188def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002189 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002190 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002191 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002192 TB; // [mem8] = < signed
2193def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002194 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002195 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002196 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002197 TB; // GR8 = >= signed
2198def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002199 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002200 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002201 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202 TB; // [mem8] = >= signed
2203def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002204 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002205 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002206 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002207 TB; // GR8 = <= signed
2208def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002209 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002210 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002211 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002212 TB; // [mem8] = <= signed
2213def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002214 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002215 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002216 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002217 TB; // GR8 = > signed
2218def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002219 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002220 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002221 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002222 TB; // [mem8] = > signed
2223
2224def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002225 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002226 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002227 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002228 TB; // GR8 = < unsign
2229def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002230 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002231 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002232 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002233 TB; // [mem8] = < unsign
2234def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002235 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002236 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002237 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002238 TB; // GR8 = >= unsign
2239def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002240 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002241 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002242 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002243 TB; // [mem8] = >= unsign
2244def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002245 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002246 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002247 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002248 TB; // GR8 = <= unsign
2249def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002250 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002251 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002252 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002253 TB; // [mem8] = <= unsign
2254def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002255 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002257 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002258 TB; // GR8 = > signed
2259def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002260 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002261 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002262 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263 TB; // [mem8] = > signed
2264
2265def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002266 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002267 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002268 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269 TB; // GR8 = <sign bit>
2270def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002271 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002272 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002273 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002274 TB; // [mem8] = <sign bit>
2275def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002276 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002277 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002278 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002279 TB; // GR8 = !<sign bit>
2280def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002281 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002283 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002284 TB; // [mem8] = !<sign bit>
2285def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002286 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002287 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002288 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289 TB; // GR8 = parity
2290def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002291 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002292 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002293 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002294 TB; // [mem8] = parity
2295def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002296 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002297 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002298 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002299 TB; // GR8 = not parity
2300def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002301 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002302 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002303 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002304 TB; // [mem8] = not parity
Evan Cheng950aac02007-09-25 01:57:46 +00002305} // Uses = [EFLAGS]
2306
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002307
2308// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002309let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002310def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002311 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002312 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002313 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002314def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002315 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002316 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002317 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002318def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002319 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002320 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002321 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002323 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002324 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002325 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2326 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002328 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002329 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002330 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2331 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002332def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002333 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002334 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002335 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2336 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002337def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002338 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002340 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2341 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002342def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002343 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002344 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002345 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2346 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002347def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002348 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002350 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2351 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002352def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002353 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002354 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002355 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002357 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002358 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002359 [(X86cmp GR16:$src1, imm:$src2),
2360 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002361def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002362 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002363 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002364 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002365def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002366 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002367 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002368 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2369 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002370def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002371 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002372 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002373 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2374 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002375def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002376 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002377 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002378 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2379 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002380def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002381 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002382 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002383 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2384 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002385def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002386 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002387 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002388 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2389 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002390def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002391 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002392 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002393 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2394 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002395def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002396 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002397 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002398 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002399 (implicit EFLAGS)]>;
2400} // Defs = [EFLAGS]
2401
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002402// Sign/Zero extenders
Evan Chengb783fa32007-07-19 01:14:50 +00002403def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002404 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002405 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002406def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002407 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002408 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002409def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002410 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002411 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002412def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002413 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002414 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002415def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002416 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002417 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002418def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002419 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002420 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2421
Evan Chengb783fa32007-07-19 01:14:50 +00002422def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002423 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002424 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002425def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002426 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002427 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002428def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002429 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002430 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002431def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002432 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002433 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002434def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002435 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002436 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002437def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002438 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002439 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2440
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002441let Defs = [AX], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00002442def CBW : I<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002443 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2444let Defs = [EAX], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002445def CWDE : I<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002446 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002447
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002448let Defs = [AX,DX], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002449def CWD : I<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002450 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2451let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002452def CDQ : I<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002453 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002454
2455
2456//===----------------------------------------------------------------------===//
2457// Alias Instructions
2458//===----------------------------------------------------------------------===//
2459
2460// Alias instructions that map movr0 to xor.
2461// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Cheng55687072007-09-14 21:48:26 +00002462let Defs = [EFLAGS], isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002463def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002464 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002465 [(set GR8:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002466def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002467 "xor{w}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002468 [(set GR16:$dst, 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002469def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002470 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002471 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002472}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002473
2474// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2475// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengb783fa32007-07-19 01:14:50 +00002476def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002477 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002478def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002479 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002480
Evan Chengb783fa32007-07-19 01:14:50 +00002481def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002482 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002483def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002484 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002485let isLoad = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002486def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002487 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002488def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002489 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002490}
Evan Chengb783fa32007-07-19 01:14:50 +00002491def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002492 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002493def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002494 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002495
2496//===----------------------------------------------------------------------===//
2497// Thread Local Storage Instructions
2498//
2499
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002500let Uses = [EBX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002501def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
Dan Gohman91888f02007-07-31 20:11:57 +00002502 "leal\t${sym:mem}(,%ebx,1), $dst",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002503 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002504
2505let AddedComplexity = 10 in
Evan Chengb783fa32007-07-19 01:14:50 +00002506def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002507 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002508 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2509
2510let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002511def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002512 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002513 [(set GR32:$dst,
2514 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2515
Evan Chengb783fa32007-07-19 01:14:50 +00002516def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002517 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002518 [(set GR32:$dst, X86TLStp)]>;
2519
2520//===----------------------------------------------------------------------===//
2521// DWARF Pseudo Instructions
2522//
2523
Evan Chengb783fa32007-07-19 01:14:50 +00002524def DWARF_LOC : I<0, Pseudo, (outs),
2525 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002526 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002527 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2528 (i32 imm:$file))]>;
2529
2530//===----------------------------------------------------------------------===//
2531// EH Pseudo Instructions
2532//
2533let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002534 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002535def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002536 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002537 [(X86ehret GR32:$addr)]>;
2538
2539}
2540
2541//===----------------------------------------------------------------------===//
2542// Non-Instruction Patterns
2543//===----------------------------------------------------------------------===//
2544
2545// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2546def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2547def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2548def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2549def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2550def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2551
2552def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2553 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2554def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2555 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2556def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2557 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2558def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2559 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2560
2561def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2562 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2563def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2564 (MOV32mi addr:$dst, texternalsym:$src)>;
2565
2566// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002567// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002568def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002569 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002570
2571def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002572 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002573def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002574 (TAILCALL)>;
2575
2576def : Pat<(X86tcret GR32:$dst, imm:$off),
2577 (TCRETURNri GR32:$dst, imm:$off)>;
2578
2579def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2580 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2581
2582def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2583 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002584
2585def : Pat<(X86call (i32 tglobaladdr:$dst)),
2586 (CALLpcrel32 tglobaladdr:$dst)>;
2587def : Pat<(X86call (i32 texternalsym:$dst)),
2588 (CALLpcrel32 texternalsym:$dst)>;
2589
2590// X86 specific add which produces a flag.
2591def : Pat<(addc GR32:$src1, GR32:$src2),
2592 (ADD32rr GR32:$src1, GR32:$src2)>;
2593def : Pat<(addc GR32:$src1, (load addr:$src2)),
2594 (ADD32rm GR32:$src1, addr:$src2)>;
2595def : Pat<(addc GR32:$src1, imm:$src2),
2596 (ADD32ri GR32:$src1, imm:$src2)>;
2597def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2598 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2599
2600def : Pat<(subc GR32:$src1, GR32:$src2),
2601 (SUB32rr GR32:$src1, GR32:$src2)>;
2602def : Pat<(subc GR32:$src1, (load addr:$src2)),
2603 (SUB32rm GR32:$src1, addr:$src2)>;
2604def : Pat<(subc GR32:$src1, imm:$src2),
2605 (SUB32ri GR32:$src1, imm:$src2)>;
2606def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2607 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2608
2609def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2610 (MOV8mi addr:$dst, imm:$src)>;
2611def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2612 (MOV8mr addr:$dst, GR8:$src)>;
2613
2614// Comparisons.
2615
2616// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00002617def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002618 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002619def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002620 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002621def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002622 (TEST32rr GR32:$src1, GR32:$src1)>;
2623
2624// {s|z}extload bool -> {s|z}extload byte
2625def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2626def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2627def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2628def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2629def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2630
2631// extload bool -> extload byte
2632def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2633def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2634def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2635def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2636def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2637def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2638
2639// anyext -> zext
2640def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2641def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2642def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2643def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2644def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2645def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2646
Evan Chengf2abee72007-12-13 00:43:27 +00002647// (and (i32 load), 255) -> (zextload i8)
2648def : Pat<(i32 (and (loadi32 addr:$src), (i32 255))), (MOVZX32rm8 addr:$src)>;
2649def : Pat<(i32 (and (loadi32 addr:$src), (i32 65535))),(MOVZX32rm16 addr:$src)>;
2650
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002651//===----------------------------------------------------------------------===//
2652// Some peepholes
2653//===----------------------------------------------------------------------===//
2654
2655// (shl x, 1) ==> (add x, x)
2656def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2657def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2658def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2659
2660// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2661def : Pat<(or (srl GR32:$src1, CL:$amt),
2662 (shl GR32:$src2, (sub 32, CL:$amt))),
2663 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2664
2665def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2666 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2667 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2668
2669// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2670def : Pat<(or (shl GR32:$src1, CL:$amt),
2671 (srl GR32:$src2, (sub 32, CL:$amt))),
2672 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2673
2674def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2675 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2676 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2677
2678// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2679def : Pat<(or (srl GR16:$src1, CL:$amt),
2680 (shl GR16:$src2, (sub 16, CL:$amt))),
2681 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2682
2683def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2684 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2685 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2686
2687// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2688def : Pat<(or (shl GR16:$src1, CL:$amt),
2689 (srl GR16:$src2, (sub 16, CL:$amt))),
2690 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2691
2692def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2693 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2694 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2695
2696
2697//===----------------------------------------------------------------------===//
2698// Floating Point Stack Support
2699//===----------------------------------------------------------------------===//
2700
2701include "X86InstrFPStack.td"
2702
2703//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00002704// X86-64 Support
2705//===----------------------------------------------------------------------===//
2706
2707include "X86InstrX86-64.td"
2708
2709//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002710// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2711//===----------------------------------------------------------------------===//
2712
2713include "X86InstrMMX.td"
2714
2715//===----------------------------------------------------------------------===//
2716// XMM Floating point support (requires SSE / SSE2)
2717//===----------------------------------------------------------------------===//
2718
2719include "X86InstrSSE.td"