blob: 5278ccc84b949d630c1fe80af25b3ee14fb4f52d [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
20def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
24def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
26def SDTX86Cmov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>]>;
29
30def SDTX86BrCond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>]>;
32
33def SDTX86SetCC : SDTypeProfile<1, 1,
34 [SDTCisVT<0, i8>, SDTCisVT<1, i8>]>;
35
36def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
37
38def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
39def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
40 SDTCisVT<1, i32> ]>;
41
42def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
43
44def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
45
46def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
47
48def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
49
50def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
51
52def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
53
54def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
55
56def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
57def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
58
59def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
60 [SDNPHasChain, SDNPOutFlag]>;
61
62def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
63 [SDNPInFlag, SDNPOutFlag]>;
64def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
65 [SDNPHasChain, SDNPInFlag]>;
66def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
67 [SDNPInFlag, SDNPOutFlag]>;
68
69def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
70 [SDNPHasChain, SDNPOptInFlag]>;
71
72def X86callseq_start :
73 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
74 [SDNPHasChain, SDNPOutFlag]>;
75def X86callseq_end :
76 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
77 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
78
79def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
80 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
81
82def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
83 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
84
85def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
86 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
87def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
89
90def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
91 [SDNPHasChain, SDNPOutFlag]>;
92
93def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
94def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
95
96def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
97 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
98def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
99
100def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
101 [SDNPHasChain]>;
102
103
104//===----------------------------------------------------------------------===//
105// X86 Operand Definitions.
106//
107
108// *mem - Operand definitions for the funky X86 addressing mode operands.
109//
110class X86MemOperand<string printMethod> : Operand<iPTR> {
111 let PrintMethod = printMethod;
112 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
113}
114
115def i8mem : X86MemOperand<"printi8mem">;
116def i16mem : X86MemOperand<"printi16mem">;
117def i32mem : X86MemOperand<"printi32mem">;
118def i64mem : X86MemOperand<"printi64mem">;
119def i128mem : X86MemOperand<"printi128mem">;
120def f32mem : X86MemOperand<"printf32mem">;
121def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000122def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123def f128mem : X86MemOperand<"printf128mem">;
124
125def lea32mem : Operand<i32> {
126 let PrintMethod = "printi32mem";
127 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
128}
129
130def SSECC : Operand<i8> {
131 let PrintMethod = "printSSECC";
132}
133
134def piclabel: Operand<i32> {
135 let PrintMethod = "printPICLabel";
136}
137
138// A couple of more descriptive operand definitions.
139// 16-bits but only 8 bits are significant.
140def i16i8imm : Operand<i16>;
141// 32-bits but only 8 bits are significant.
142def i32i8imm : Operand<i32>;
143
144// Branch targets have OtherVT type.
145def brtarget : Operand<OtherVT>;
146
147//===----------------------------------------------------------------------===//
148// X86 Complex Pattern Definitions.
149//
150
151// Define X86 specific addressing mode.
152def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
153def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
154 [add, mul, shl, or, frameindex], []>;
155
156//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000157// X86 Instruction Predicate Definitions.
158def HasMMX : Predicate<"Subtarget->hasMMX()">;
159def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
160def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
161def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
162def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
163def FPStack : Predicate<"!Subtarget->hasSSE2()">;
164def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
165def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Evan Cheng09e13792007-08-01 23:45:51 +0000166def HasLow4G : Predicate<"Subtarget->hasLow4GUserSpaceAddress()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
168def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
169def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
170
171//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000172// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173//
174
Evan Cheng86ab7d32007-07-31 08:04:03 +0000175include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176
177//===----------------------------------------------------------------------===//
178// Pattern fragments...
179//
180
181// X86 specific condition code. These correspond to CondCode in
182// X86InstrInfo.h. They must be kept in synch.
183def X86_COND_A : PatLeaf<(i8 0)>;
184def X86_COND_AE : PatLeaf<(i8 1)>;
185def X86_COND_B : PatLeaf<(i8 2)>;
186def X86_COND_BE : PatLeaf<(i8 3)>;
187def X86_COND_E : PatLeaf<(i8 4)>;
188def X86_COND_G : PatLeaf<(i8 5)>;
189def X86_COND_GE : PatLeaf<(i8 6)>;
190def X86_COND_L : PatLeaf<(i8 7)>;
191def X86_COND_LE : PatLeaf<(i8 8)>;
192def X86_COND_NE : PatLeaf<(i8 9)>;
193def X86_COND_NO : PatLeaf<(i8 10)>;
194def X86_COND_NP : PatLeaf<(i8 11)>;
195def X86_COND_NS : PatLeaf<(i8 12)>;
196def X86_COND_O : PatLeaf<(i8 13)>;
197def X86_COND_P : PatLeaf<(i8 14)>;
198def X86_COND_S : PatLeaf<(i8 15)>;
199
200def i16immSExt8 : PatLeaf<(i16 imm), [{
201 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
202 // sign extended field.
203 return (int16_t)N->getValue() == (int8_t)N->getValue();
204}]>;
205
206def i32immSExt8 : PatLeaf<(i32 imm), [{
207 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
208 // sign extended field.
209 return (int32_t)N->getValue() == (int8_t)N->getValue();
210}]>;
211
212// Helper fragments for loads.
213def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
214def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
215def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
216def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
217
218def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
219def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000220def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000221
222def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
223def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
224def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
225def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
226def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
227
228def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
229def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
230def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
231def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
232def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
233def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
234
235def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
236def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
237def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
238def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
239def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
240def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
241
242//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243// Instruction list...
244//
245
246// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
247// a stack adjustment and the codegen must know that they may modify the stack
248// pointer before prolog-epilog rewriting occurs.
Evan Chengb783fa32007-07-19 01:14:50 +0000249def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt), "#ADJCALLSTACKDOWN",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000250 [(X86callseq_start imm:$amt)]>, Imp<[ESP],[ESP]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000251def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000252 "#ADJCALLSTACKUP",
253 [(X86callseq_end imm:$amt1, imm:$amt2)]>,
254 Imp<[ESP],[ESP]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000255def IMPLICIT_USE : I<0, Pseudo, (outs), (ins variable_ops),
256 "#IMPLICIT_USE", []>;
257def IMPLICIT_DEF : I<0, Pseudo, (outs variable_ops), (ins),
258 "#IMPLICIT_DEF", []>;
259def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000260 "#IMPLICIT_DEF $dst",
261 [(set GR8:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000262def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263 "#IMPLICIT_DEF $dst",
264 [(set GR16:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000265def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266 "#IMPLICIT_DEF $dst",
267 [(set GR32:$dst, (undef))]>;
268
269// Nop
Evan Chengb783fa32007-07-19 01:14:50 +0000270def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272
273//===----------------------------------------------------------------------===//
274// Control Flow Instructions...
275//
276
277// Return instructions.
278let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +0000279 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000280 def RET : I<0xC3, RawFrm, (outs), (ins), "ret", [(X86retflag 0)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000281 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt), "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000282 [(X86retflag imm:$amt)]>;
283}
284
285// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000286let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000287 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
288 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000289
290// Indirect branches
291let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000292 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000293
Evan Cheng37e7c752007-07-21 00:34:19 +0000294let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000295 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000296 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000297 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298 [(brind (loadi32 addr:$dst))]>;
299}
300
301// Conditional branches
Dan Gohman91888f02007-07-31 20:11:57 +0000302def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000303 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000304def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000306def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000308def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000310def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000312def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
314
Dan Gohman91888f02007-07-31 20:11:57 +0000315def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000316 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000317def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000319def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000321def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
323
Dan Gohman91888f02007-07-31 20:11:57 +0000324def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000325 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000326def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000328def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000330def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000332def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000334def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
336
337//===----------------------------------------------------------------------===//
338// Call Instructions...
339//
Evan Cheng37e7c752007-07-21 00:34:19 +0000340let isCall = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341 // All calls clobber the non-callee saved registers...
342 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
343 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
344 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000345 def CALLpcrel32 : I<0xE8, RawFrm, (outs), (ins i32imm:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000346 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000347 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000348 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000349 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000350 "call\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351 }
352
353// Tail call stuff.
Evan Cheng37e7c752007-07-21 00:34:19 +0000354let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000355 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAIL CALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000357let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000358 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp\t{*}$dst # TAIL CALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000359 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000360let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000361 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000362 "jmp\t{*}$dst # TAIL CALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000363
364//===----------------------------------------------------------------------===//
365// Miscellaneous Instructions...
366//
367def LEAVE : I<0xC9, RawFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000368 (outs), (ins), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369def POP32r : I<0x58, AddRegFrm,
Dan Gohman91888f02007-07-31 20:11:57 +0000370 (outs GR32:$reg), (ins), "pop{l}\t$reg", []>, Imp<[ESP],[ESP]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000371
372def PUSH32r : I<0x50, AddRegFrm,
Dan Gohman91888f02007-07-31 20:11:57 +0000373 (outs), (ins GR32:$reg), "push{l}\t$reg", []>, Imp<[ESP],[ESP]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000374
Evan Chengb783fa32007-07-19 01:14:50 +0000375def MovePCtoStack : I<0, Pseudo, (outs), (ins piclabel:$label),
Dan Gohman91888f02007-07-31 20:11:57 +0000376 "call\t$label", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000377
378let isTwoAddress = 1 in // GR32 = bswap GR32
379 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000380 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000381 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
383
Evan Chengb783fa32007-07-19 01:14:50 +0000384// FIXME: Model xchg* as two address instructions?
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000385def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
Evan Chengb783fa32007-07-19 01:14:50 +0000386 (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000387 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000389 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000390 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000392 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000393 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394
395def XCHG8mr : I<0x86, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000396 (outs), (ins i8mem:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000397 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000398def XCHG16mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000399 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000400 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000401def XCHG32mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000402 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000403 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000404def XCHG8rm : I<0x86, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000405 (outs), (ins GR8:$src1, i8mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000406 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407def XCHG16rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000408 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000409 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410def XCHG32rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000411 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000412 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413
414def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000415 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000416 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000418 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000419 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
421
Evan Chengb783fa32007-07-19 01:14:50 +0000422def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423 [(X86rep_movs i8)]>,
424 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000425def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426 [(X86rep_movs i16)]>,
427 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000428def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000429 [(X86rep_movs i32)]>,
430 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
431
Evan Chengb783fa32007-07-19 01:14:50 +0000432def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000433 [(X86rep_stos i8)]>,
434 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000435def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436 [(X86rep_stos i16)]>,
437 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000438def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000439 [(X86rep_stos i32)]>,
440 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
441
Evan Chengb783fa32007-07-19 01:14:50 +0000442def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000443 TB, Imp<[],[RAX,RDX]>;
444
445//===----------------------------------------------------------------------===//
446// Input/Output Instructions...
447//
Evan Chengb783fa32007-07-19 01:14:50 +0000448def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000449 "in{b}\t{%dx, %al|%AL, %DX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000450 []>, Imp<[DX], [AL]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000451def IN16rr : I<0xED, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000452 "in{w}\t{%dx, %ax|%AX, %DX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000453 []>, Imp<[DX], [AX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000454def IN32rr : I<0xED, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000455 "in{l}\t{%dx, %eax|%EAX, %DX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456 []>, Imp<[DX],[EAX]>;
457
Evan Chengb783fa32007-07-19 01:14:50 +0000458def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000459 "in{b}\t{$port, %al|%AL, $port}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000460 []>,
461 Imp<[], [AL]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000462def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000463 "in{w}\t{$port, %ax|%AX, $port}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000464 []>,
465 Imp<[], [AX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000466def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000467 "in{l}\t{$port, %eax|%EAX, $port}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000468 []>,
469 Imp<[],[EAX]>;
470
Evan Chengb783fa32007-07-19 01:14:50 +0000471def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000472 "out{b}\t{%al, %dx|%DX, %AL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473 []>, Imp<[DX, AL], []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000474def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000475 "out{w}\t{%ax, %dx|%DX, %AX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476 []>, Imp<[DX, AX], []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000477def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +0000478 "out{l}\t{%eax, %dx|%DX, %EAX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000479 []>, Imp<[DX, EAX], []>;
480
Evan Chengb783fa32007-07-19 01:14:50 +0000481def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000482 "out{b}\t{%al, $port|$port, %AL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483 []>,
484 Imp<[AL], []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000485def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000486 "out{w}\t{%ax, $port|$port, %AX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000487 []>,
488 Imp<[AX], []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000489def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Dan Gohman91888f02007-07-31 20:11:57 +0000490 "out{l}\t{%eax, $port|$port, %EAX}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000491 []>,
492 Imp<[EAX], []>;
493
494//===----------------------------------------------------------------------===//
495// Move Instructions...
496//
Evan Chengb783fa32007-07-19 01:14:50 +0000497def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000498 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000499def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000500 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000501def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000502 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000503let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000504def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000505 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000506 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000507def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000508 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000510def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000511 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512 [(set GR32:$dst, imm:$src)]>;
513}
Evan Chengb783fa32007-07-19 01:14:50 +0000514def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000515 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000517def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000518 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000520def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000521 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522 [(store (i32 imm:$src), addr:$dst)]>;
523
Evan Chengb783fa32007-07-19 01:14:50 +0000524def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000525 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000527def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000528 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000530def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000531 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532 [(set GR32:$dst, (load addr:$src))]>;
533
Evan Chengb783fa32007-07-19 01:14:50 +0000534def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000535 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000537def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000538 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000540def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000541 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542 [(store GR32:$src, addr:$dst)]>;
543
544//===----------------------------------------------------------------------===//
545// Fixed-Register Multiplication and Division Instructions...
546//
547
548// Extra precision multiplication
Dan Gohman91888f02007-07-31 20:11:57 +0000549def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
551 // This probably ought to be moved to a def : Pat<> if the
552 // syntax can be accepted.
Evan Cheng508fe8b2007-08-02 05:48:35 +0000553 []>,
Evan Chenge3dc8a62007-08-01 20:22:37 +0000554 Imp<[AL],[AL,AH]>; // AL,AH = AL*GR8
Dan Gohman91888f02007-07-31 20:11:57 +0000555def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
Dan Gohman91888f02007-07-31 20:11:57 +0000557def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000558 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000559def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000560 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
562 // This probably ought to be moved to a def : Pat<> if the
563 // syntax can be accepted.
Evan Cheng508fe8b2007-08-02 05:48:35 +0000564 []>,
565 Imp<[AL],[AL,AH]>; // AL,AH = AL*[mem8]
Evan Chengb783fa32007-07-19 01:14:50 +0000566def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000567 "mul{w}\t$src", []>, Imp<[AX],[AX,DX]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000568 OpSize; // AX,DX = AX*[mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000569def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng508fe8b2007-08-02 05:48:35 +0000570 "mul{l}\t$src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000571
Dan Gohman91888f02007-07-31 20:11:57 +0000572def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>,
Evan Cheng508fe8b2007-08-02 05:48:35 +0000573 Imp<[AL],[AL,AH]>; // AL,AH = AL*GR8
Dan Gohman91888f02007-07-31 20:11:57 +0000574def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*GR16
Dan Gohman91888f02007-07-31 20:11:57 +0000576def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000577 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000578def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng508fe8b2007-08-02 05:48:35 +0000579 "imul{b}\t$src", []>, Imp<[AL],[AL,AH]>; // AL,AH = AL*[mem8]
Evan Chengb783fa32007-07-19 01:14:50 +0000580def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000581 "imul{w}\t$src", []>, Imp<[AX],[AX,DX]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000582 OpSize; // AX,DX = AX*[mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000583def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000584 "imul{l}\t$src", []>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000585 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
586
587// unsigned division/remainder
Evan Chengb783fa32007-07-19 01:14:50 +0000588def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Dan Gohman91888f02007-07-31 20:11:57 +0000589 "div{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000590def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Dan Gohman91888f02007-07-31 20:11:57 +0000591 "div{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000592def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Dan Gohman91888f02007-07-31 20:11:57 +0000593 "div{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000594def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Dan Gohman91888f02007-07-31 20:11:57 +0000595 "div{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000596def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Dan Gohman91888f02007-07-31 20:11:57 +0000597 "div{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000598def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Dan Gohman91888f02007-07-31 20:11:57 +0000599 "div{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000600
601// Signed division/remainder.
Evan Chengb783fa32007-07-19 01:14:50 +0000602def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Dan Gohman91888f02007-07-31 20:11:57 +0000603 "idiv{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000604def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Dan Gohman91888f02007-07-31 20:11:57 +0000605 "idiv{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000606def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Dan Gohman91888f02007-07-31 20:11:57 +0000607 "idiv{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000608def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Dan Gohman91888f02007-07-31 20:11:57 +0000609 "idiv{b}\t$src", []>, Imp<[AX],[AX]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000610def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Dan Gohman91888f02007-07-31 20:11:57 +0000611 "idiv{w}\t$src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000612def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Dan Gohman91888f02007-07-31 20:11:57 +0000613 "idiv{l}\t$src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000614
615
616//===----------------------------------------------------------------------===//
617// Two address Instructions...
618//
619let isTwoAddress = 1 in {
620
621// Conditional moves
622def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000623 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000624 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000625 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
626 X86_COND_B))]>,
627 TB, OpSize;
628def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000629 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000630 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000631 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
632 X86_COND_B))]>,
633 TB, OpSize;
634def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000635 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000636 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000637 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
638 X86_COND_B))]>,
639 TB;
640def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000641 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000642 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000643 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
644 X86_COND_B))]>,
645 TB;
646
647def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000648 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000649 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000650 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
651 X86_COND_AE))]>,
652 TB, OpSize;
653def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000654 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000655 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000656 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
657 X86_COND_AE))]>,
658 TB, OpSize;
659def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000660 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000661 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000662 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
663 X86_COND_AE))]>,
664 TB;
665def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000666 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000667 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000668 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
669 X86_COND_AE))]>,
670 TB;
671
672def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000673 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000674 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000675 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
676 X86_COND_E))]>,
677 TB, OpSize;
678def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000679 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000680 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000681 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
682 X86_COND_E))]>,
683 TB, OpSize;
684def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000685 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000686 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
688 X86_COND_E))]>,
689 TB;
690def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000691 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000692 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
694 X86_COND_E))]>,
695 TB;
696
697def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000698 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000699 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000700 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
701 X86_COND_NE))]>,
702 TB, OpSize;
703def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000704 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000705 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000706 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
707 X86_COND_NE))]>,
708 TB, OpSize;
709def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000710 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000711 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000712 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
713 X86_COND_NE))]>,
714 TB;
715def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000716 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000717 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000718 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
719 X86_COND_NE))]>,
720 TB;
721
722def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000723 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000724 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
726 X86_COND_BE))]>,
727 TB, OpSize;
728def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000729 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000730 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
732 X86_COND_BE))]>,
733 TB, OpSize;
734def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000735 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000736 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
738 X86_COND_BE))]>,
739 TB;
740def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000741 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000742 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
744 X86_COND_BE))]>,
745 TB;
746
747def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000748 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000749 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000750 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
751 X86_COND_A))]>,
752 TB, OpSize;
753def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000754 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000755 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
757 X86_COND_A))]>,
758 TB, OpSize;
759def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000760 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000761 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
763 X86_COND_A))]>,
764 TB;
765def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000766 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000767 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
769 X86_COND_A))]>,
770 TB;
771
772def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000773 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000774 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000775 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
776 X86_COND_L))]>,
777 TB, OpSize;
778def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000779 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000780 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000781 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
782 X86_COND_L))]>,
783 TB, OpSize;
784def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000785 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000786 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000787 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
788 X86_COND_L))]>,
789 TB;
790def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000791 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000792 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000793 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
794 X86_COND_L))]>,
795 TB;
796
797def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000798 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000799 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000800 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
801 X86_COND_GE))]>,
802 TB, OpSize;
803def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000804 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000805 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000806 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
807 X86_COND_GE))]>,
808 TB, OpSize;
809def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000810 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000811 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000812 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
813 X86_COND_GE))]>,
814 TB;
815def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000816 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000817 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000818 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
819 X86_COND_GE))]>,
820 TB;
821
822def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000823 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000824 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
826 X86_COND_LE))]>,
827 TB, OpSize;
828def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000829 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000830 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000831 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
832 X86_COND_LE))]>,
833 TB, OpSize;
834def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000835 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000836 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
838 X86_COND_LE))]>,
839 TB;
840def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000841 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000842 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000843 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
844 X86_COND_LE))]>,
845 TB;
846
847def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000848 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000849 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000850 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
851 X86_COND_G))]>,
852 TB, OpSize;
853def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000854 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000855 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000856 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
857 X86_COND_G))]>,
858 TB, OpSize;
859def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000860 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000861 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000862 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
863 X86_COND_G))]>,
864 TB;
865def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000866 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000867 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000868 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
869 X86_COND_G))]>,
870 TB;
871
872def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000873 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000874 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000875 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
876 X86_COND_S))]>,
877 TB, OpSize;
878def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000879 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000880 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000881 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
882 X86_COND_S))]>,
883 TB, OpSize;
884def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000885 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000886 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000887 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
888 X86_COND_S))]>,
889 TB;
890def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000891 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000892 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000893 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
894 X86_COND_S))]>,
895 TB;
896
897def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000898 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000899 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000900 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
901 X86_COND_NS))]>,
902 TB, OpSize;
903def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000904 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000905 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000906 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
907 X86_COND_NS))]>,
908 TB, OpSize;
909def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000910 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000911 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000912 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
913 X86_COND_NS))]>,
914 TB;
915def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000916 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000917 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000918 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
919 X86_COND_NS))]>,
920 TB;
921
922def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000923 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000924 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000925 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
926 X86_COND_P))]>,
927 TB, OpSize;
928def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000929 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000930 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000931 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
932 X86_COND_P))]>,
933 TB, OpSize;
934def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000935 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000936 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000937 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
938 X86_COND_P))]>,
939 TB;
940def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000941 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000942 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000943 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
944 X86_COND_P))]>,
945 TB;
946
947def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000948 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000949 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000950 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
951 X86_COND_NP))]>,
952 TB, OpSize;
953def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000954 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000955 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000956 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
957 X86_COND_NP))]>,
958 TB, OpSize;
959def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000960 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000961 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000962 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
963 X86_COND_NP))]>,
964 TB;
965def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000966 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000967 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000968 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
969 X86_COND_NP))]>,
970 TB;
971
972
973// unary instructions
974let CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000975def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000977def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +0000979def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 [(set GR32:$dst, (ineg GR32:$src))]>;
981let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000982 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000984 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000985 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +0000986 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000987 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
988
989}
990
Dan Gohman91888f02007-07-31 20:11:57 +0000991def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000993def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000994 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +0000995def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 [(set GR32:$dst, (not GR32:$src))]>;
997let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000998 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001000 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001002 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001003 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1004}
1005} // CodeSize
1006
1007// TODO: inc/dec is slow for P4, but fast for Pentium-M.
1008let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001009def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010 [(set GR8:$dst, (add GR8:$src, 1))]>;
1011let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001012def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 [(set GR16:$dst, (add GR16:$src, 1))]>,
1014 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001015def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1017}
1018let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001019 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001021 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001023 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1025}
1026
1027let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001028def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 [(set GR8:$dst, (add GR8:$src, -1))]>;
1030let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001031def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 [(set GR16:$dst, (add GR16:$src, -1))]>,
1033 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001034def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1036}
1037
1038let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001039 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001041 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001043 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1045}
1046
1047// Logical operators...
1048let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1049def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001050 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001051 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1053def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001054 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001055 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1057def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001058 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001059 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1061}
1062
1063def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001064 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001065 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001066 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1067def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001068 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001069 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1071def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001072 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001073 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1075
1076def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001077 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001078 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1080def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001081 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001082 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001083 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1084def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001085 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001086 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001087 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1088def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001089 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001090 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1092 OpSize;
1093def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001094 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001095 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1097
1098let isTwoAddress = 0 in {
1099 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001100 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001101 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1103 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001104 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001105 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1107 OpSize;
1108 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001109 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001110 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001111 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1112 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001113 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001114 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001115 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1116 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001117 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001118 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001119 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1120 OpSize;
1121 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001122 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001123 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1125 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001126 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001127 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001128 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1129 OpSize;
1130 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001131 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001132 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1134}
1135
1136
1137let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001138def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001139 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001141def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001142 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001143 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001144def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001145 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1147}
Evan Chengb783fa32007-07-19 01:14:50 +00001148def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001149 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001151def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001152 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001154def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001155 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1157
Evan Chengb783fa32007-07-19 01:14:50 +00001158def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001159 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001160 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001161def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001162 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001163 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001164def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001165 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1167
Evan Chengb783fa32007-07-19 01:14:50 +00001168def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001169 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001170 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001171def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001172 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001173 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1174let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001175 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001176 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001178 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001179 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001180 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001181 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001182 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001183 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001184 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001185 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001186 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001187 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001188 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001189 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1190 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001191 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001192 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001194 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001195 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001196 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1197 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001198 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001199 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1201}
1202
1203
1204let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1205def XOR8rr : I<0x30, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001206 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001207 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001208 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1209def XOR16rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001210 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001211 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001212 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1213def XOR32rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001214 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001215 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1217}
1218
1219def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001220 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001221 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1223def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001224 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001225 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001226 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1227def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001228 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001229 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1231
1232def XOR8ri : Ii8<0x80, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001233 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001234 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001235 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1236def XOR16ri : Ii16<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001237 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001238 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001239 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1240def XOR32ri : Ii32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001241 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001242 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1244def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001245 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001246 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1248 OpSize;
1249def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001250 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001251 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1253let isTwoAddress = 0 in {
1254 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001255 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001256 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001257 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1258 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001259 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001260 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1262 OpSize;
1263 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001264 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001265 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1267 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001268 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001269 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001270 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1271 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001272 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001273 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001274 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1275 OpSize;
1276 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001277 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001278 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001279 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1280 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001281 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001282 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1284 OpSize;
1285 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001286 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001287 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001288 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1289}
1290
1291// Shift instructions
Evan Chengb783fa32007-07-19 01:14:50 +00001292def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001293 "shl{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001294 [(set GR8:$dst, (shl GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001295def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001296 "shl{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001297 [(set GR16:$dst, (shl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001298def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001299 "shl{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300 [(set GR32:$dst, (shl GR32:$src, CL))]>, Imp<[CL],[]>;
1301
Evan Chengb783fa32007-07-19 01:14:50 +00001302def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001303 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1305let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001306def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001307 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001309def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001310 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1312}
1313
1314// Shift left by one. Not used because (add x, x) is slightly cheaper.
Evan Chengb783fa32007-07-19 01:14:50 +00001315def SHL8r1 : I<0xD0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001316 "shl{b}\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001317def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001318 "shl{w}\t$dst", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001319def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001320 "shl{l}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001321
1322let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001323 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001324 "shl{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1326 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001327 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001328 "shl{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1330 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001331 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001332 "shl{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1334 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001335 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001336 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001338 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001339 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1341 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001342 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001343 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001344 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1345
1346 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001347 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001348 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001350 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001351 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001352 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1353 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001354 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001355 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001356 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1357}
1358
Evan Chengb783fa32007-07-19 01:14:50 +00001359def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001360 "shr{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001361 [(set GR8:$dst, (srl GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001362def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001363 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001364 [(set GR16:$dst, (srl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001365def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001366 "shr{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001367 [(set GR32:$dst, (srl GR32:$src, CL))]>, Imp<[CL],[]>;
1368
Evan Chengb783fa32007-07-19 01:14:50 +00001369def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001370 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001371 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001372def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001373 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001375def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001376 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1378
1379// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001380def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001381 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001382 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001383def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001384 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001385 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001386def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001387 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001388 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1389
1390let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001391 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001392 "shr{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1394 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001395 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001396 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001397 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1398 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001399 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001400 "shr{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001401 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1402 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001403 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001404 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001405 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001406 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001407 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1409 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001410 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001411 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1413
1414 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001415 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001416 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001417 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001418 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001419 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001420 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001421 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001422 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001423 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1424}
1425
Evan Chengb783fa32007-07-19 01:14:50 +00001426def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001427 "sar{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428 [(set GR8:$dst, (sra GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001429def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001430 "sar{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001431 [(set GR16:$dst, (sra GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001432def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001433 "sar{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001434 [(set GR32:$dst, (sra GR32:$src, CL))]>, Imp<[CL],[]>;
1435
Evan Chengb783fa32007-07-19 01:14:50 +00001436def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001437 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001439def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001440 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001441 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1442 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001443def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001444 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001445 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1446
1447// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001448def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001449 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001450 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001451def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001452 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001453 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001454def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001455 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001456 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1457
1458let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001459 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001460 "sar{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001461 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1462 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001463 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 "sar{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001465 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1466 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001467 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001468 "sar{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001469 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1470 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001471 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001472 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001474 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001475 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1477 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001478 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001479 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001480 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1481
1482 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001483 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001484 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001485 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001486 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001487 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001488 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1489 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001490 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001491 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001492 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1493}
1494
1495// Rotate instructions
1496// FIXME: provide shorter instructions when imm8 == 1
Evan Chengb783fa32007-07-19 01:14:50 +00001497def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001498 "rol{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001499 [(set GR8:$dst, (rotl GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001500def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001501 "rol{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001502 [(set GR16:$dst, (rotl GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001503def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001504 "rol{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505 [(set GR32:$dst, (rotl GR32:$src, CL))]>, Imp<[CL],[]>;
1506
Evan Chengb783fa32007-07-19 01:14:50 +00001507def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001508 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001509 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001510def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001511 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001512 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001513def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001514 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001515 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1516
1517// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001518def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001519 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001520 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001521def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001522 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001523 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001524def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001525 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001526 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1527
1528let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001529 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001530 "rol{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001531 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>,
1532 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001533 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001534 "rol{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001535 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>,
1536 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001537 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001538 "rol{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001539 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>,
1540 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001541 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001544 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001545 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001546 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1547 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001548 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001549 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001550 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1551
1552 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001553 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001554 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001555 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001556 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001557 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001558 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1559 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001560 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001561 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001562 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1563}
1564
Evan Chengb783fa32007-07-19 01:14:50 +00001565def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001566 "ror{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567 [(set GR8:$dst, (rotr GR8:$src, CL))]>, Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001568def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001569 "ror{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001570 [(set GR16:$dst, (rotr GR16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001571def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001572 "ror{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001573 [(set GR32:$dst, (rotr GR32:$src, CL))]>, Imp<[CL],[]>;
1574
Evan Chengb783fa32007-07-19 01:14:50 +00001575def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001576 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001577 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001578def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001579 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001580 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001581def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001582 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1584
1585// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001586def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001587 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001588 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001589def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001590 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001591 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001592def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001593 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001594 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1595
1596let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001597 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001598 "ror{b}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>,
1600 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001601 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "ror{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>,
1604 Imp<[CL],[]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001605 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "ror{l}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001607 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>,
1608 Imp<[CL],[]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001609 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001610 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001611 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001612 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001613 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1615 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001616 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001617 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001618 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1619
1620 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001621 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001622 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001624 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001625 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001626 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1627 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001628 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001629 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001630 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1631}
1632
1633
1634
1635// Double shift instructions (generalizations of rotate)
Evan Chengb783fa32007-07-19 01:14:50 +00001636def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001637 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001638 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>,
1639 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001640def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>,
1643 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001644def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001645 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001646 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
1647 Imp<[CL],[]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001648def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001649 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
1651 Imp<[CL],[]>, TB, OpSize;
1652
1653let isCommutable = 1 in { // These instructions commute to each other.
1654def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001655 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001656 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001657 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1658 (i8 imm:$src3)))]>,
1659 TB;
1660def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001661 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001662 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001663 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1664 (i8 imm:$src3)))]>,
1665 TB;
1666def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001667 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001668 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001669 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1670 (i8 imm:$src3)))]>,
1671 TB, OpSize;
1672def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001673 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001675 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1676 (i8 imm:$src3)))]>,
1677 TB, OpSize;
1678}
1679
1680let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001681 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001682 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001683 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
1684 addr:$dst)]>,
1685 Imp<[CL],[]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001686 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001687 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001688 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
1689 addr:$dst)]>,
1690 Imp<[CL],[]>, TB;
1691 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001692 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001693 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001694 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1695 (i8 imm:$src3)), addr:$dst)]>,
1696 TB;
1697 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001698 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001699 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001700 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1701 (i8 imm:$src3)), addr:$dst)]>,
1702 TB;
1703
Evan Chengb783fa32007-07-19 01:14:50 +00001704 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001705 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001706 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
1707 addr:$dst)]>,
1708 Imp<[CL],[]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001709 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001710 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
1712 addr:$dst)]>,
1713 Imp<[CL],[]>, TB, OpSize;
1714 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001715 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1718 (i8 imm:$src3)), addr:$dst)]>,
1719 TB, OpSize;
1720 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001721 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001722 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001723 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1724 (i8 imm:$src3)), addr:$dst)]>,
1725 TB, OpSize;
1726}
1727
1728
1729// Arithmetic.
1730let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001731def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001732 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1734let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001735def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001736 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001737 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001738def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001739 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1741} // end isConvertibleToThreeAddress
1742} // end isCommutable
Evan Chengb783fa32007-07-19 01:14:50 +00001743def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001744 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001745 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001746def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001747 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001748 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001749def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001750 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001751 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1752
Evan Chengb783fa32007-07-19 01:14:50 +00001753def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001754 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001755 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1756
1757let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001758def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001759 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001760 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001761def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001762 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001763 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001764def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001765 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>,
1767 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001768def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
1771}
1772
1773let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001774 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001775 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001776 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001777 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
1780 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001781 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001782 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001783 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001784 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001785 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001786 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001787 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001788 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001789 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1790 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001791 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001794 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1797 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001798 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001799 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001800 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1801}
1802
1803let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001804def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001805 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1807}
Evan Chengb783fa32007-07-19 01:14:50 +00001808def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001809 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001810 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001811def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001812 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001813 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001814def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001815 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1817
1818let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001819 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001822 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001823 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001825 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001826 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1828}
1829
Evan Chengb783fa32007-07-19 01:14:50 +00001830def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001833def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001834 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001835 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001836def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001837 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001838 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001839def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001840 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001841 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001842def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001843 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001844 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001845def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001846 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001847 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1848
Evan Chengb783fa32007-07-19 01:14:50 +00001849def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001850 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001851 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001852def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001853 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001855def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001856 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001858def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
1861 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001862def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1865let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001866 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001868 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001869 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001870 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
1872 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001873 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001874 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001875 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001876 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001877 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001878 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001879 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001881 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
1882 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001883 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001884 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001885 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001886 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1889 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001890 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001891 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001892 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1893}
1894
Evan Chengb783fa32007-07-19 01:14:50 +00001895def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001896 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001897 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
1898
1899let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001900 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001903 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001905 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001906 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001909 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001910 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001911 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1912}
Evan Chengb783fa32007-07-19 01:14:50 +00001913def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001914 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001916def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001917 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001918 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001919def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001920 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001921 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
1922
1923let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001924def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001927def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
1930}
Evan Chengb783fa32007-07-19 01:14:50 +00001931def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001932 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001933 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
1934 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001935def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001936 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001937 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
1938
1939} // end Two Address instructions
1940
1941// Suprisingly enough, these are not two address instructions!
1942def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00001943 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001944 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001945 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
1946def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00001947 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001948 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001949 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
1950def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001951 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001953 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
1954 OpSize;
1955def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001956 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
1959
1960def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00001961 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
1964 OpSize;
1965def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00001966 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001967 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001968 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
1969def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001970 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001971 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
1973 OpSize;
1974def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001975 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001976 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
1978
1979//===----------------------------------------------------------------------===//
1980// Test instructions are just like AND, except they don't generate a result.
1981//
1982let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00001983def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001984 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001985 [(X86cmp (and GR8:$src1, GR8:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001986def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001987 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001988 [(X86cmp (and GR16:$src1, GR16:$src2), 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001989def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001990 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001991 [(X86cmp (and GR32:$src1, GR32:$src2), 0)]>;
1992}
1993
Evan Chengb783fa32007-07-19 01:14:50 +00001994def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001997def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001998 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001999 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0)]>,
2000 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002001def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002002 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002003 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0)]>;
2004
2005def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002006 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002007 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002008 [(X86cmp (and GR8:$src1, imm:$src2), 0)]>;
2009def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002010 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002011 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002012 [(X86cmp (and GR16:$src1, imm:$src2), 0)]>, OpSize;
2013def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002014 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002015 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002016 [(X86cmp (and GR32:$src1, imm:$src2), 0)]>;
2017
2018def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002019 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002020 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002021 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0)]>;
2022def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002023 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002024 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002025 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0)]>,
2026 OpSize;
2027def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002028 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002029 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002030 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0)]>;
2031
2032
2033// Condition code ops, incl. set if equal/not equal/...
Evan Chengb783fa32007-07-19 01:14:50 +00002034def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>, Imp<[AH],[]>; // flags = AH
2035def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>, Imp<[],[AH]>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002036
2037def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002038 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002039 "sete\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002040 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2041 TB; // GR8 = ==
2042def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002043 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002044 "sete\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002045 [(store (X86setcc X86_COND_E), addr:$dst)]>,
2046 TB; // [mem8] = ==
2047def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002048 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002049 "setne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002050 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2051 TB; // GR8 = !=
2052def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002053 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002054 "setne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
2056 TB; // [mem8] = !=
2057def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002058 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002059 "setl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002060 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2061 TB; // GR8 = < signed
2062def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002063 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "setl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(store (X86setcc X86_COND_L), addr:$dst)]>,
2066 TB; // [mem8] = < signed
2067def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002068 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "setge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2071 TB; // GR8 = >= signed
2072def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002073 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002074 "setge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002075 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
2076 TB; // [mem8] = >= signed
2077def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002078 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "setle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002080 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2081 TB; // GR8 = <= signed
2082def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002083 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002084 "setle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002085 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
2086 TB; // [mem8] = <= signed
2087def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002088 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002089 "setg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002090 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2091 TB; // GR8 = > signed
2092def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002093 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002094 "setg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002095 [(store (X86setcc X86_COND_G), addr:$dst)]>,
2096 TB; // [mem8] = > signed
2097
2098def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002099 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002100 "setb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002101 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2102 TB; // GR8 = < unsign
2103def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002104 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002105 "setb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002106 [(store (X86setcc X86_COND_B), addr:$dst)]>,
2107 TB; // [mem8] = < unsign
2108def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002109 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002110 "setae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002111 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2112 TB; // GR8 = >= unsign
2113def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002114 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002115 "setae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002116 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
2117 TB; // [mem8] = >= unsign
2118def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002119 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002120 "setbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002121 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2122 TB; // GR8 = <= unsign
2123def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002124 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002125 "setbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002126 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
2127 TB; // [mem8] = <= unsign
2128def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002129 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002130 "seta\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002131 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2132 TB; // GR8 = > signed
2133def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002134 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002135 "seta\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002136 [(store (X86setcc X86_COND_A), addr:$dst)]>,
2137 TB; // [mem8] = > signed
2138
2139def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002140 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002141 "sets\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002142 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2143 TB; // GR8 = <sign bit>
2144def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002145 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002146 "sets\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002147 [(store (X86setcc X86_COND_S), addr:$dst)]>,
2148 TB; // [mem8] = <sign bit>
2149def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002150 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "setns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002152 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2153 TB; // GR8 = !<sign bit>
2154def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002155 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002156 "setns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002157 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
2158 TB; // [mem8] = !<sign bit>
2159def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002160 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002161 "setp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002162 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2163 TB; // GR8 = parity
2164def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002165 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002166 "setp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002167 [(store (X86setcc X86_COND_P), addr:$dst)]>,
2168 TB; // [mem8] = parity
2169def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002170 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "setnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002172 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2173 TB; // GR8 = not parity
2174def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002175 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002176 "setnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002177 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
2178 TB; // [mem8] = not parity
2179
2180// Integer comparisons
2181def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002182 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002183 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 [(X86cmp GR8:$src1, GR8:$src2)]>;
2185def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002186 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002187 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
2189def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002190 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002191 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002192 [(X86cmp GR32:$src1, GR32:$src2)]>;
2193def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002194 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002195 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002196 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
2197def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002198 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002199 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002200 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
2201def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002202 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002203 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
2205def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002206 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002207 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002208 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
2209def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002210 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002211 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002212 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
2213def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002214 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002215 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002216 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
2217def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002218 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002219 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002220 [(X86cmp GR8:$src1, imm:$src2)]>;
2221def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002222 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002224 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
2225def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002226 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002227 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002228 [(X86cmp GR32:$src1, imm:$src2)]>;
2229def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002230 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002231 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002232 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
2233def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002234 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002235 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002236 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
2237def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002238 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002239 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002240 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
2241def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002242 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002243 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002244 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
2245def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002246 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002247 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002248 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
2249def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002250 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002251 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002252 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
2253def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002254 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002255 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002256 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
2257
2258// Sign/Zero extenders
Evan Chengb783fa32007-07-19 01:14:50 +00002259def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002262def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002263 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002264 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002265def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002266 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002267 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002268def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002269 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002270 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002271def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002272 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002274def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002275 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002276 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2277
Evan Chengb783fa32007-07-19 01:14:50 +00002278def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002279 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002280 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002281def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002282 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002283 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002284def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002285 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002286 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002287def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002288 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002290def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002291 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002292 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002293def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002294 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002295 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2296
Evan Chengb783fa32007-07-19 01:14:50 +00002297def CBW : I<0x98, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002298 "{cbtw|cbw}", []>, Imp<[AL],[AX]>, OpSize; // AX = signext(AL)
Evan Chengb783fa32007-07-19 01:14:50 +00002299def CWDE : I<0x98, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002300 "{cwtl|cwde}", []>, Imp<[AX],[EAX]>; // EAX = signext(AX)
2301
Evan Chengb783fa32007-07-19 01:14:50 +00002302def CWD : I<0x99, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002303 "{cwtd|cwd}", []>, Imp<[AX],[AX,DX]>, OpSize; // DX:AX = signext(AX)
Evan Chengb783fa32007-07-19 01:14:50 +00002304def CDQ : I<0x99, RawFrm, (outs), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002305 "{cltd|cdq}", []>, Imp<[EAX],[EAX,EDX]>; // EDX:EAX = signext(EAX)
2306
2307
2308//===----------------------------------------------------------------------===//
2309// Alias Instructions
2310//===----------------------------------------------------------------------===//
2311
2312// Alias instructions that map movr0 to xor.
2313// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Chengb783fa32007-07-19 01:14:50 +00002314def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002315 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002316 [(set GR8:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002317def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002318 "xor{w}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002319 [(set GR16:$dst, 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002320def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002321 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322 [(set GR32:$dst, 0)]>;
2323
2324// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2325// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengb783fa32007-07-19 01:14:50 +00002326def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002327 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002328def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002329 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002330
Evan Chengb783fa32007-07-19 01:14:50 +00002331def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002332 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002333def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002334 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00002335def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002336 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002337def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002338 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00002339def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002340 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002341def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002342 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002343
2344//===----------------------------------------------------------------------===//
2345// Thread Local Storage Instructions
2346//
2347
Evan Chengb783fa32007-07-19 01:14:50 +00002348def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 "leal\t${sym:mem}(,%ebx,1), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002350 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>,
2351 Imp<[EBX],[]>;
2352
2353let AddedComplexity = 10 in
Evan Chengb783fa32007-07-19 01:14:50 +00002354def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002355 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2357
2358let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002359def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002360 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002361 [(set GR32:$dst,
2362 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2363
Evan Chengb783fa32007-07-19 01:14:50 +00002364def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002365 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002366 [(set GR32:$dst, X86TLStp)]>;
2367
2368//===----------------------------------------------------------------------===//
2369// DWARF Pseudo Instructions
2370//
2371
Evan Chengb783fa32007-07-19 01:14:50 +00002372def DWARF_LOC : I<0, Pseudo, (outs),
2373 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohmanf8133d72007-07-26 15:24:15 +00002374 "; .loc ${file:debug}, ${line:debug}, ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002375 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2376 (i32 imm:$file))]>;
2377
2378//===----------------------------------------------------------------------===//
2379// EH Pseudo Instructions
2380//
2381let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002382 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002383def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002384 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002385 [(X86ehret GR32:$addr)]>;
2386
2387}
2388
2389//===----------------------------------------------------------------------===//
2390// Non-Instruction Patterns
2391//===----------------------------------------------------------------------===//
2392
2393// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2394def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2395def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2396def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2397def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2398def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2399
2400def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2401 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2402def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2403 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2404def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2405 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2406def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2407 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2408
2409def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2410 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2411def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2412 (MOV32mi addr:$dst, texternalsym:$src)>;
2413
2414// Calls
2415def : Pat<(X86tailcall GR32:$dst),
2416 (CALL32r GR32:$dst)>;
2417
2418def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2419 (CALLpcrel32 tglobaladdr:$dst)>;
2420def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2421 (CALLpcrel32 texternalsym:$dst)>;
2422
2423def : Pat<(X86call (i32 tglobaladdr:$dst)),
2424 (CALLpcrel32 tglobaladdr:$dst)>;
2425def : Pat<(X86call (i32 texternalsym:$dst)),
2426 (CALLpcrel32 texternalsym:$dst)>;
2427
2428// X86 specific add which produces a flag.
2429def : Pat<(addc GR32:$src1, GR32:$src2),
2430 (ADD32rr GR32:$src1, GR32:$src2)>;
2431def : Pat<(addc GR32:$src1, (load addr:$src2)),
2432 (ADD32rm GR32:$src1, addr:$src2)>;
2433def : Pat<(addc GR32:$src1, imm:$src2),
2434 (ADD32ri GR32:$src1, imm:$src2)>;
2435def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2436 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2437
2438def : Pat<(subc GR32:$src1, GR32:$src2),
2439 (SUB32rr GR32:$src1, GR32:$src2)>;
2440def : Pat<(subc GR32:$src1, (load addr:$src2)),
2441 (SUB32rm GR32:$src1, addr:$src2)>;
2442def : Pat<(subc GR32:$src1, imm:$src2),
2443 (SUB32ri GR32:$src1, imm:$src2)>;
2444def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2445 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2446
2447def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2448 (MOV8mi addr:$dst, imm:$src)>;
2449def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2450 (MOV8mr addr:$dst, GR8:$src)>;
2451
2452// Comparisons.
2453
2454// TEST R,R is smaller than CMP R,0
2455def : Pat<(X86cmp GR8:$src1, 0),
2456 (TEST8rr GR8:$src1, GR8:$src1)>;
2457def : Pat<(X86cmp GR16:$src1, 0),
2458 (TEST16rr GR16:$src1, GR16:$src1)>;
2459def : Pat<(X86cmp GR32:$src1, 0),
2460 (TEST32rr GR32:$src1, GR32:$src1)>;
2461
2462// {s|z}extload bool -> {s|z}extload byte
2463def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2464def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2465def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2466def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2467def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2468
2469// extload bool -> extload byte
2470def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2471def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2472def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2473def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2474def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2475def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2476
2477// anyext -> zext
2478def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2479def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2480def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2481def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2482def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2483def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2484
2485//===----------------------------------------------------------------------===//
2486// Some peepholes
2487//===----------------------------------------------------------------------===//
2488
2489// (shl x, 1) ==> (add x, x)
2490def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2491def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2492def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2493
2494// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2495def : Pat<(or (srl GR32:$src1, CL:$amt),
2496 (shl GR32:$src2, (sub 32, CL:$amt))),
2497 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2498
2499def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2500 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2501 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2502
2503// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2504def : Pat<(or (shl GR32:$src1, CL:$amt),
2505 (srl GR32:$src2, (sub 32, CL:$amt))),
2506 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2507
2508def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2509 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2510 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2511
2512// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2513def : Pat<(or (srl GR16:$src1, CL:$amt),
2514 (shl GR16:$src2, (sub 16, CL:$amt))),
2515 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2516
2517def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2518 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2519 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2520
2521// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2522def : Pat<(or (shl GR16:$src1, CL:$amt),
2523 (srl GR16:$src2, (sub 16, CL:$amt))),
2524 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2525
2526def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2527 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2528 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2529
2530
2531//===----------------------------------------------------------------------===//
2532// Floating Point Stack Support
2533//===----------------------------------------------------------------------===//
2534
2535include "X86InstrFPStack.td"
2536
2537//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00002538// X86-64 Support
2539//===----------------------------------------------------------------------===//
2540
2541include "X86InstrX86-64.td"
2542
2543//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002544// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2545//===----------------------------------------------------------------------===//
2546
2547include "X86InstrMMX.td"
2548
2549//===----------------------------------------------------------------------===//
2550// XMM Floating point support (requires SSE / SSE2)
2551//===----------------------------------------------------------------------===//
2552
2553include "X86InstrSSE.td"