blob: 190d5b1bcc0aa16104579334f69f06301f14219a [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">;
122def f128mem : X86MemOperand<"printf128mem">;
123
124def lea32mem : Operand<i32> {
125 let PrintMethod = "printi32mem";
126 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
127}
128
129def SSECC : Operand<i8> {
130 let PrintMethod = "printSSECC";
131}
132
133def piclabel: Operand<i32> {
134 let PrintMethod = "printPICLabel";
135}
136
137// A couple of more descriptive operand definitions.
138// 16-bits but only 8 bits are significant.
139def i16i8imm : Operand<i16>;
140// 32-bits but only 8 bits are significant.
141def i32i8imm : Operand<i32>;
142
143// Branch targets have OtherVT type.
144def brtarget : Operand<OtherVT>;
145
146//===----------------------------------------------------------------------===//
147// X86 Complex Pattern Definitions.
148//
149
150// Define X86 specific addressing mode.
151def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
152def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
153 [add, mul, shl, or, frameindex], []>;
154
155//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000156// X86 Instruction Predicate Definitions.
157def HasMMX : Predicate<"Subtarget->hasMMX()">;
158def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
159def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
160def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
161def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
162def FPStack : Predicate<"!Subtarget->hasSSE2()">;
163def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
164def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Evan Cheng09e13792007-08-01 23:45:51 +0000165def HasLow4G : Predicate<"Subtarget->hasLow4GUserSpaceAddress()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000166def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
167def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
168def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
169
170//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000171// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000172//
173
Evan Cheng86ab7d32007-07-31 08:04:03 +0000174include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000175
176//===----------------------------------------------------------------------===//
177// Pattern fragments...
178//
179
180// X86 specific condition code. These correspond to CondCode in
181// X86InstrInfo.h. They must be kept in synch.
182def X86_COND_A : PatLeaf<(i8 0)>;
183def X86_COND_AE : PatLeaf<(i8 1)>;
184def X86_COND_B : PatLeaf<(i8 2)>;
185def X86_COND_BE : PatLeaf<(i8 3)>;
186def X86_COND_E : PatLeaf<(i8 4)>;
187def X86_COND_G : PatLeaf<(i8 5)>;
188def X86_COND_GE : PatLeaf<(i8 6)>;
189def X86_COND_L : PatLeaf<(i8 7)>;
190def X86_COND_LE : PatLeaf<(i8 8)>;
191def X86_COND_NE : PatLeaf<(i8 9)>;
192def X86_COND_NO : PatLeaf<(i8 10)>;
193def X86_COND_NP : PatLeaf<(i8 11)>;
194def X86_COND_NS : PatLeaf<(i8 12)>;
195def X86_COND_O : PatLeaf<(i8 13)>;
196def X86_COND_P : PatLeaf<(i8 14)>;
197def X86_COND_S : PatLeaf<(i8 15)>;
198
199def i16immSExt8 : PatLeaf<(i16 imm), [{
200 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
201 // sign extended field.
202 return (int16_t)N->getValue() == (int8_t)N->getValue();
203}]>;
204
205def i32immSExt8 : PatLeaf<(i32 imm), [{
206 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
207 // sign extended field.
208 return (int32_t)N->getValue() == (int8_t)N->getValue();
209}]>;
210
211// Helper fragments for loads.
212def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
213def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
214def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
215def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
216
217def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
218def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
219
220def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
221def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
222def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
223def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
224def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
225
226def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
227def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
228def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
229def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
230def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
231def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
232
233def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
234def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
235def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
236def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
237def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
238def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
239
240//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000241// Instruction list...
242//
243
244// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
245// a stack adjustment and the codegen must know that they may modify the stack
246// pointer before prolog-epilog rewriting occurs.
Evan Chengb783fa32007-07-19 01:14:50 +0000247def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt), "#ADJCALLSTACKDOWN",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000248 [(X86callseq_start imm:$amt)]>, Imp<[ESP],[ESP]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000249def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000250 "#ADJCALLSTACKUP",
251 [(X86callseq_end imm:$amt1, imm:$amt2)]>,
252 Imp<[ESP],[ESP]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000253def IMPLICIT_USE : I<0, Pseudo, (outs), (ins variable_ops),
254 "#IMPLICIT_USE", []>;
255def IMPLICIT_DEF : I<0, Pseudo, (outs variable_ops), (ins),
256 "#IMPLICIT_DEF", []>;
257def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000258 "#IMPLICIT_DEF $dst",
259 [(set GR8:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000260def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000261 "#IMPLICIT_DEF $dst",
262 [(set GR16:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000263def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264 "#IMPLICIT_DEF $dst",
265 [(set GR32:$dst, (undef))]>;
266
267// Nop
Evan Chengb783fa32007-07-19 01:14:50 +0000268def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000270
271//===----------------------------------------------------------------------===//
272// Control Flow Instructions...
273//
274
275// Return instructions.
276let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +0000277 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000278 def RET : I<0xC3, RawFrm, (outs), (ins), "ret", [(X86retflag 0)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000279 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt), "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280 [(X86retflag imm:$amt)]>;
281}
282
283// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000284let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000285 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
286 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000287
288// Indirect branches
289let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000290 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291
Evan Cheng37e7c752007-07-21 00:34:19 +0000292let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000293 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000295 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000296 [(brind (loadi32 addr:$dst))]>;
297}
298
299// Conditional branches
Dan Gohman91888f02007-07-31 20:11:57 +0000300def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000301 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000302def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000303 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000304def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000306def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000308def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000310def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
312
Dan Gohman91888f02007-07-31 20:11:57 +0000313def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000314 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000315def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000317def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000319def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
321
Dan Gohman91888f02007-07-31 20:11:57 +0000322def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000324def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000326def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000328def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000330def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000332def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
334
335//===----------------------------------------------------------------------===//
336// Call Instructions...
337//
Evan Cheng37e7c752007-07-21 00:34:19 +0000338let isCall = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000339 // All calls clobber the non-callee saved registers...
340 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
341 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
342 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000343 def CALLpcrel32 : I<0xE8, RawFrm, (outs), (ins i32imm:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000344 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000345 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000346 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000347 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000348 "call\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000349 }
350
351// Tail call stuff.
Evan Cheng37e7c752007-07-21 00:34:19 +0000352let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000353 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAIL CALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000354 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000355let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000356 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp\t{*}$dst # TAIL CALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000358let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000359 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000360 "jmp\t{*}$dst # TAIL CALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361
362//===----------------------------------------------------------------------===//
363// Miscellaneous Instructions...
364//
365def LEAVE : I<0xC9, RawFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000366 (outs), (ins), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000367def POP32r : I<0x58, AddRegFrm,
Dan Gohman91888f02007-07-31 20:11:57 +0000368 (outs GR32:$reg), (ins), "pop{l}\t$reg", []>, Imp<[ESP],[ESP]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369
370def PUSH32r : I<0x50, AddRegFrm,
Dan Gohman91888f02007-07-31 20:11:57 +0000371 (outs), (ins GR32:$reg), "push{l}\t$reg", []>, Imp<[ESP],[ESP]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000372
Evan Chengb783fa32007-07-19 01:14:50 +0000373def MovePCtoStack : I<0, Pseudo, (outs), (ins piclabel:$label),
Dan Gohman91888f02007-07-31 20:11:57 +0000374 "call\t$label", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000375
376let isTwoAddress = 1 in // GR32 = bswap GR32
377 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000378 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000379 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000380 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
381
Evan Chengb783fa32007-07-19 01:14:50 +0000382// FIXME: Model xchg* as two address instructions?
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000383def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
Evan Chengb783fa32007-07-19 01:14:50 +0000384 (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000385 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000386def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000387 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000388 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000389def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000390 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000391 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000392
393def XCHG8mr : I<0x86, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000394 (outs), (ins i8mem:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000395 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000396def XCHG16mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000397 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000398 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399def XCHG32mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000400 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000401 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000402def XCHG8rm : I<0x86, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000403 (outs), (ins GR8:$src1, i8mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000404 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000405def XCHG16rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000406 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000407 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000408def XCHG32rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000409 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000410 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000411
412def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000413 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000414 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000415def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000416 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000417 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000418 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
419
Evan Chengb783fa32007-07-19 01:14:50 +0000420def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000421 [(X86rep_movs i8)]>,
422 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000423def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000424 [(X86rep_movs i16)]>,
425 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000426def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000427 [(X86rep_movs i32)]>,
428 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
429
Evan Chengb783fa32007-07-19 01:14:50 +0000430def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000431 [(X86rep_stos i8)]>,
432 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000433def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000434 [(X86rep_stos i16)]>,
435 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000436def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000437 [(X86rep_stos i32)]>,
438 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
439
Evan Chengb783fa32007-07-19 01:14:50 +0000440def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000441 TB, Imp<[],[RAX,RDX]>;
442
443//===----------------------------------------------------------------------===//
444// Input/Output Instructions...
445//
Evan Chengb783fa32007-07-19 01:14:50 +0000446def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000447 "in{b}\t{%dx, %al|%AL, %DX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000448 []>, Imp<[DX], [AL]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000449def IN16rr : I<0xED, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000450 "in{w}\t{%dx, %ax|%AX, %DX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000451 []>, Imp<[DX], [AX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000452def IN32rr : I<0xED, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000453 "in{l}\t{%dx, %eax|%EAX, %DX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000454 []>, Imp<[DX],[EAX]>;
455
Evan Chengb783fa32007-07-19 01:14:50 +0000456def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000457 "in{b}\t{$port, %al|%AL, $port}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000458 []>,
459 Imp<[], [AL]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000460def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000461 "in{w}\t{$port, %ax|%AX, $port}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000462 []>,
463 Imp<[], [AX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000464def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000465 "in{l}\t{$port, %eax|%EAX, $port}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000466 []>,
467 Imp<[],[EAX]>;
468
Evan Chengb783fa32007-07-19 01:14:50 +0000469def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000470 "out{b}\t{%al, %dx|%DX, %AL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000471 []>, Imp<[DX, AL], []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000472def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000473 "out{w}\t{%ax, %dx|%DX, %AX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000474 []>, Imp<[DX, AX], []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000475def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000476 "out{l}\t{%eax, %dx|%DX, %EAX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000477 []>, Imp<[DX, EAX], []>;
478
Evan Chengb783fa32007-07-19 01:14:50 +0000479def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000480 "out{b}\t{%al, $port|$port, %AL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000481 []>,
482 Imp<[AL], []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000483def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000484 "out{w}\t{%ax, $port|$port, %AX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000485 []>,
486 Imp<[AX], []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000487def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000488 "out{l}\t{%eax, $port|$port, %EAX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000489 []>,
490 Imp<[EAX], []>;
491
492//===----------------------------------------------------------------------===//
493// Move Instructions...
494//
Evan Chengb783fa32007-07-19 01:14:50 +0000495def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000496 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000497def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000498 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000499def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000500 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000501let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000502def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000503 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000504 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000505def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000506 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000507 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000508def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000509 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000510 [(set GR32:$dst, imm:$src)]>;
511}
Evan Chengb783fa32007-07-19 01:14:50 +0000512def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000513 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000514 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000515def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000516 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000517 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000518def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000519 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000520 [(store (i32 imm:$src), addr:$dst)]>;
521
Evan Chengb783fa32007-07-19 01:14:50 +0000522def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000523 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000524 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000525def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000526 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000528def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000529 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530 [(set GR32:$dst, (load addr:$src))]>;
531
Evan Chengb783fa32007-07-19 01:14:50 +0000532def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000533 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000535def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000536 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000538def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000539 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000540 [(store GR32:$src, addr:$dst)]>;
541
542//===----------------------------------------------------------------------===//
543// Fixed-Register Multiplication and Division Instructions...
544//
545
546// Extra precision multiplication
Dan Gohman91888f02007-07-31 20:11:57 +0000547def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
549 // This probably ought to be moved to a def : Pat<> if the
550 // syntax can be accepted.
551 [(set AL, (mul AL, GR8:$src))]>,
Evan Chenge3dc8a62007-08-01 20:22:37 +0000552 Imp<[AL],[AL,AH]>; // AL,AH = AL*GR8
Dan Gohman91888f02007-07-31 20:11:57 +0000553def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000554 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
Dan Gohman91888f02007-07-31 20:11:57 +0000555def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000557def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000558 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
560 // This probably ought to be moved to a def : Pat<> if the
561 // syntax can be accepted.
562 [(set AL, (mul AL, (loadi8 addr:$src)))]>,
563 Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Evan Chengb783fa32007-07-19 01:14:50 +0000564def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000565 "mul{w}\t$src", []>, Imp<[AX],[AX,DX]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000566 OpSize; // AX,DX = AX*[mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000567def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000568 "mul{l}\t$src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000569
Dan Gohman91888f02007-07-31 20:11:57 +0000570def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000571 Imp<[AL],[AX]>; // AL,AH = AL*GR8
Dan Gohman91888f02007-07-31 20:11:57 +0000572def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000573 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
Dan Gohman91888f02007-07-31 20:11:57 +0000574def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000576def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000577 "imul{b}\t$src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Evan Chengb783fa32007-07-19 01:14:50 +0000578def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000579 "imul{w}\t$src", []>, Imp<[AX],[AX,DX]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000580 OpSize; // AX,DX = AX*[mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000581def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000582 "imul{l}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000583 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
584
585// unsigned division/remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000586def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Dan Gohman91888f02007-07-31 20:11:57 +0000587 "div{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000588def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Dan Gohman91888f02007-07-31 20:11:57 +0000589 "div{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000590def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Dan Gohman91888f02007-07-31 20:11:57 +0000591 "div{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000592def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Dan Gohman91888f02007-07-31 20:11:57 +0000593 "div{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000594def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Dan Gohman91888f02007-07-31 20:11:57 +0000595 "div{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000596def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Dan Gohman91888f02007-07-31 20:11:57 +0000597 "div{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000598
599// Signed division/remainder.
Evan Chengb783fa32007-07-19 01:14:50 +0000600def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Dan Gohman91888f02007-07-31 20:11:57 +0000601 "idiv{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000602def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Dan Gohman91888f02007-07-31 20:11:57 +0000603 "idiv{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000604def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Dan Gohman91888f02007-07-31 20:11:57 +0000605 "idiv{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000606def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Dan Gohman91888f02007-07-31 20:11:57 +0000607 "idiv{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000608def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Dan Gohman91888f02007-07-31 20:11:57 +0000609 "idiv{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000610def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Dan Gohman91888f02007-07-31 20:11:57 +0000611 "idiv{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000612
613
614//===----------------------------------------------------------------------===//
615// Two address Instructions...
616//
617let isTwoAddress = 1 in {
618
619// Conditional moves
620def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000621 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000622 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000623 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
624 X86_COND_B))]>,
625 TB, OpSize;
626def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000627 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000628 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000629 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
630 X86_COND_B))]>,
631 TB, OpSize;
632def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000633 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000634 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
636 X86_COND_B))]>,
637 TB;
638def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000639 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000640 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
642 X86_COND_B))]>,
643 TB;
644
645def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000646 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000647 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000648 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
649 X86_COND_AE))]>,
650 TB, OpSize;
651def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000652 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000653 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000654 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
655 X86_COND_AE))]>,
656 TB, OpSize;
657def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000658 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000659 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000660 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
661 X86_COND_AE))]>,
662 TB;
663def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000664 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000665 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000666 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
667 X86_COND_AE))]>,
668 TB;
669
670def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000671 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000672 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
674 X86_COND_E))]>,
675 TB, OpSize;
676def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000677 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000678 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000679 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
680 X86_COND_E))]>,
681 TB, OpSize;
682def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000683 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000684 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000685 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
686 X86_COND_E))]>,
687 TB;
688def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000689 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000690 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000691 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
692 X86_COND_E))]>,
693 TB;
694
695def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000696 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000697 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000698 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
699 X86_COND_NE))]>,
700 TB, OpSize;
701def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000702 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000703 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000704 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
705 X86_COND_NE))]>,
706 TB, OpSize;
707def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000708 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000709 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000710 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
711 X86_COND_NE))]>,
712 TB;
713def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000714 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000715 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000716 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
717 X86_COND_NE))]>,
718 TB;
719
720def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000721 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000722 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
724 X86_COND_BE))]>,
725 TB, OpSize;
726def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000727 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000728 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
730 X86_COND_BE))]>,
731 TB, OpSize;
732def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000733 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000734 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
736 X86_COND_BE))]>,
737 TB;
738def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000739 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000740 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
742 X86_COND_BE))]>,
743 TB;
744
745def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000746 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000747 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000748 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
749 X86_COND_A))]>,
750 TB, OpSize;
751def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000752 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000753 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000754 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
755 X86_COND_A))]>,
756 TB, OpSize;
757def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000758 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000759 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000760 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
761 X86_COND_A))]>,
762 TB;
763def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000764 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000765 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000766 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
767 X86_COND_A))]>,
768 TB;
769
770def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000771 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000772 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
774 X86_COND_L))]>,
775 TB, OpSize;
776def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000777 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000778 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
780 X86_COND_L))]>,
781 TB, OpSize;
782def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000783 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000784 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
786 X86_COND_L))]>,
787 TB;
788def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000789 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000790 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
792 X86_COND_L))]>,
793 TB;
794
795def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000796 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000797 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
799 X86_COND_GE))]>,
800 TB, OpSize;
801def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000802 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000803 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
805 X86_COND_GE))]>,
806 TB, OpSize;
807def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000808 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000809 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
811 X86_COND_GE))]>,
812 TB;
813def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000814 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000815 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
817 X86_COND_GE))]>,
818 TB;
819
820def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000821 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000822 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
824 X86_COND_LE))]>,
825 TB, OpSize;
826def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000827 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000828 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000829 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
830 X86_COND_LE))]>,
831 TB, OpSize;
832def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000833 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000834 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000835 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
836 X86_COND_LE))]>,
837 TB;
838def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000839 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000840 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000841 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
842 X86_COND_LE))]>,
843 TB;
844
845def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000846 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000847 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
849 X86_COND_G))]>,
850 TB, OpSize;
851def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000852 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000853 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000854 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
855 X86_COND_G))]>,
856 TB, OpSize;
857def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000858 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000859 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000860 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
861 X86_COND_G))]>,
862 TB;
863def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000864 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000865 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000866 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
867 X86_COND_G))]>,
868 TB;
869
870def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000871 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000872 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
874 X86_COND_S))]>,
875 TB, OpSize;
876def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000877 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000878 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000879 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
880 X86_COND_S))]>,
881 TB, OpSize;
882def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000883 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000884 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000885 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
886 X86_COND_S))]>,
887 TB;
888def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000889 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000890 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000891 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
892 X86_COND_S))]>,
893 TB;
894
895def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000896 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000897 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
899 X86_COND_NS))]>,
900 TB, OpSize;
901def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000902 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000903 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000904 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
905 X86_COND_NS))]>,
906 TB, OpSize;
907def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000908 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000909 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000910 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
911 X86_COND_NS))]>,
912 TB;
913def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000914 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000915 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000916 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
917 X86_COND_NS))]>,
918 TB;
919
920def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000921 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000922 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
924 X86_COND_P))]>,
925 TB, OpSize;
926def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000927 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000928 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000929 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
930 X86_COND_P))]>,
931 TB, OpSize;
932def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000933 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000934 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000935 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
936 X86_COND_P))]>,
937 TB;
938def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000939 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000940 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000941 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
942 X86_COND_P))]>,
943 TB;
944
945def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000946 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000947 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
949 X86_COND_NP))]>,
950 TB, OpSize;
951def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000952 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000953 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000954 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
955 X86_COND_NP))]>,
956 TB, OpSize;
957def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000958 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000959 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000960 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
961 X86_COND_NP))]>,
962 TB;
963def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000964 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000965 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000966 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
967 X86_COND_NP))]>,
968 TB;
969
970
971// unary instructions
972let CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000973def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000974 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000975def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +0000977def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 [(set GR32:$dst, (ineg GR32:$src))]>;
979let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000980 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000981 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000982 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +0000984 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
986
987}
988
Dan Gohman91888f02007-07-31 20:11:57 +0000989def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000991def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +0000993def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 [(set GR32:$dst, (not GR32:$src))]>;
995let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000996 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000998 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001000 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1002}
1003} // CodeSize
1004
1005// TODO: inc/dec is slow for P4, but fast for Pentium-M.
1006let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001007def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008 [(set GR8:$dst, (add GR8:$src, 1))]>;
1009let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001010def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001011 [(set GR16:$dst, (add GR16:$src, 1))]>,
1012 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001013def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1015}
1016let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001017 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001019 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001021 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1023}
1024
1025let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001026def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001027 [(set GR8:$dst, (add GR8:$src, -1))]>;
1028let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001029def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030 [(set GR16:$dst, (add GR16:$src, -1))]>,
1031 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001032def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1034}
1035
1036let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001037 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001038 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001039 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001041 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1043}
1044
1045// Logical operators...
1046let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1047def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001048 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001049 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001050 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1051def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001052 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001053 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1055def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001056 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001057 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1059}
1060
1061def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001062 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001063 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1065def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001066 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001067 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1069def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001070 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001071 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1073
1074def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001075 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001076 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1078def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001079 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001080 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1082def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001083 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001084 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1086def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001087 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001088 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001089 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1090 OpSize;
1091def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001092 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001093 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1095
1096let isTwoAddress = 0 in {
1097 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001098 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001099 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1101 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001102 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001103 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1105 OpSize;
1106 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001107 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001108 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1110 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001111 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001112 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1114 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001115 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001116 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1118 OpSize;
1119 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001120 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001121 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1123 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001124 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001125 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001126 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1127 OpSize;
1128 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001129 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001130 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001131 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1132}
1133
1134
1135let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001136def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001137 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001138 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001139def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001140 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001141 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001142def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001143 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001144 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1145}
Evan Chengb783fa32007-07-19 01:14:50 +00001146def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001147 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001148 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001149def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001150 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001151 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001152def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001153 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1155
Evan Chengb783fa32007-07-19 01:14:50 +00001156def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001157 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001159def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001160 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001162def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001163 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001164 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1165
Evan Chengb783fa32007-07-19 01:14:50 +00001166def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001167 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001169def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001170 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001171 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1172let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001173 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001174 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001176 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001177 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001178 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001179 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001180 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001182 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001183 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001185 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001186 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001187 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1188 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001189 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001190 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001191 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001192 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001193 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1195 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001196 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001197 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1199}
1200
1201
1202let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1203def XOR8rr : I<0x30, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001204 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001205 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1207def XOR16rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001208 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001209 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1211def XOR32rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001212 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001213 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001214 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1215}
1216
1217def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001218 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001219 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001220 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1221def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001222 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001223 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001224 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1225def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001226 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001227 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001228 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1229
1230def XOR8ri : Ii8<0x80, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001231 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001232 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1234def XOR16ri : Ii16<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001235 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001236 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001237 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1238def XOR32ri : Ii32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001239 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001240 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1242def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001243 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001244 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001245 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1246 OpSize;
1247def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001248 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001249 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001250 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1251let isTwoAddress = 0 in {
1252 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001253 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001254 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001255 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1256 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001257 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001258 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001259 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1260 OpSize;
1261 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001262 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001263 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1265 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001266 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001267 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001268 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1269 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001270 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001271 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1273 OpSize;
1274 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001275 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001276 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1278 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001279 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1282 OpSize;
1283 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001284 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001285 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1287}
1288
1289// Shift instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001290def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001291 "shl{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001292 [(set GR8:$dst, (shl GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001293def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001294 "shl{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 [(set GR16:$dst, (shl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001296def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001297 "shl{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001298 [(set GR32:$dst, (shl GR32:$src, CL))]>, Imp<[CL],[]>;
1299
Evan Chengb783fa32007-07-19 01:14:50 +00001300def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001301 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1303let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001304def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001305 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001306 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001307def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001308 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001309 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1310}
1311
1312// Shift left by one. Not used because (add x, x) is slightly cheaper.
Evan Chengb783fa32007-07-19 01:14:50 +00001313def SHL8r1 : I<0xD0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001314 "shl{b}\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001315def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001316 "shl{w}\t$dst", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001317def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001318 "shl{l}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001319
1320let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001321 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001322 "shl{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001323 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1324 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001325 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001326 "shl{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001327 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1328 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001329 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001330 "shl{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001331 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1332 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001333 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001334 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001335 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001336 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001337 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001338 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1339 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001340 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001341 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1343
1344 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001345 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001346 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001347 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001348 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001349 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1351 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001352 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001353 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001354 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1355}
1356
Evan Chengb783fa32007-07-19 01:14:50 +00001357def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001358 "shr{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359 [(set GR8:$dst, (srl GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001360def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001361 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362 [(set GR16:$dst, (srl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001363def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001364 "shr{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 [(set GR32:$dst, (srl GR32:$src, CL))]>, Imp<[CL],[]>;
1366
Evan Chengb783fa32007-07-19 01:14:50 +00001367def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001368 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001370def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001371 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001373def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001374 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001375 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1376
1377// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001378def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001379 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001381def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001382 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001383 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001384def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001385 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1387
1388let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001389 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001390 "shr{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001391 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1392 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001393 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001394 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001395 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1396 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001397 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001398 "shr{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1400 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001401 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001402 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001403 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001404 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001405 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001406 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1407 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001408 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001409 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001410 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1411
1412 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001413 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001414 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001415 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001416 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001419 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001420 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001421 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1422}
1423
Evan Chengb783fa32007-07-19 01:14:50 +00001424def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 "sar{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426 [(set GR8:$dst, (sra GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001427def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001428 "sar{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001429 [(set GR16:$dst, (sra GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001430def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001431 "sar{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001432 [(set GR32:$dst, (sra GR32:$src, CL))]>, Imp<[CL],[]>;
1433
Evan Chengb783fa32007-07-19 01:14:50 +00001434def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001436 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001437def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001438 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001439 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1440 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001441def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001442 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001443 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1444
1445// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001446def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001447 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001448 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001449def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001452def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001453 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001454 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1455
1456let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001457 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "sar{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001459 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1460 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001461 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001462 "sar{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001463 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1464 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001465 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001466 "sar{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1468 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001469 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001470 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001472 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001473 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001474 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1475 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001476 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001477 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001478 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1479
1480 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001481 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001482 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001483 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001484 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001485 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1487 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001488 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001489 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001490 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1491}
1492
1493// Rotate instructions
1494// FIXME: provide shorter instructions when imm8 == 1
Evan Chengb783fa32007-07-19 01:14:50 +00001495def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001496 "rol{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001497 [(set GR8:$dst, (rotl GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001498def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001499 "rol{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001500 [(set GR16:$dst, (rotl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001501def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001502 "rol{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001503 [(set GR32:$dst, (rotl GR32:$src, CL))]>, Imp<[CL],[]>;
1504
Evan Chengb783fa32007-07-19 01:14:50 +00001505def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001507 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001508def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001509 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001510 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001511def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001512 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001513 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1514
1515// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001516def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001517 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001518 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001519def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001520 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001521 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001522def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001523 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1525
1526let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001527 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001528 "rol{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001529 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1530 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001531 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001532 "rol{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001533 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1534 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001535 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "rol{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001537 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1538 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001539 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001540 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001541 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001542 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001543 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001544 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1545 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001546 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1549
1550 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001551 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001552 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001553 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001554 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001555 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1557 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001558 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1561}
1562
Evan Chengb783fa32007-07-19 01:14:50 +00001563def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001564 "ror{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 [(set GR8:$dst, (rotr GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001566def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "ror{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001568 [(set GR16:$dst, (rotr GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001569def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001570 "ror{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001571 [(set GR32:$dst, (rotr GR32:$src, CL))]>, Imp<[CL],[]>;
1572
Evan Chengb783fa32007-07-19 01:14:50 +00001573def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001574 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001576def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001577 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001579def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001580 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1582
1583// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001584def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001585 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001586 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001587def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001588 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001589 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001590def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001591 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001592 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1593
1594let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001595 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001596 "ror{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001597 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1598 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001599 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001600 "ror{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001601 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1602 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001603 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001604 "ror{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001605 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1606 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001607 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001608 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001610 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001611 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001612 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1613 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001614 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001615 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001616 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1617
1618 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001619 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001620 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001621 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001622 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001623 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001624 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1625 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001626 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001627 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001628 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1629}
1630
1631
1632
1633// Double shift instructions (generalizations of rotate)
Evan Chengb783fa32007-07-19 01:14:50 +00001634def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001635 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>,
1637 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001638def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001639 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001640 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>,
1641 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001642def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001643 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1645 Imp<[CL],[]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001646def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1649 Imp<[CL],[]>, TB, OpSize;
1650
1651let isCommutable = 1 in { // These instructions commute to each other.
1652def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001653 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001654 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001655 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1656 (i8 imm:$src3)))]>,
1657 TB;
1658def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001659 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001660 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001661 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1662 (i8 imm:$src3)))]>,
1663 TB;
1664def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001665 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001666 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001667 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1668 (i8 imm:$src3)))]>,
1669 TB, OpSize;
1670def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001671 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001672 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001673 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1674 (i8 imm:$src3)))]>,
1675 TB, OpSize;
1676}
1677
1678let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001679 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001681 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1682 addr:$dst)]>,
1683 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001684 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001685 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001686 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1687 addr:$dst)]>,
1688 Imp<[CL],[]>, TB;
1689 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001690 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001691 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001692 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1693 (i8 imm:$src3)), addr:$dst)]>,
1694 TB;
1695 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001696 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001697 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001698 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1699 (i8 imm:$src3)), addr:$dst)]>,
1700 TB;
1701
Evan Chengb783fa32007-07-19 01:14:50 +00001702 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001703 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001704 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
1705 addr:$dst)]>,
1706 Imp<[CL],[]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001707 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001709 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
1710 addr:$dst)]>,
1711 Imp<[CL],[]>, TB, OpSize;
1712 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001713 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001715 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1716 (i8 imm:$src3)), addr:$dst)]>,
1717 TB, OpSize;
1718 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001719 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1722 (i8 imm:$src3)), addr:$dst)]>,
1723 TB, OpSize;
1724}
1725
1726
1727// Arithmetic.
1728let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001729def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001730 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001731 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1732let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001733def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001734 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001735 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001736def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001737 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001738 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1739} // end isConvertibleToThreeAddress
1740} // end isCommutable
Evan Chengb783fa32007-07-19 01:14:50 +00001741def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001742 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001743 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001744def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001745 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001746 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001747def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001748 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001749 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1750
Evan Chengb783fa32007-07-19 01:14:50 +00001751def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001752 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001753 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1754
1755let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001756def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001757 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001758 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001759def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001760 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001761 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001762def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001763 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001764 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>,
1765 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001766def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001767 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001768 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
1769}
1770
1771let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001772 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001775 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001776 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001777 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
1778 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001779 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001780 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001781 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001782 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001784 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001785 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1788 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001789 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001790 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001791 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001792 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001793 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001794 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1795 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001796 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001797 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001798 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1799}
1800
1801let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001802def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001803 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001804 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1805}
Evan Chengb783fa32007-07-19 01:14:50 +00001806def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$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, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001809def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001810 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001811 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001812def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001814 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1815
1816let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001817 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001818 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001819 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001820 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001821 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001822 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001823 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001824 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001825 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1826}
1827
Evan Chengb783fa32007-07-19 01:14:50 +00001828def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001831def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001834def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001837def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001838 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001839 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001840def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001842 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001843def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001844 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1846
Evan Chengb783fa32007-07-19 01:14:50 +00001847def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001848 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001849 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001850def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001851 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001852 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001853def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001854 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001856def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001857 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001858 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
1859 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001860def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1863let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001864 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001865 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001867 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001868 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
1870 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001871 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001872 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001873 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001874 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001876 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001877 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1880 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001881 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001882 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001883 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001884 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1887 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001888 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001889 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001890 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1891}
1892
Evan Chengb783fa32007-07-19 01:14:50 +00001893def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
1896
1897let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001898 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001899 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001900 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001901 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001904 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001905 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001906 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001907 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1910}
Evan Chengb783fa32007-07-19 01:14:50 +00001911def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001914def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001915 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001916 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001917def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001919 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
1920
1921let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001922def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001923 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001924 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001925def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001926 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001927 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
1928}
Evan Chengb783fa32007-07-19 01:14:50 +00001929def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001930 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
1932 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001933def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001935 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
1936
1937} // end Two Address instructions
1938
1939// Suprisingly enough, these are not two address instructions!
1940def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00001941 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001942 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
1944def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00001945 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001946 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
1948def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001949 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001950 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001951 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
1952 OpSize;
1953def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001954 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
1957
1958def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00001959 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001960 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
1962 OpSize;
1963def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00001964 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001965 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001966 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
1967def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001968 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001969 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
1971 OpSize;
1972def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001973 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001974 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
1976
1977//===----------------------------------------------------------------------===//
1978// Test instructions are just like AND, except they don't generate a result.
1979//
1980let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00001981def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001983 [(X86cmp (and GR8:$src1, GR8:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001984def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001985 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001986 [(X86cmp (and GR16:$src1, GR16:$src2), 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001987def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001988 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001989 [(X86cmp (and GR32:$src1, GR32:$src2), 0)]>;
1990}
1991
Evan Chengb783fa32007-07-19 01:14:50 +00001992def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001993 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001994 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001995def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001996 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001997 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0)]>,
1998 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001999def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0)]>;
2002
2003def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002004 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002005 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002006 [(X86cmp (and GR8:$src1, imm:$src2), 0)]>;
2007def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002008 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002009 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010 [(X86cmp (and GR16:$src1, imm:$src2), 0)]>, OpSize;
2011def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002012 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002013 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014 [(X86cmp (and GR32:$src1, imm:$src2), 0)]>;
2015
2016def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002017 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002018 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0)]>;
2020def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002021 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0)]>,
2024 OpSize;
2025def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002026 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0)]>;
2029
2030
2031// Condition code ops, incl. set if equal/not equal/...
Evan Chengb783fa32007-07-19 01:14:50 +00002032def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>, Imp<[AH],[]>; // flags = AH
2033def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>, Imp<[],[AH]>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034
2035def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002036 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002037 "sete\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002038 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2039 TB; // GR8 = ==
2040def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002041 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002042 "sete\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002043 [(store (X86setcc X86_COND_E), addr:$dst)]>,
2044 TB; // [mem8] = ==
2045def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002046 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002047 "setne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002048 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2049 TB; // GR8 = !=
2050def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002051 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "setne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
2054 TB; // [mem8] = !=
2055def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002056 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002057 "setl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002058 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2059 TB; // GR8 = < signed
2060def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002061 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002062 "setl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002063 [(store (X86setcc X86_COND_L), addr:$dst)]>,
2064 TB; // [mem8] = < signed
2065def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002066 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002067 "setge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002068 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2069 TB; // GR8 = >= signed
2070def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002071 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002072 "setge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002073 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
2074 TB; // [mem8] = >= signed
2075def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002076 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002077 "setle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2079 TB; // GR8 = <= signed
2080def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002081 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002082 "setle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002083 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
2084 TB; // [mem8] = <= signed
2085def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002086 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002087 "setg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2089 TB; // GR8 = > signed
2090def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002091 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002092 "setg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002093 [(store (X86setcc X86_COND_G), addr:$dst)]>,
2094 TB; // [mem8] = > signed
2095
2096def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002097 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002098 "setb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002099 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2100 TB; // GR8 = < unsign
2101def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002102 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002103 "setb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104 [(store (X86setcc X86_COND_B), addr:$dst)]>,
2105 TB; // [mem8] = < unsign
2106def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002107 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002108 "setae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002109 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2110 TB; // GR8 = >= unsign
2111def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002112 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002113 "setae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002114 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
2115 TB; // [mem8] = >= unsign
2116def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002117 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002118 "setbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002119 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2120 TB; // GR8 = <= unsign
2121def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002122 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002123 "setbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002124 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
2125 TB; // [mem8] = <= unsign
2126def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002127 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002128 "seta\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002129 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2130 TB; // GR8 = > signed
2131def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002132 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002133 "seta\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 [(store (X86setcc X86_COND_A), addr:$dst)]>,
2135 TB; // [mem8] = > signed
2136
2137def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002138 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002139 "sets\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002140 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2141 TB; // GR8 = <sign bit>
2142def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002143 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002144 "sets\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002145 [(store (X86setcc X86_COND_S), addr:$dst)]>,
2146 TB; // [mem8] = <sign bit>
2147def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002148 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002149 "setns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002150 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2151 TB; // GR8 = !<sign bit>
2152def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002153 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002154 "setns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002155 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
2156 TB; // [mem8] = !<sign bit>
2157def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002158 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002159 "setp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002160 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2161 TB; // GR8 = parity
2162def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002163 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002164 "setp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002165 [(store (X86setcc X86_COND_P), addr:$dst)]>,
2166 TB; // [mem8] = parity
2167def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002168 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002169 "setnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002170 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2171 TB; // GR8 = not parity
2172def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002173 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002174 "setnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002175 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
2176 TB; // [mem8] = not parity
2177
2178// Integer comparisons
2179def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002180 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002181 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002182 [(X86cmp GR8:$src1, GR8:$src2)]>;
2183def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002184 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002185 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002186 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
2187def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002188 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002189 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002190 [(X86cmp GR32:$src1, GR32:$src2)]>;
2191def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002192 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002194 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
2195def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002196 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002197 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002198 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
2199def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002200 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002201 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002202 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
2203def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002204 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002205 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002206 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
2207def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002208 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002209 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002210 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
2211def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002212 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
2215def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002216 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002217 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002218 [(X86cmp GR8:$src1, imm:$src2)]>;
2219def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002220 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002221 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002222 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
2223def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002224 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002225 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002226 [(X86cmp GR32:$src1, imm:$src2)]>;
2227def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002228 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002229 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
2231def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002232 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002233 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
2235def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002236 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002237 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002238 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
2239def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002240 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002241 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002242 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
2243def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002244 (outs), (ins i16mem:$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 (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
2247def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002248 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002249 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002250 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
2251def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002252 (outs), (ins GR32:$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 GR32:$src1, i32immSExt8:$src2)]>;
2255
2256// Sign/Zero extenders
Evan Chengb783fa32007-07-19 01:14:50 +00002257def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002258 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002259 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002260def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002261 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002262 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002263def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002264 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002265 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002266def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002267 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002268 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002269def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002270 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002271 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002272def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002273 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002274 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2275
Evan Chengb783fa32007-07-19 01:14:50 +00002276def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002277 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002278 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002279def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002280 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002281 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002282def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002283 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002284 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002285def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002286 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002287 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002288def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002289 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002291def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002292 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002293 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2294
Evan Chengb783fa32007-07-19 01:14:50 +00002295def CBW : I<0x98, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002296 "{cbtw|cbw}", []>, Imp<[AL],[AX]>, OpSize; // AX = signext(AL)
Evan Chengb783fa32007-07-19 01:14:50 +00002297def CWDE : I<0x98, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002298 "{cwtl|cwde}", []>, Imp<[AX],[EAX]>; // EAX = signext(AX)
2299
Evan Chengb783fa32007-07-19 01:14:50 +00002300def CWD : I<0x99, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002301 "{cwtd|cwd}", []>, Imp<[AX],[AX,DX]>, OpSize; // DX:AX = signext(AX)
Evan Chengb783fa32007-07-19 01:14:50 +00002302def CDQ : I<0x99, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002303 "{cltd|cdq}", []>, Imp<[EAX],[EAX,EDX]>; // EDX:EAX = signext(EAX)
2304
2305
2306//===----------------------------------------------------------------------===//
2307// Alias Instructions
2308//===----------------------------------------------------------------------===//
2309
2310// Alias instructions that map movr0 to xor.
2311// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Chengb783fa32007-07-19 01:14:50 +00002312def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002313 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002314 [(set GR8:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002315def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002316 "xor{w}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002317 [(set GR16:$dst, 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002318def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002319 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002320 [(set GR32:$dst, 0)]>;
2321
2322// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2323// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengb783fa32007-07-19 01:14:50 +00002324def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002325 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002326def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002327 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002328
Evan Chengb783fa32007-07-19 01:14:50 +00002329def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002330 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002331def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002332 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00002333def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002334 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002335def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002336 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00002337def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002338 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002339def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002340 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002341
2342//===----------------------------------------------------------------------===//
2343// Thread Local Storage Instructions
2344//
2345
Evan Chengb783fa32007-07-19 01:14:50 +00002346def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
Dan Gohman91888f02007-07-31 20:11:57 +00002347 "leal\t${sym:mem}(,%ebx,1), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002348 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>,
2349 Imp<[EBX],[]>;
2350
2351let AddedComplexity = 10 in
Evan Chengb783fa32007-07-19 01:14:50 +00002352def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002353 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002354 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2355
2356let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002357def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002358 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002359 [(set GR32:$dst,
2360 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2361
Evan Chengb783fa32007-07-19 01:14:50 +00002362def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002363 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002364 [(set GR32:$dst, X86TLStp)]>;
2365
2366//===----------------------------------------------------------------------===//
2367// DWARF Pseudo Instructions
2368//
2369
Evan Chengb783fa32007-07-19 01:14:50 +00002370def DWARF_LOC : I<0, Pseudo, (outs),
2371 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohmanf8133d72007-07-26 15:24:15 +00002372 "; .loc ${file:debug}, ${line:debug}, ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002373 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2374 (i32 imm:$file))]>;
2375
2376//===----------------------------------------------------------------------===//
2377// EH Pseudo Instructions
2378//
2379let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002380 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002381def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002382 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002383 [(X86ehret GR32:$addr)]>;
2384
2385}
2386
2387//===----------------------------------------------------------------------===//
2388// Non-Instruction Patterns
2389//===----------------------------------------------------------------------===//
2390
2391// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2392def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2393def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2394def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2395def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2396def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2397
2398def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2399 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2400def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2401 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2402def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2403 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2404def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2405 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2406
2407def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2408 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2409def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2410 (MOV32mi addr:$dst, texternalsym:$src)>;
2411
2412// Calls
2413def : Pat<(X86tailcall GR32:$dst),
2414 (CALL32r GR32:$dst)>;
2415
2416def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2417 (CALLpcrel32 tglobaladdr:$dst)>;
2418def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2419 (CALLpcrel32 texternalsym:$dst)>;
2420
2421def : Pat<(X86call (i32 tglobaladdr:$dst)),
2422 (CALLpcrel32 tglobaladdr:$dst)>;
2423def : Pat<(X86call (i32 texternalsym:$dst)),
2424 (CALLpcrel32 texternalsym:$dst)>;
2425
2426// X86 specific add which produces a flag.
2427def : Pat<(addc GR32:$src1, GR32:$src2),
2428 (ADD32rr GR32:$src1, GR32:$src2)>;
2429def : Pat<(addc GR32:$src1, (load addr:$src2)),
2430 (ADD32rm GR32:$src1, addr:$src2)>;
2431def : Pat<(addc GR32:$src1, imm:$src2),
2432 (ADD32ri GR32:$src1, imm:$src2)>;
2433def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2434 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2435
2436def : Pat<(subc GR32:$src1, GR32:$src2),
2437 (SUB32rr GR32:$src1, GR32:$src2)>;
2438def : Pat<(subc GR32:$src1, (load addr:$src2)),
2439 (SUB32rm GR32:$src1, addr:$src2)>;
2440def : Pat<(subc GR32:$src1, imm:$src2),
2441 (SUB32ri GR32:$src1, imm:$src2)>;
2442def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2443 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2444
2445def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2446 (MOV8mi addr:$dst, imm:$src)>;
2447def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2448 (MOV8mr addr:$dst, GR8:$src)>;
2449
2450// Comparisons.
2451
2452// TEST R,R is smaller than CMP R,0
2453def : Pat<(X86cmp GR8:$src1, 0),
2454 (TEST8rr GR8:$src1, GR8:$src1)>;
2455def : Pat<(X86cmp GR16:$src1, 0),
2456 (TEST16rr GR16:$src1, GR16:$src1)>;
2457def : Pat<(X86cmp GR32:$src1, 0),
2458 (TEST32rr GR32:$src1, GR32:$src1)>;
2459
2460// {s|z}extload bool -> {s|z}extload byte
2461def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2462def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2463def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2464def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2465def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2466
2467// extload bool -> extload byte
2468def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2469def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2470def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2471def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2472def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2473def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2474
2475// anyext -> zext
2476def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2477def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2478def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2479def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2480def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2481def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2482
2483//===----------------------------------------------------------------------===//
2484// Some peepholes
2485//===----------------------------------------------------------------------===//
2486
2487// (shl x, 1) ==> (add x, x)
2488def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2489def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2490def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2491
2492// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2493def : Pat<(or (srl GR32:$src1, CL:$amt),
2494 (shl GR32:$src2, (sub 32, CL:$amt))),
2495 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2496
2497def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2498 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2499 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2500
2501// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2502def : Pat<(or (shl GR32:$src1, CL:$amt),
2503 (srl GR32:$src2, (sub 32, CL:$amt))),
2504 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2505
2506def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2507 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2508 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2509
2510// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2511def : Pat<(or (srl GR16:$src1, CL:$amt),
2512 (shl GR16:$src2, (sub 16, CL:$amt))),
2513 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2514
2515def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2516 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2517 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2518
2519// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2520def : Pat<(or (shl GR16:$src1, CL:$amt),
2521 (srl GR16:$src2, (sub 16, CL:$amt))),
2522 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2523
2524def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2525 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2526 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2527
2528
2529//===----------------------------------------------------------------------===//
2530// Floating Point Stack Support
2531//===----------------------------------------------------------------------===//
2532
2533include "X86InstrFPStack.td"
2534
2535//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00002536// X86-64 Support
2537//===----------------------------------------------------------------------===//
2538
2539include "X86InstrX86-64.td"
2540
2541//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002542// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2543//===----------------------------------------------------------------------===//
2544
2545include "X86InstrMMX.td"
2546
2547//===----------------------------------------------------------------------===//
2548// XMM Floating point support (requires SSE / SSE2)
2549//===----------------------------------------------------------------------===//
2550
2551include "X86InstrSSE.td"