blob: 4168c1965d455bc590ed81b83ab7247ff8e308c8 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
2//
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
26def SDTX86Cmov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>]>;
29
30def SDTX86BrCond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>]>;
32
33def SDTX86SetCC : SDTypeProfile<1, 1,
34 [SDTCisVT<0, i8>, SDTCisVT<1, i8>]>;
35
36def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
37
38def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
39def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
40 SDTCisVT<1, i32> ]>;
41
42def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
43
44def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
45
46def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
47
48def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
49
50def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
51
52def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
53
54def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
55
56def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
57def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
58
59def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
60 [SDNPHasChain, SDNPOutFlag]>;
61
62def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
63 [SDNPInFlag, SDNPOutFlag]>;
64def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
65 [SDNPHasChain, SDNPInFlag]>;
66def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
67 [SDNPInFlag, SDNPOutFlag]>;
68
69def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
70 [SDNPHasChain, SDNPOptInFlag]>;
71
72def X86callseq_start :
73 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
74 [SDNPHasChain, SDNPOutFlag]>;
75def X86callseq_end :
76 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
77 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
78
79def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
80 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
81
82def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
83 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
84
85def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
86 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
87def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
89
90def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
91 [SDNPHasChain, SDNPOutFlag]>;
92
93def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
94def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
95
96def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
97 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
98def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
99
100def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
101 [SDNPHasChain]>;
102
103
104//===----------------------------------------------------------------------===//
105// X86 Operand Definitions.
106//
107
108// *mem - Operand definitions for the funky X86 addressing mode operands.
109//
110class X86MemOperand<string printMethod> : Operand<iPTR> {
111 let PrintMethod = printMethod;
112 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
113}
114
115def i8mem : X86MemOperand<"printi8mem">;
116def i16mem : X86MemOperand<"printi16mem">;
117def i32mem : X86MemOperand<"printi32mem">;
118def i64mem : X86MemOperand<"printi64mem">;
119def i128mem : X86MemOperand<"printi128mem">;
120def f32mem : X86MemOperand<"printf32mem">;
121def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000122def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123def f128mem : X86MemOperand<"printf128mem">;
124
125def lea32mem : Operand<i32> {
126 let PrintMethod = "printi32mem";
127 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
128}
129
130def SSECC : Operand<i8> {
131 let PrintMethod = "printSSECC";
132}
133
134def piclabel: Operand<i32> {
135 let PrintMethod = "printPICLabel";
136}
137
138// A couple of more descriptive operand definitions.
139// 16-bits but only 8 bits are significant.
140def i16i8imm : Operand<i16>;
141// 32-bits but only 8 bits are significant.
142def i32i8imm : Operand<i32>;
143
144// Branch targets have OtherVT type.
145def brtarget : Operand<OtherVT>;
146
147//===----------------------------------------------------------------------===//
148// X86 Complex Pattern Definitions.
149//
150
151// Define X86 specific addressing mode.
152def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
153def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
154 [add, mul, shl, or, frameindex], []>;
155
156//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000157// X86 Instruction Predicate Definitions.
158def HasMMX : Predicate<"Subtarget->hasMMX()">;
159def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
160def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
161def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
162def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
163def FPStack : Predicate<"!Subtarget->hasSSE2()">;
164def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
165def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Evan Cheng09e13792007-08-01 23:45:51 +0000166def HasLow4G : Predicate<"Subtarget->hasLow4GUserSpaceAddress()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
168def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
169def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
170
171//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000172// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173//
174
Evan Cheng86ab7d32007-07-31 08:04:03 +0000175include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176
177//===----------------------------------------------------------------------===//
178// Pattern fragments...
179//
180
181// X86 specific condition code. These correspond to CondCode in
182// X86InstrInfo.h. They must be kept in synch.
183def X86_COND_A : PatLeaf<(i8 0)>;
184def X86_COND_AE : PatLeaf<(i8 1)>;
185def X86_COND_B : PatLeaf<(i8 2)>;
186def X86_COND_BE : PatLeaf<(i8 3)>;
187def X86_COND_E : PatLeaf<(i8 4)>;
188def X86_COND_G : PatLeaf<(i8 5)>;
189def X86_COND_GE : PatLeaf<(i8 6)>;
190def X86_COND_L : PatLeaf<(i8 7)>;
191def X86_COND_LE : PatLeaf<(i8 8)>;
192def X86_COND_NE : PatLeaf<(i8 9)>;
193def X86_COND_NO : PatLeaf<(i8 10)>;
194def X86_COND_NP : PatLeaf<(i8 11)>;
195def X86_COND_NS : PatLeaf<(i8 12)>;
196def X86_COND_O : PatLeaf<(i8 13)>;
197def X86_COND_P : PatLeaf<(i8 14)>;
198def X86_COND_S : PatLeaf<(i8 15)>;
199
200def i16immSExt8 : PatLeaf<(i16 imm), [{
201 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
202 // sign extended field.
203 return (int16_t)N->getValue() == (int8_t)N->getValue();
204}]>;
205
206def i32immSExt8 : PatLeaf<(i32 imm), [{
207 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
208 // sign extended field.
209 return (int32_t)N->getValue() == (int8_t)N->getValue();
210}]>;
211
212// Helper fragments for loads.
213def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
214def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
215def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
216def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
217
218def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
219def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000220def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000221
222def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
223def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
224def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
225def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
226def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
227
228def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
229def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
230def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
231def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
232def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
233def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
234
235def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
236def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
237def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
238def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
239def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
240def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
241
242//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243// Instruction list...
244//
245
246// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
247// a stack adjustment and the codegen must know that they may modify the stack
248// pointer before prolog-epilog rewriting occurs.
Evan Chengb783fa32007-07-19 01:14:50 +0000249def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt), "#ADJCALLSTACKDOWN",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000250 [(X86callseq_start imm:$amt)]>, Imp<[ESP],[ESP]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000251def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000252 "#ADJCALLSTACKUP",
253 [(X86callseq_end imm:$amt1, imm:$amt2)]>,
254 Imp<[ESP],[ESP]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000255def IMPLICIT_USE : I<0, Pseudo, (outs), (ins variable_ops),
256 "#IMPLICIT_USE", []>;
257def IMPLICIT_DEF : I<0, Pseudo, (outs variable_ops), (ins),
258 "#IMPLICIT_DEF", []>;
259def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000260 "#IMPLICIT_DEF $dst",
261 [(set GR8:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000262def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263 "#IMPLICIT_DEF $dst",
264 [(set GR16:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000265def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266 "#IMPLICIT_DEF $dst",
267 [(set GR32:$dst, (undef))]>;
268
269// Nop
Evan Chengb783fa32007-07-19 01:14:50 +0000270def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272
273//===----------------------------------------------------------------------===//
274// Control Flow Instructions...
275//
276
277// Return instructions.
278let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +0000279 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000280 def RET : I<0xC3, RawFrm, (outs), (ins), "ret", [(X86retflag 0)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000281 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt), "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282 [(X86retflag imm:$amt)]>;
283}
284
285// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000286let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000287 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
288 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000289
290// Indirect branches
291let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000292 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000293
Evan Cheng37e7c752007-07-21 00:34:19 +0000294let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000295 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000296 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000297 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298 [(brind (loadi32 addr:$dst))]>;
299}
300
301// Conditional branches
Dan Gohman91888f02007-07-31 20:11:57 +0000302def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000303 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000304def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000306def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000308def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000310def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000312def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
314
Dan Gohman91888f02007-07-31 20:11:57 +0000315def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000317def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000319def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000321def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
323
Dan Gohman91888f02007-07-31 20:11:57 +0000324def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000326def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000328def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000330def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000332def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000334def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
336
337//===----------------------------------------------------------------------===//
338// Call Instructions...
339//
Evan Cheng37e7c752007-07-21 00:34:19 +0000340let isCall = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341 // All calls clobber the non-callee saved registers...
342 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
343 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
344 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000345 def CALLpcrel32 : I<0xE8, RawFrm, (outs), (ins i32imm:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000346 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000347 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000348 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000349 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000350 "call\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351 }
352
353// Tail call stuff.
Evan Cheng37e7c752007-07-21 00:34:19 +0000354let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000355 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAIL CALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000357let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000358 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp\t{*}$dst # TAIL CALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000359 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000360let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000361 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000362 "jmp\t{*}$dst # TAIL CALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000363
364//===----------------------------------------------------------------------===//
365// Miscellaneous Instructions...
366//
367def LEAVE : I<0xC9, RawFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000368 (outs), (ins), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369def POP32r : I<0x58, AddRegFrm,
Dan Gohman91888f02007-07-31 20:11:57 +0000370 (outs GR32:$reg), (ins), "pop{l}\t$reg", []>, Imp<[ESP],[ESP]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371
372def PUSH32r : I<0x50, AddRegFrm,
Dan Gohman91888f02007-07-31 20:11:57 +0000373 (outs), (ins GR32:$reg), "push{l}\t$reg", []>, Imp<[ESP],[ESP]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000374
Evan Chengb783fa32007-07-19 01:14:50 +0000375def MovePCtoStack : I<0, Pseudo, (outs), (ins piclabel:$label),
Dan Gohman91888f02007-07-31 20:11:57 +0000376 "call\t$label", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000377
378let isTwoAddress = 1 in // GR32 = bswap GR32
379 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000380 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000381 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
383
Evan Chengb783fa32007-07-19 01:14:50 +0000384// FIXME: Model xchg* as two address instructions?
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
Evan Chengb783fa32007-07-19 01:14:50 +0000386 (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000387 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000389 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000390 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000392 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000393 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394
395def XCHG8mr : I<0x86, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000396 (outs), (ins i8mem:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000397 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000398def XCHG16mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000399 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000400 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000401def XCHG32mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000402 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000403 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000404def XCHG8rm : I<0x86, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000405 (outs), (ins GR8:$src1, i8mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000406 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407def XCHG16rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000408 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000409 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410def XCHG32rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000411 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000412 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413
414def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000415 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000416 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000418 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000419 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
421
Evan Chengb783fa32007-07-19 01:14:50 +0000422def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423 [(X86rep_movs i8)]>,
424 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000425def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426 [(X86rep_movs i16)]>,
427 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000428def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000429 [(X86rep_movs i32)]>,
430 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
431
Evan Chengb783fa32007-07-19 01:14:50 +0000432def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000433 [(X86rep_stos i8)]>,
434 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000435def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436 [(X86rep_stos i16)]>,
437 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000438def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000439 [(X86rep_stos i32)]>,
440 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
441
Evan Chengb783fa32007-07-19 01:14:50 +0000442def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000443 TB, Imp<[],[RAX,RDX]>;
444
445//===----------------------------------------------------------------------===//
446// Input/Output Instructions...
447//
Evan Chengb783fa32007-07-19 01:14:50 +0000448def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000449 "in{b}\t{%dx, %al|%AL, %DX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000450 []>, Imp<[DX], [AL]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000451def IN16rr : I<0xED, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000452 "in{w}\t{%dx, %ax|%AX, %DX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453 []>, Imp<[DX], [AX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000454def IN32rr : I<0xED, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000455 "in{l}\t{%dx, %eax|%EAX, %DX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456 []>, Imp<[DX],[EAX]>;
457
Evan Chengb783fa32007-07-19 01:14:50 +0000458def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000459 "in{b}\t{$port, %al|%AL, $port}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460 []>,
461 Imp<[], [AL]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000462def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000463 "in{w}\t{$port, %ax|%AX, $port}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464 []>,
465 Imp<[], [AX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000466def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000467 "in{l}\t{$port, %eax|%EAX, $port}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468 []>,
469 Imp<[],[EAX]>;
470
Evan Chengb783fa32007-07-19 01:14:50 +0000471def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000472 "out{b}\t{%al, %dx|%DX, %AL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473 []>, Imp<[DX, AL], []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000474def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000475 "out{w}\t{%ax, %dx|%DX, %AX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476 []>, Imp<[DX, AX], []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000477def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000478 "out{l}\t{%eax, %dx|%DX, %EAX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000479 []>, Imp<[DX, EAX], []>;
480
Evan Chengb783fa32007-07-19 01:14:50 +0000481def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000482 "out{b}\t{%al, $port|$port, %AL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483 []>,
484 Imp<[AL], []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000485def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000486 "out{w}\t{%ax, $port|$port, %AX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000487 []>,
488 Imp<[AX], []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000489def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000490 "out{l}\t{%eax, $port|$port, %EAX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491 []>,
492 Imp<[EAX], []>;
493
494//===----------------------------------------------------------------------===//
495// Move Instructions...
496//
Evan Chengb783fa32007-07-19 01:14:50 +0000497def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000498 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000499def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000500 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000501def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000502 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000503let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000504def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000505 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000506 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000507def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000508 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000510def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000511 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512 [(set GR32:$dst, imm:$src)]>;
513}
Evan Chengb783fa32007-07-19 01:14:50 +0000514def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000515 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000517def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000518 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000520def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000521 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522 [(store (i32 imm:$src), addr:$dst)]>;
523
Evan Cheng4e84e452007-08-30 05:49:43 +0000524let isLoad = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000525def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000526 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000528def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000529 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000531def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000532 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000533 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000534}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535
Evan Chengb783fa32007-07-19 01:14:50 +0000536def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000537 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000538 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000539def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000540 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000541 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000542def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000543 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544 [(store GR32:$src, addr:$dst)]>;
545
546//===----------------------------------------------------------------------===//
547// Fixed-Register Multiplication and Division Instructions...
548//
549
550// Extra precision multiplication
Dan Gohman91888f02007-07-31 20:11:57 +0000551def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000552 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
553 // This probably ought to be moved to a def : Pat<> if the
554 // syntax can be accepted.
Evan Chengdec1dd12007-09-07 23:59:02 +0000555 [(set AL, (mul AL, GR8:$src))]>,
Evan Chenge3dc8a62007-08-01 20:22:37 +0000556 Imp<[AL],[AL,AH]>; // AL,AH = AL*GR8
Dan Gohman91888f02007-07-31 20:11:57 +0000557def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
Dan Gohman91888f02007-07-31 20:11:57 +0000559def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000560 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000561def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000562 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000563 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
564 // This probably ought to be moved to a def : Pat<> if the
565 // syntax can be accepted.
Evan Chengdec1dd12007-09-07 23:59:02 +0000566 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
Evan Cheng508fe8b2007-08-02 05:48:35 +0000567 Imp<[AL],[AL,AH]>; // AL,AH = AL*[mem8]
Evan Chengb783fa32007-07-19 01:14:50 +0000568def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000569 "mul{w}\t$src", []>, Imp<[AX],[AX,DX]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570 OpSize; // AX,DX = AX*[mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000571def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng508fe8b2007-08-02 05:48:35 +0000572 "mul{l}\t$src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573
Dan Gohman91888f02007-07-31 20:11:57 +0000574def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>,
Evan Cheng508fe8b2007-08-02 05:48:35 +0000575 Imp<[AL],[AL,AH]>; // AL,AH = AL*GR8
Dan Gohman91888f02007-07-31 20:11:57 +0000576def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
Dan Gohman91888f02007-07-31 20:11:57 +0000578def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000579 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000580def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng508fe8b2007-08-02 05:48:35 +0000581 "imul{b}\t$src", []>, Imp<[AL],[AL,AH]>; // AL,AH = AL*[mem8]
Evan Chengb783fa32007-07-19 01:14:50 +0000582def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000583 "imul{w}\t$src", []>, Imp<[AX],[AX,DX]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000584 OpSize; // AX,DX = AX*[mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000585def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000586 "imul{l}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000587 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
588
589// unsigned division/remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000590def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Dan Gohman91888f02007-07-31 20:11:57 +0000591 "div{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000592def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Dan Gohman91888f02007-07-31 20:11:57 +0000593 "div{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000594def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Dan Gohman91888f02007-07-31 20:11:57 +0000595 "div{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000596def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Dan Gohman91888f02007-07-31 20:11:57 +0000597 "div{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000598def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Dan Gohman91888f02007-07-31 20:11:57 +0000599 "div{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000600def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Dan Gohman91888f02007-07-31 20:11:57 +0000601 "div{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000602
603// Signed division/remainder.
Evan Chengb783fa32007-07-19 01:14:50 +0000604def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Dan Gohman91888f02007-07-31 20:11:57 +0000605 "idiv{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000606def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Dan Gohman91888f02007-07-31 20:11:57 +0000607 "idiv{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000608def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Dan Gohman91888f02007-07-31 20:11:57 +0000609 "idiv{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000610def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Dan Gohman91888f02007-07-31 20:11:57 +0000611 "idiv{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000612def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Dan Gohman91888f02007-07-31 20:11:57 +0000613 "idiv{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000614def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Dan Gohman91888f02007-07-31 20:11:57 +0000615 "idiv{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000616
617
618//===----------------------------------------------------------------------===//
619// Two address Instructions...
620//
621let isTwoAddress = 1 in {
622
623// Conditional moves
624def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000625 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000626 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000627 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
628 X86_COND_B))]>,
629 TB, OpSize;
630def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000631 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000632 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000633 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
634 X86_COND_B))]>,
635 TB, OpSize;
636def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000637 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000638 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000639 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
640 X86_COND_B))]>,
641 TB;
642def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000643 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000644 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000645 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
646 X86_COND_B))]>,
647 TB;
648
649def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000650 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000651 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000652 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
653 X86_COND_AE))]>,
654 TB, OpSize;
655def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000656 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000657 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
659 X86_COND_AE))]>,
660 TB, OpSize;
661def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000662 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000663 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000664 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
665 X86_COND_AE))]>,
666 TB;
667def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000668 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000669 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
671 X86_COND_AE))]>,
672 TB;
673
674def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000675 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000676 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
678 X86_COND_E))]>,
679 TB, OpSize;
680def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000681 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000682 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
684 X86_COND_E))]>,
685 TB, OpSize;
686def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000687 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000688 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000689 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
690 X86_COND_E))]>,
691 TB;
692def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000693 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000694 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000695 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
696 X86_COND_E))]>,
697 TB;
698
699def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000700 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000701 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
703 X86_COND_NE))]>,
704 TB, OpSize;
705def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000706 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000707 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
709 X86_COND_NE))]>,
710 TB, OpSize;
711def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000712 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000713 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
715 X86_COND_NE))]>,
716 TB;
717def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000718 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000719 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
721 X86_COND_NE))]>,
722 TB;
723
724def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000725 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000726 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000727 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
728 X86_COND_BE))]>,
729 TB, OpSize;
730def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000731 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000732 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000733 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
734 X86_COND_BE))]>,
735 TB, OpSize;
736def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000737 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000738 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000739 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
740 X86_COND_BE))]>,
741 TB;
742def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000743 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000744 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
746 X86_COND_BE))]>,
747 TB;
748
749def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000750 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
753 X86_COND_A))]>,
754 TB, OpSize;
755def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000756 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000757 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
759 X86_COND_A))]>,
760 TB, OpSize;
761def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000762 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000763 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
765 X86_COND_A))]>,
766 TB;
767def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000768 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000769 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
771 X86_COND_A))]>,
772 TB;
773
774def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000775 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000776 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
778 X86_COND_L))]>,
779 TB, OpSize;
780def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000781 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000782 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
784 X86_COND_L))]>,
785 TB, OpSize;
786def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000787 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000788 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
790 X86_COND_L))]>,
791 TB;
792def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000793 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000794 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
796 X86_COND_L))]>,
797 TB;
798
799def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000800 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000801 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
803 X86_COND_GE))]>,
804 TB, OpSize;
805def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000806 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000807 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
809 X86_COND_GE))]>,
810 TB, OpSize;
811def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000812 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000813 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
815 X86_COND_GE))]>,
816 TB;
817def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000818 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000819 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
821 X86_COND_GE))]>,
822 TB;
823
824def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000825 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000826 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
828 X86_COND_LE))]>,
829 TB, OpSize;
830def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000831 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000832 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
834 X86_COND_LE))]>,
835 TB, OpSize;
836def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000837 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000838 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
840 X86_COND_LE))]>,
841 TB;
842def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000843 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000844 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
846 X86_COND_LE))]>,
847 TB;
848
849def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000850 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000851 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
853 X86_COND_G))]>,
854 TB, OpSize;
855def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000856 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000857 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
859 X86_COND_G))]>,
860 TB, OpSize;
861def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000862 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000863 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
865 X86_COND_G))]>,
866 TB;
867def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000868 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000869 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
871 X86_COND_G))]>,
872 TB;
873
874def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000875 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000876 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
878 X86_COND_S))]>,
879 TB, OpSize;
880def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000881 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000882 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
884 X86_COND_S))]>,
885 TB, OpSize;
886def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000887 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000888 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
890 X86_COND_S))]>,
891 TB;
892def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000893 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000894 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
896 X86_COND_S))]>,
897 TB;
898
899def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000900 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000901 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
903 X86_COND_NS))]>,
904 TB, OpSize;
905def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000906 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000907 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000908 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
909 X86_COND_NS))]>,
910 TB, OpSize;
911def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000912 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000913 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
915 X86_COND_NS))]>,
916 TB;
917def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000918 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000919 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
921 X86_COND_NS))]>,
922 TB;
923
924def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000925 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000926 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
928 X86_COND_P))]>,
929 TB, OpSize;
930def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000931 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000932 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
934 X86_COND_P))]>,
935 TB, OpSize;
936def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000937 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
940 X86_COND_P))]>,
941 TB;
942def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000943 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000944 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
946 X86_COND_P))]>,
947 TB;
948
949def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000950 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000951 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
953 X86_COND_NP))]>,
954 TB, OpSize;
955def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000956 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000957 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
959 X86_COND_NP))]>,
960 TB, OpSize;
961def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000962 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000963 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
965 X86_COND_NP))]>,
966 TB;
967def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000968 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000969 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
971 X86_COND_NP))]>,
972 TB;
973
974
975// unary instructions
976let CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000977def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000979def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +0000981def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 [(set GR32:$dst, (ineg GR32:$src))]>;
983let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000984 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000986 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +0000988 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
990
991}
992
Dan Gohman91888f02007-07-31 20:11:57 +0000993def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000995def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +0000997def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 [(set GR32:$dst, (not GR32:$src))]>;
999let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001000 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001002 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001004 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1006}
1007} // CodeSize
1008
1009// TODO: inc/dec is slow for P4, but fast for Pentium-M.
1010let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001011def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012 [(set GR8:$dst, (add GR8:$src, 1))]>;
1013let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001014def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 [(set GR16:$dst, (add GR16:$src, 1))]>,
1016 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001017def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1019}
1020let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001021 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001023 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001025 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1027}
1028
1029let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001030def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031 [(set GR8:$dst, (add GR8:$src, -1))]>;
1032let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001033def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034 [(set GR16:$dst, (add GR16:$src, -1))]>,
1035 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001036def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1038}
1039
1040let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001041 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001043 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001045 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1047}
1048
1049// Logical operators...
1050let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1051def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001052 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001053 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1055def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001056 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001057 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1059def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001060 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001061 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001062 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1063}
1064
1065def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001066 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001067 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1069def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001070 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001071 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1073def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001074 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001075 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1077
1078def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001079 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001080 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1082def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001083 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001084 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1086def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001087 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001088 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1090def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001091 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001092 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1094 OpSize;
1095def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001096 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001097 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1099
1100let isTwoAddress = 0 in {
1101 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001102 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001103 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1105 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001106 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001107 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1109 OpSize;
1110 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001111 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001112 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1114 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001115 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001116 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1118 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001119 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001120 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1122 OpSize;
1123 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001124 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001125 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1127 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001128 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001129 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1131 OpSize;
1132 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001133 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001134 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001135 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1136}
1137
1138
1139let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001140def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001141 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001142 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001143def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001144 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001146def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001147 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1149}
Evan Chengb783fa32007-07-19 01:14:50 +00001150def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001151 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001153def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001154 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001155 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001156def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001157 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1159
Evan Chengb783fa32007-07-19 01:14:50 +00001160def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001161 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001163def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001164 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001166def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001167 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1169
Evan Chengb783fa32007-07-19 01:14:50 +00001170def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001171 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001172 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001173def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001174 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1176let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001177 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001178 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001180 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001181 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001183 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001184 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001186 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001187 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001189 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001190 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001191 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1192 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001193 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001194 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001195 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001196 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001197 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1199 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001200 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001201 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1203}
1204
1205
1206let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1207def XOR8rr : I<0x30, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001208 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001209 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1211def XOR16rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001212 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001213 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001214 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1215def XOR32rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001216 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001217 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1219}
1220
1221def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001222 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001223 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1225def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001226 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001227 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1229def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001230 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001231 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001232 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1233
1234def XOR8ri : Ii8<0x80, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001235 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001236 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001237 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1238def XOR16ri : Ii16<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001239 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001240 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1242def XOR32ri : Ii32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001243 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001244 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1246def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001247 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001248 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001249 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1250 OpSize;
1251def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001252 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001253 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001254 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1255let isTwoAddress = 0 in {
1256 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001257 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001258 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1260 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001261 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001262 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001263 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1264 OpSize;
1265 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001266 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001267 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001268 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1269 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001270 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001271 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1273 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001274 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001275 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1277 OpSize;
1278 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001279 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1282 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001283 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001284 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1286 OpSize;
1287 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001288 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001289 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001290 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1291}
1292
1293// Shift instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001294def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001295 "shl{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296 [(set GR8:$dst, (shl GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001297def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001298 "shl{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(set GR16:$dst, (shl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001300def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001301 "shl{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 [(set GR32:$dst, (shl GR32:$src, CL))]>, Imp<[CL],[]>;
1303
Evan Chengb783fa32007-07-19 01:14:50 +00001304def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001305 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001306 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1307let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001308def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001309 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001310 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001311def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001312 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1314}
1315
1316// Shift left by one. Not used because (add x, x) is slightly cheaper.
Evan Chengb783fa32007-07-19 01:14:50 +00001317def SHL8r1 : I<0xD0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001318 "shl{b}\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001319def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001320 "shl{w}\t$dst", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001321def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001322 "shl{l}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323
1324let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001325 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001326 "shl{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001327 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1328 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001329 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001330 "shl{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001331 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1332 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001333 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001334 "shl{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1336 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001337 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001338 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001340 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001341 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1343 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001344 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001345 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1347
1348 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001349 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001350 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001352 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001353 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1355 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001356 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001357 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001358 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1359}
1360
Evan Chengb783fa32007-07-19 01:14:50 +00001361def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001362 "shr{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001363 [(set GR8:$dst, (srl GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001364def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001365 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001366 [(set GR16:$dst, (srl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001367def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001368 "shr{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369 [(set GR32:$dst, (srl GR32:$src, CL))]>, Imp<[CL],[]>;
1370
Evan Chengb783fa32007-07-19 01:14:50 +00001371def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001372 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001374def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001375 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001376 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001377def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001378 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001379 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1380
1381// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001382def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001383 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001385def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001386 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001387 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001388def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001389 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1391
1392let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001393 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001394 "shr{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1396 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001397 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001398 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1400 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001401 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001402 "shr{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1404 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001405 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001406 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001407 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001408 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001409 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001410 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1411 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001412 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001413 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001414 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1415
1416 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001417 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001418 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001420 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001421 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001422 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001423 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001424 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001425 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1426}
1427
Evan Chengb783fa32007-07-19 01:14:50 +00001428def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001429 "sar{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001430 [(set GR8:$dst, (sra GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001431def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001432 "sar{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001433 [(set GR16:$dst, (sra GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001434def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 "sar{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001436 [(set GR32:$dst, (sra GR32:$src, CL))]>, Imp<[CL],[]>;
1437
Evan Chengb783fa32007-07-19 01:14:50 +00001438def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001441def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001442 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001443 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1444 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001445def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001446 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1448
1449// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001450def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001451 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001452 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001453def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001454 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001455 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001456def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001457 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001458 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1459
1460let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001461 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001462 "sar{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001463 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1464 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001465 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001466 "sar{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1468 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001469 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001470 "sar{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1472 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001473 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001474 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001475 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001476 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001477 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001478 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1479 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001480 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001482 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1483
1484 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001485 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001487 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001488 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001489 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001490 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1491 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001492 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001493 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1495}
1496
1497// Rotate instructions
1498// FIXME: provide shorter instructions when imm8 == 1
Evan Chengb783fa32007-07-19 01:14:50 +00001499def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001500 "rol{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001501 [(set GR8:$dst, (rotl GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001502def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001503 "rol{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001504 [(set GR16:$dst, (rotl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001505def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "rol{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001507 [(set GR32:$dst, (rotl GR32:$src, CL))]>, Imp<[CL],[]>;
1508
Evan Chengb783fa32007-07-19 01:14:50 +00001509def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001510 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001512def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001513 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001514 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001515def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001516 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1518
1519// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001520def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001521 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001522 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001523def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001524 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001526def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001527 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1529
1530let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001531 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001532 "rol{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1534 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001535 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "rol{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1538 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001539 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001540 "rol{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001541 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1542 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001543 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001544 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001545 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001546 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1549 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001550 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001551 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001552 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1553
1554 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001555 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001558 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1561 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001562 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001563 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1565}
1566
Evan Chengb783fa32007-07-19 01:14:50 +00001567def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001568 "ror{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001569 [(set GR8:$dst, (rotr GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001570def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "ror{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001572 [(set GR16:$dst, (rotr GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001573def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001574 "ror{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575 [(set GR32:$dst, (rotr GR32:$src, CL))]>, Imp<[CL],[]>;
1576
Evan Chengb783fa32007-07-19 01:14:50 +00001577def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001578 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001579 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001580def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001581 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001582 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001583def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001584 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001585 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1586
1587// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001588def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001589 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001590 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001591def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001592 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001593 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001594def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001595 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001596 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1597
1598let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001599 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001600 "ror{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1602 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001603 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001604 "ror{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001605 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1606 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001607 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001608 "ror{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1610 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001611 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001612 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001613 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001614 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001615 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001616 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1617 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001618 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001619 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1621
1622 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001623 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001624 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001626 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001627 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001628 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1629 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001630 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001631 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001632 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1633}
1634
1635
1636
1637// Double shift instructions (generalizations of rotate)
Evan Chengb783fa32007-07-19 01:14:50 +00001638def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001639 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001640 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>,
1641 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001642def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001643 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>,
1645 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001646def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1649 Imp<[CL],[]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001650def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001651 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001652 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1653 Imp<[CL],[]>, TB, OpSize;
1654
1655let isCommutable = 1 in { // These instructions commute to each other.
1656def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001657 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1660 (i8 imm:$src3)))]>,
1661 TB;
1662def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001663 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1666 (i8 imm:$src3)))]>,
1667 TB;
1668def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001669 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001670 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001671 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1672 (i8 imm:$src3)))]>,
1673 TB, OpSize;
1674def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001675 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001676 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001677 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1678 (i8 imm:$src3)))]>,
1679 TB, OpSize;
1680}
1681
1682let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001683 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001684 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001685 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1686 addr:$dst)]>,
1687 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001688 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001690 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1691 addr:$dst)]>,
1692 Imp<[CL],[]>, TB;
1693 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001694 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001695 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001696 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1697 (i8 imm:$src3)), addr:$dst)]>,
1698 TB;
1699 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001700 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001701 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001702 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1703 (i8 imm:$src3)), addr:$dst)]>,
1704 TB;
1705
Evan Chengb783fa32007-07-19 01:14:50 +00001706 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001707 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001708 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
1709 addr:$dst)]>,
1710 Imp<[CL],[]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001711 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001712 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001713 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
1714 addr:$dst)]>,
1715 Imp<[CL],[]>, TB, OpSize;
1716 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001717 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001718 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001719 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1720 (i8 imm:$src3)), addr:$dst)]>,
1721 TB, OpSize;
1722 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001723 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001724 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1726 (i8 imm:$src3)), addr:$dst)]>,
1727 TB, OpSize;
1728}
1729
1730
1731// Arithmetic.
1732let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001733def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001734 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001735 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1736let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001737def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001738 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001739 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001740def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001741 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1743} // end isConvertibleToThreeAddress
1744} // end isCommutable
Evan Chengb783fa32007-07-19 01:14:50 +00001745def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001746 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001748def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001749 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001750 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001751def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001752 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001753 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1754
Evan Chengb783fa32007-07-19 01:14:50 +00001755def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1758
1759let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001760def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001761 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001763def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001765 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001766def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001767 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001768 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>,
1769 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001770def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001771 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001772 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
1773}
1774
1775let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001776 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001778 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001779 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001780 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001781 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
1782 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001783 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001784 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001785 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001786 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001788 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001789 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001790 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001791 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1792 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001793 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001794 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001795 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001796 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1799 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001800 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001801 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1803}
1804
1805let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001806def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001807 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001808 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1809}
Evan Chengb783fa32007-07-19 01:14:50 +00001810def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001811 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001812 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001813def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001814 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001815 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001816def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001817 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001818 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1819
1820let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001821 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001822 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001824 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001825 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001826 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001827 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1830}
1831
Evan Chengb783fa32007-07-19 01:14:50 +00001832def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001833 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001834 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001835def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001838def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001839 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001841def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001842 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001843 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001844def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001845 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001846 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001847def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001848 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001849 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1850
Evan Chengb783fa32007-07-19 01:14:50 +00001851def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001852 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001853 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001854def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001855 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001856 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001857def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001858 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001859 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001860def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
1863 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001864def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001865 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1867let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001868 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001869 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001870 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001871 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001872 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001873 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
1874 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001875 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001876 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001877 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001878 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001879 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001880 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001881 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001882 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001883 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1884 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001885 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001886 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001887 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001888 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001889 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001890 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1891 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001892 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001894 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1895}
1896
Evan Chengb783fa32007-07-19 01:14:50 +00001897def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001899 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
1900
1901let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001902 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001903 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001904 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001905 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001906 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001907 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001908 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001909 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001910 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001911 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1914}
Evan Chengb783fa32007-07-19 01:14:50 +00001915def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001916 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001917 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001918def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001919 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001920 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001921def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
1924
1925let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001926def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001927 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001928 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001929def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001930 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
1932}
Evan Chengb783fa32007-07-19 01:14:50 +00001933def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001935 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
1936 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001937def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
1940
1941} // end Two Address instructions
1942
1943// Suprisingly enough, these are not two address instructions!
1944def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00001945 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001946 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
1948def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00001949 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001950 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001951 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
1952def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001953 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001954 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001955 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
1956 OpSize;
1957def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001958 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
1961
1962def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00001963 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001964 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001965 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
1966 OpSize;
1967def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00001968 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001969 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
1971def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001972 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001973 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001974 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
1975 OpSize;
1976def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001977 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001978 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001979 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
1980
1981//===----------------------------------------------------------------------===//
1982// Test instructions are just like AND, except they don't generate a result.
1983//
1984let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00001985def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001986 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001987 [(X86cmp (and GR8:$src1, GR8:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001988def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001989 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001990 [(X86cmp (and GR16:$src1, GR16:$src2), 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001991def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001992 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993 [(X86cmp (and GR32:$src1, GR32:$src2), 0)]>;
1994}
1995
Evan Chengb783fa32007-07-19 01:14:50 +00001996def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001997 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001998 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001999def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0)]>,
2002 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002003def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0)]>;
2006
2007def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002008 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002009 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010 [(X86cmp (and GR8:$src1, imm:$src2), 0)]>;
2011def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002012 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 [(X86cmp (and GR16:$src1, imm:$src2), 0)]>, OpSize;
2015def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002016 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002017 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002018 [(X86cmp (and GR32:$src1, imm:$src2), 0)]>;
2019
2020def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002021 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0)]>;
2024def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002025 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002026 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0)]>,
2028 OpSize;
2029def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002030 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002031 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002032 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0)]>;
2033
2034
2035// Condition code ops, incl. set if equal/not equal/...
Evan Chengb783fa32007-07-19 01:14:50 +00002036def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>, Imp<[AH],[]>; // flags = AH
2037def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>, Imp<[],[AH]>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002038
2039def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002040 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002041 "sete\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002042 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2043 TB; // GR8 = ==
2044def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002045 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002046 "sete\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002047 [(store (X86setcc X86_COND_E), addr:$dst)]>,
2048 TB; // [mem8] = ==
2049def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002050 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002051 "setne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002052 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2053 TB; // GR8 = !=
2054def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002055 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002056 "setne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
2058 TB; // [mem8] = !=
2059def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002060 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002061 "setl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002062 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2063 TB; // GR8 = < signed
2064def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002065 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002066 "setl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002067 [(store (X86setcc X86_COND_L), addr:$dst)]>,
2068 TB; // [mem8] = < signed
2069def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002070 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002071 "setge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2073 TB; // GR8 = >= signed
2074def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002075 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002076 "setge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002077 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
2078 TB; // [mem8] = >= signed
2079def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002080 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002081 "setle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2083 TB; // GR8 = <= signed
2084def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002085 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002086 "setle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002087 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
2088 TB; // [mem8] = <= signed
2089def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002090 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002091 "setg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002092 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2093 TB; // GR8 = > signed
2094def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002095 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002096 "setg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002097 [(store (X86setcc X86_COND_G), addr:$dst)]>,
2098 TB; // [mem8] = > signed
2099
2100def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002101 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002102 "setb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2104 TB; // GR8 = < unsign
2105def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002106 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002107 "setb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002108 [(store (X86setcc X86_COND_B), addr:$dst)]>,
2109 TB; // [mem8] = < unsign
2110def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002111 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002112 "setae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2114 TB; // GR8 = >= unsign
2115def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002116 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002117 "setae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
2119 TB; // [mem8] = >= unsign
2120def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002121 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002122 "setbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2124 TB; // GR8 = <= unsign
2125def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002126 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002127 "setbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
2129 TB; // [mem8] = <= unsign
2130def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002131 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002132 "seta\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2134 TB; // GR8 = > signed
2135def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002136 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002137 "seta\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138 [(store (X86setcc X86_COND_A), addr:$dst)]>,
2139 TB; // [mem8] = > signed
2140
2141def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002142 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002143 "sets\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2145 TB; // GR8 = <sign bit>
2146def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002147 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002148 "sets\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002149 [(store (X86setcc X86_COND_S), addr:$dst)]>,
2150 TB; // [mem8] = <sign bit>
2151def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002152 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002153 "setns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002154 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2155 TB; // GR8 = !<sign bit>
2156def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002157 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002158 "setns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002159 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
2160 TB; // [mem8] = !<sign bit>
2161def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002162 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002163 "setp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2165 TB; // GR8 = parity
2166def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002167 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002168 "setp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002169 [(store (X86setcc X86_COND_P), addr:$dst)]>,
2170 TB; // [mem8] = parity
2171def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002172 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002173 "setnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2175 TB; // GR8 = not parity
2176def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002177 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002178 "setnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
2180 TB; // [mem8] = not parity
2181
2182// Integer comparisons
2183def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002184 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 [(X86cmp GR8:$src1, GR8:$src2)]>;
2187def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002188 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002189 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002190 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
2191def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002192 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002194 [(X86cmp GR32:$src1, GR32:$src2)]>;
2195def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002196 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002197 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002198 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
2199def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002200 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
2203def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002204 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002205 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
2207def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002208 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002209 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002210 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
2211def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002212 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
2215def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002216 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002218 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
2219def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002220 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002221 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002222 [(X86cmp GR8:$src1, imm:$src2)]>;
2223def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002224 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
2227def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002228 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002229 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230 [(X86cmp GR32:$src1, imm:$src2)]>;
2231def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002232 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002233 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
2235def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002236 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002237 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002238 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
2239def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002240 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002241 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002242 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
2243def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002244 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002245 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002246 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
2247def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002248 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002249 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002250 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
2251def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002252 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002253 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002254 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
2255def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002256 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002258 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
2259
2260// Sign/Zero extenders
Evan Chengb783fa32007-07-19 01:14:50 +00002261def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002262 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002263 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002264def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002266 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002267def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002268 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002270def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002271 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002272 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002273def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002274 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002275 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002276def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002277 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002278 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2279
Evan Chengb783fa32007-07-19 01:14:50 +00002280def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002281 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002283def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002284 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002285 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002286def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002287 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002288 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002289def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002290 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002291 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002292def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002293 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002294 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002295def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002296 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002297 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2298
Evan Chengb783fa32007-07-19 01:14:50 +00002299def CBW : I<0x98, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300 "{cbtw|cbw}", []>, Imp<[AL],[AX]>, OpSize; // AX = signext(AL)
Evan Chengb783fa32007-07-19 01:14:50 +00002301def CWDE : I<0x98, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002302 "{cwtl|cwde}", []>, Imp<[AX],[EAX]>; // EAX = signext(AX)
2303
Evan Chengb783fa32007-07-19 01:14:50 +00002304def CWD : I<0x99, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002305 "{cwtd|cwd}", []>, Imp<[AX],[AX,DX]>, OpSize; // DX:AX = signext(AX)
Evan Chengb783fa32007-07-19 01:14:50 +00002306def CDQ : I<0x99, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002307 "{cltd|cdq}", []>, Imp<[EAX],[EAX,EDX]>; // EDX:EAX = signext(EAX)
2308
2309
2310//===----------------------------------------------------------------------===//
2311// Alias Instructions
2312//===----------------------------------------------------------------------===//
2313
2314// Alias instructions that map movr0 to xor.
2315// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Dan Gohman8aef09b2007-09-07 21:32:51 +00002316let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002317def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002318 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002319 [(set GR8:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002320def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002321 "xor{w}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322 [(set GR16:$dst, 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002323def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002324 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002325 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002326}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327
2328// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2329// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengb783fa32007-07-19 01:14:50 +00002330def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002331 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002332def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002334
Evan Chengb783fa32007-07-19 01:14:50 +00002335def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002336 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002337def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002338 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002339let isLoad = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002340def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002341 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002342def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002343 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002344}
Evan Chengb783fa32007-07-19 01:14:50 +00002345def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002346 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002347def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002348 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002349
2350//===----------------------------------------------------------------------===//
2351// Thread Local Storage Instructions
2352//
2353
Evan Chengb783fa32007-07-19 01:14:50 +00002354def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
Dan Gohman91888f02007-07-31 20:11:57 +00002355 "leal\t${sym:mem}(,%ebx,1), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>,
2357 Imp<[EBX],[]>;
2358
2359let AddedComplexity = 10 in
Evan Chengb783fa32007-07-19 01:14:50 +00002360def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002361 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002362 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2363
2364let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002365def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002366 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002367 [(set GR32:$dst,
2368 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2369
Evan Chengb783fa32007-07-19 01:14:50 +00002370def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002372 [(set GR32:$dst, X86TLStp)]>;
2373
2374//===----------------------------------------------------------------------===//
2375// DWARF Pseudo Instructions
2376//
2377
Evan Chengb783fa32007-07-19 01:14:50 +00002378def DWARF_LOC : I<0, Pseudo, (outs),
2379 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohmanf8133d72007-07-26 15:24:15 +00002380 "; .loc ${file:debug}, ${line:debug}, ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002381 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2382 (i32 imm:$file))]>;
2383
2384//===----------------------------------------------------------------------===//
2385// EH Pseudo Instructions
2386//
2387let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002388 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002389def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002390 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002391 [(X86ehret GR32:$addr)]>;
2392
2393}
2394
2395//===----------------------------------------------------------------------===//
2396// Non-Instruction Patterns
2397//===----------------------------------------------------------------------===//
2398
2399// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2400def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2401def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2402def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2403def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2404def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2405
2406def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2407 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2408def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2409 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2410def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2411 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2412def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2413 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2414
2415def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2416 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2417def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2418 (MOV32mi addr:$dst, texternalsym:$src)>;
2419
2420// Calls
2421def : Pat<(X86tailcall GR32:$dst),
2422 (CALL32r GR32:$dst)>;
2423
2424def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2425 (CALLpcrel32 tglobaladdr:$dst)>;
2426def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2427 (CALLpcrel32 texternalsym:$dst)>;
2428
2429def : Pat<(X86call (i32 tglobaladdr:$dst)),
2430 (CALLpcrel32 tglobaladdr:$dst)>;
2431def : Pat<(X86call (i32 texternalsym:$dst)),
2432 (CALLpcrel32 texternalsym:$dst)>;
2433
2434// X86 specific add which produces a flag.
2435def : Pat<(addc GR32:$src1, GR32:$src2),
2436 (ADD32rr GR32:$src1, GR32:$src2)>;
2437def : Pat<(addc GR32:$src1, (load addr:$src2)),
2438 (ADD32rm GR32:$src1, addr:$src2)>;
2439def : Pat<(addc GR32:$src1, imm:$src2),
2440 (ADD32ri GR32:$src1, imm:$src2)>;
2441def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2442 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2443
2444def : Pat<(subc GR32:$src1, GR32:$src2),
2445 (SUB32rr GR32:$src1, GR32:$src2)>;
2446def : Pat<(subc GR32:$src1, (load addr:$src2)),
2447 (SUB32rm GR32:$src1, addr:$src2)>;
2448def : Pat<(subc GR32:$src1, imm:$src2),
2449 (SUB32ri GR32:$src1, imm:$src2)>;
2450def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2451 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2452
2453def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2454 (MOV8mi addr:$dst, imm:$src)>;
2455def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2456 (MOV8mr addr:$dst, GR8:$src)>;
2457
2458// Comparisons.
2459
2460// TEST R,R is smaller than CMP R,0
2461def : Pat<(X86cmp GR8:$src1, 0),
2462 (TEST8rr GR8:$src1, GR8:$src1)>;
2463def : Pat<(X86cmp GR16:$src1, 0),
2464 (TEST16rr GR16:$src1, GR16:$src1)>;
2465def : Pat<(X86cmp GR32:$src1, 0),
2466 (TEST32rr GR32:$src1, GR32:$src1)>;
2467
2468// {s|z}extload bool -> {s|z}extload byte
2469def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2470def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2471def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2472def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2473def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2474
2475// extload bool -> extload byte
2476def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2477def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2478def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2479def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2480def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2481def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2482
2483// anyext -> zext
2484def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2485def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2486def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2487def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2488def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2489def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2490
2491//===----------------------------------------------------------------------===//
2492// Some peepholes
2493//===----------------------------------------------------------------------===//
2494
2495// (shl x, 1) ==> (add x, x)
2496def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2497def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2498def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2499
2500// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2501def : Pat<(or (srl GR32:$src1, CL:$amt),
2502 (shl GR32:$src2, (sub 32, CL:$amt))),
2503 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2504
2505def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2506 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2507 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2508
2509// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2510def : Pat<(or (shl GR32:$src1, CL:$amt),
2511 (srl GR32:$src2, (sub 32, CL:$amt))),
2512 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2513
2514def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2515 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2516 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2517
2518// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2519def : Pat<(or (srl GR16:$src1, CL:$amt),
2520 (shl GR16:$src2, (sub 16, CL:$amt))),
2521 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2522
2523def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2524 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2525 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2526
2527// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2528def : Pat<(or (shl GR16:$src1, CL:$amt),
2529 (srl GR16:$src2, (sub 16, CL:$amt))),
2530 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2531
2532def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2533 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2534 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2535
2536
2537//===----------------------------------------------------------------------===//
2538// Floating Point Stack Support
2539//===----------------------------------------------------------------------===//
2540
2541include "X86InstrFPStack.td"
2542
2543//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00002544// X86-64 Support
2545//===----------------------------------------------------------------------===//
2546
2547include "X86InstrX86-64.td"
2548
2549//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002550// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2551//===----------------------------------------------------------------------===//
2552
2553include "X86InstrMMX.td"
2554
2555//===----------------------------------------------------------------------===//
2556// XMM Floating point support (requires SSE / SSE2)
2557//===----------------------------------------------------------------------===//
2558
2559include "X86InstrSSE.td"