blob: dde59fc04be4f6ac5df4c61b395432364ce631f0 [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()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000163def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
164def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000165def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
166def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Evan Cheng09e13792007-08-01 23:45:51 +0000167def HasLow4G : Predicate<"Subtarget->hasLow4GUserSpaceAddress()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000168def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
169def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
170def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
171
172//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000173// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000174//
175
Evan Cheng86ab7d32007-07-31 08:04:03 +0000176include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177
178//===----------------------------------------------------------------------===//
179// Pattern fragments...
180//
181
182// X86 specific condition code. These correspond to CondCode in
183// X86InstrInfo.h. They must be kept in synch.
184def X86_COND_A : PatLeaf<(i8 0)>;
185def X86_COND_AE : PatLeaf<(i8 1)>;
186def X86_COND_B : PatLeaf<(i8 2)>;
187def X86_COND_BE : PatLeaf<(i8 3)>;
188def X86_COND_E : PatLeaf<(i8 4)>;
189def X86_COND_G : PatLeaf<(i8 5)>;
190def X86_COND_GE : PatLeaf<(i8 6)>;
191def X86_COND_L : PatLeaf<(i8 7)>;
192def X86_COND_LE : PatLeaf<(i8 8)>;
193def X86_COND_NE : PatLeaf<(i8 9)>;
194def X86_COND_NO : PatLeaf<(i8 10)>;
195def X86_COND_NP : PatLeaf<(i8 11)>;
196def X86_COND_NS : PatLeaf<(i8 12)>;
197def X86_COND_O : PatLeaf<(i8 13)>;
198def X86_COND_P : PatLeaf<(i8 14)>;
199def X86_COND_S : PatLeaf<(i8 15)>;
200
201def i16immSExt8 : PatLeaf<(i16 imm), [{
202 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
203 // sign extended field.
204 return (int16_t)N->getValue() == (int8_t)N->getValue();
205}]>;
206
207def i32immSExt8 : PatLeaf<(i32 imm), [{
208 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
209 // sign extended field.
210 return (int32_t)N->getValue() == (int8_t)N->getValue();
211}]>;
212
213// Helper fragments for loads.
214def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
215def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
216def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
217def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
218
219def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
220def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000221def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000222
223def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
224def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
225def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
226def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
227def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
228
229def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
230def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
231def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
232def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
233def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
234def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
235
236def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
237def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
238def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
239def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
240def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
241def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
242
243//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000244// Instruction list...
245//
246
247// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
248// a stack adjustment and the codegen must know that they may modify the stack
249// pointer before prolog-epilog rewriting occurs.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000250let Defs = [ESP], Uses = [ESP] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000251def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt), "#ADJCALLSTACKDOWN",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000252 [(X86callseq_start imm:$amt)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000253def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000254 "#ADJCALLSTACKUP",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000255 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
256}
Evan Chengb783fa32007-07-19 01:14:50 +0000257def IMPLICIT_USE : I<0, Pseudo, (outs), (ins variable_ops),
258 "#IMPLICIT_USE", []>;
259def IMPLICIT_DEF : I<0, Pseudo, (outs variable_ops), (ins),
260 "#IMPLICIT_DEF", []>;
261def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000262 "#IMPLICIT_DEF $dst",
263 [(set GR8:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000264def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000265 "#IMPLICIT_DEF $dst",
266 [(set GR16:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000267def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000268 "#IMPLICIT_DEF $dst",
269 [(set GR32:$dst, (undef))]>;
270
271// Nop
Evan Chengb783fa32007-07-19 01:14:50 +0000272def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274
275//===----------------------------------------------------------------------===//
276// Control Flow Instructions...
277//
278
279// Return instructions.
280let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +0000281 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000282 def RET : I<0xC3, RawFrm, (outs), (ins), "ret", [(X86retflag 0)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000283 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt), "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000284 [(X86retflag imm:$amt)]>;
285}
286
287// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000288let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000289 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
290 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000291
292// Indirect branches
293let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000294 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000295
Evan Cheng37e7c752007-07-21 00:34:19 +0000296let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000297 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000299 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300 [(brind (loadi32 addr:$dst))]>;
301}
302
303// Conditional branches
Dan Gohman91888f02007-07-31 20:11:57 +0000304def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000305 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000306def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000307 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000308def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000309 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000310def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000311 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000312def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000313 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000314def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000315 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
316
Dan Gohman91888f02007-07-31 20:11:57 +0000317def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000319def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000320 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000321def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000322 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000323def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000324 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
325
Dan Gohman91888f02007-07-31 20:11:57 +0000326def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000328def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000329 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000330def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000331 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000332def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000333 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000334def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000335 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000336def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000337 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
338
339//===----------------------------------------------------------------------===//
340// Call Instructions...
341//
Evan Cheng37e7c752007-07-21 00:34:19 +0000342let isCall = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000343 // All calls clobber the non-callee saved registers...
344 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
345 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
346 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000347 def CALLpcrel32 : I<0xE8, RawFrm, (outs), (ins i32imm:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000348 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000349 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000350 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000351 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000352 "call\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000353 }
354
355// Tail call stuff.
Evan Cheng37e7c752007-07-21 00:34:19 +0000356let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000357 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAIL CALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000358 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000359let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000360 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp\t{*}$dst # TAIL CALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000362let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000363 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000364 "jmp\t{*}$dst # TAIL CALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000365
366//===----------------------------------------------------------------------===//
367// Miscellaneous Instructions...
368//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000369let Defs = [EBP, ESP], Uses = [EBP, ESP] in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000370def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000371 (outs), (ins), "leave", []>;
372
373let Defs = [ESP], Uses = [ESP] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000374def POP32r : I<0x58, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000375 (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000376
377def PUSH32r : I<0x50, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000378 (outs), (ins GR32:$reg), "push{l}\t$reg", []>;
379}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000380
Evan Chengb783fa32007-07-19 01:14:50 +0000381def MovePCtoStack : I<0, Pseudo, (outs), (ins piclabel:$label),
Dan Gohman91888f02007-07-31 20:11:57 +0000382 "call\t$label", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000383
384let isTwoAddress = 1 in // GR32 = bswap GR32
385 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000386 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000387 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
389
Evan Chengb783fa32007-07-19 01:14:50 +0000390// FIXME: Model xchg* as two address instructions?
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000391def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
Evan Chengb783fa32007-07-19 01:14:50 +0000392 (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000393 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000395 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000396 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000397def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000398 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000399 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000400
401def XCHG8mr : I<0x86, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000402 (outs), (ins i8mem:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000403 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000404def XCHG16mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000405 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000406 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000407def XCHG32mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000408 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000409 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410def XCHG8rm : I<0x86, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000411 (outs), (ins GR8:$src1, i8mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000412 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413def XCHG16rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000414 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000415 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416def XCHG32rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000417 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000418 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000419
420def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000421 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000422 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000424 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000425 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
427
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000428let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000429def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000430 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000431def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000432 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000433def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000434 [(X86rep_movs i32)]>, REP;
435}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000437let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000438def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000439 [(X86rep_stos i8)]>, REP;
440let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000441def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000442 [(X86rep_stos i16)]>, REP, OpSize;
443let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000444def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000445 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000446
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000447let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000448def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000449 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000450
451//===----------------------------------------------------------------------===//
452// Input/Output Instructions...
453//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000454let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000455def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000456 "in{b}\t{%dx, %al|%AL, %DX}", []>;
457let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000458def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000459 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
460let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000461def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000462 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000463
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000464let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000465def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000466 "in{b}\t{$port, %al|%AL, $port}", []>;
467let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000468def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000469 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
470let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000471def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000472 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000473
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000474let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000475def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000476 "out{b}\t{%al, %dx|%DX, %AL}", []>;
477let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000478def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000479 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
480let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000481def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000482 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000483
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000484let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000485def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000486 "out{b}\t{%al, $port|$port, %AL}", []>;
487let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000488def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000489 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
490let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000491def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000492 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000493
494//===----------------------------------------------------------------------===//
495// Move Instructions...
496//
Evan Chengb783fa32007-07-19 01:14:50 +0000497def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000498 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000499def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000500 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000501def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000502 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000503let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000504def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000505 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000506 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000507def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000508 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000510def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000511 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512 [(set GR32:$dst, imm:$src)]>;
513}
Evan Chengb783fa32007-07-19 01:14:50 +0000514def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000515 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000516 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000517def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000518 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000520def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000521 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522 [(store (i32 imm:$src), addr:$dst)]>;
523
Evan Cheng4e84e452007-08-30 05:49:43 +0000524let isLoad = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000525def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000526 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000527 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000528def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000529 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000530 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000531def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000532 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000533 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000534}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535
Evan Chengb783fa32007-07-19 01:14:50 +0000536def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000537 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000538 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000539def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000540 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000541 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000542def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000543 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544 [(store GR32:$src, addr:$dst)]>;
545
546//===----------------------------------------------------------------------===//
547// Fixed-Register Multiplication and Division Instructions...
548//
549
550// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000551let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000552def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000553 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
554 // This probably ought to be moved to a def : Pat<> if the
555 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000556 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000557let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000558def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000559 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000560let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000561def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
562 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000563let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000564def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000565 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000566 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
567 // This probably ought to be moved to a def : Pat<> if the
568 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000569 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000570let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000571def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000572 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng55687072007-09-14 21:48:26 +0000573let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000574def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000575 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000576
Evan Cheng55687072007-09-14 21:48:26 +0000577let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000578def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
579 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000580let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000581def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000582 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000583let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000584def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
585 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000586let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000587def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000588 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000589let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000590def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000591 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
592let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000593def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000594 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000595
596// unsigned division/remainder
Evan Cheng55687072007-09-14 21:48:26 +0000597let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000598def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000599 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000600let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000601def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000602 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000603let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000604def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000605 "div{l}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000606let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000607def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000608 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000609let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000610def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000611 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000612let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000613def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000614 "div{l}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000615
616// Signed division/remainder.
Evan Cheng55687072007-09-14 21:48:26 +0000617let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000618def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000619 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000620let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000621def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000622 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000623let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000624def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000625 "idiv{l}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000626let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000627def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000628 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000629let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000630def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000631 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000632let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000633def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000634 "idiv{l}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000635
636
637//===----------------------------------------------------------------------===//
638// Two address Instructions...
639//
640let isTwoAddress = 1 in {
641
642// Conditional moves
643def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000644 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000645 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000646 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
647 X86_COND_B))]>,
648 TB, OpSize;
649def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000650 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000651 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000652 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
653 X86_COND_B))]>,
654 TB, OpSize;
655def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000656 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000657 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000658 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
659 X86_COND_B))]>,
660 TB;
661def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000662 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000663 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000664 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
665 X86_COND_B))]>,
666 TB;
667
668def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000669 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000670 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000671 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
672 X86_COND_AE))]>,
673 TB, OpSize;
674def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000675 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000676 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
678 X86_COND_AE))]>,
679 TB, OpSize;
680def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000681 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000682 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
684 X86_COND_AE))]>,
685 TB;
686def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000687 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000688 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000689 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
690 X86_COND_AE))]>,
691 TB;
692
693def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000694 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000695 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
697 X86_COND_E))]>,
698 TB, OpSize;
699def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000700 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000701 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
703 X86_COND_E))]>,
704 TB, OpSize;
705def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000706 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000707 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
709 X86_COND_E))]>,
710 TB;
711def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000712 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000713 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
715 X86_COND_E))]>,
716 TB;
717
718def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000719 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000720 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
722 X86_COND_NE))]>,
723 TB, OpSize;
724def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000725 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000726 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000727 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
728 X86_COND_NE))]>,
729 TB, OpSize;
730def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000731 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000732 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000733 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
734 X86_COND_NE))]>,
735 TB;
736def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000737 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000738 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000739 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
740 X86_COND_NE))]>,
741 TB;
742
743def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000744 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000745 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
747 X86_COND_BE))]>,
748 TB, OpSize;
749def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000750 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000751 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000752 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
753 X86_COND_BE))]>,
754 TB, OpSize;
755def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000756 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000757 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000758 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
759 X86_COND_BE))]>,
760 TB;
761def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000762 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000763 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000764 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
765 X86_COND_BE))]>,
766 TB;
767
768def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000769 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000770 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
772 X86_COND_A))]>,
773 TB, OpSize;
774def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000775 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000776 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
778 X86_COND_A))]>,
779 TB, OpSize;
780def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000781 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000782 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
784 X86_COND_A))]>,
785 TB;
786def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000787 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000788 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
790 X86_COND_A))]>,
791 TB;
792
793def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000794 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000795 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
797 X86_COND_L))]>,
798 TB, OpSize;
799def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000800 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000801 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000802 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
803 X86_COND_L))]>,
804 TB, OpSize;
805def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000806 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000807 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000808 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
809 X86_COND_L))]>,
810 TB;
811def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000812 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000813 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000814 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
815 X86_COND_L))]>,
816 TB;
817
818def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000819 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000820 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
822 X86_COND_GE))]>,
823 TB, OpSize;
824def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000825 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000826 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
828 X86_COND_GE))]>,
829 TB, OpSize;
830def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000831 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000832 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
834 X86_COND_GE))]>,
835 TB;
836def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000837 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000838 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
840 X86_COND_GE))]>,
841 TB;
842
843def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000844 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000845 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
847 X86_COND_LE))]>,
848 TB, OpSize;
849def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000850 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000851 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000852 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
853 X86_COND_LE))]>,
854 TB, OpSize;
855def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000856 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000857 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000858 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
859 X86_COND_LE))]>,
860 TB;
861def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000862 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000863 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000864 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
865 X86_COND_LE))]>,
866 TB;
867
868def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000869 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000870 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
872 X86_COND_G))]>,
873 TB, OpSize;
874def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000875 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000876 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000877 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
878 X86_COND_G))]>,
879 TB, OpSize;
880def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000881 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000882 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000883 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
884 X86_COND_G))]>,
885 TB;
886def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000887 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000888 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000889 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
890 X86_COND_G))]>,
891 TB;
892
893def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000894 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000895 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
897 X86_COND_S))]>,
898 TB, OpSize;
899def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000900 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000901 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000902 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
903 X86_COND_S))]>,
904 TB, OpSize;
905def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000906 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000907 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000908 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
909 X86_COND_S))]>,
910 TB;
911def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000912 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000913 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000914 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
915 X86_COND_S))]>,
916 TB;
917
918def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000919 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000920 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
922 X86_COND_NS))]>,
923 TB, OpSize;
924def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000925 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000926 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000927 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
928 X86_COND_NS))]>,
929 TB, OpSize;
930def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000931 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000932 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000933 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
934 X86_COND_NS))]>,
935 TB;
936def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000937 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000938 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000939 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
940 X86_COND_NS))]>,
941 TB;
942
943def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000944 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000945 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
947 X86_COND_P))]>,
948 TB, OpSize;
949def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000950 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000951 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000952 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
953 X86_COND_P))]>,
954 TB, OpSize;
955def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000956 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000957 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000958 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
959 X86_COND_P))]>,
960 TB;
961def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000962 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000963 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000964 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
965 X86_COND_P))]>,
966 TB;
967
968def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000969 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000970 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
972 X86_COND_NP))]>,
973 TB, OpSize;
974def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000975 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000976 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000977 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
978 X86_COND_NP))]>,
979 TB, OpSize;
980def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000981 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000982 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000983 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
984 X86_COND_NP))]>,
985 TB;
986def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000987 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000988 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000989 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
990 X86_COND_NP))]>,
991 TB;
992
993
994// unary instructions
995let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +0000996let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000997def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000998 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000999def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001000 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001001def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002 [(set GR32:$dst, (ineg GR32:$src))]>;
1003let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001004 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001005 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001006 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001007 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001008 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001009 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1010
1011}
Evan Cheng55687072007-09-14 21:48:26 +00001012} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013
Dan Gohman91888f02007-07-31 20:11:57 +00001014def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001016def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001017 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001018def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001019 [(set GR32:$dst, (not GR32:$src))]>;
1020let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001021 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001023 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001024 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001025 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001026 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1027}
1028} // CodeSize
1029
1030// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001031let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001033def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034 [(set GR8:$dst, (add GR8:$src, 1))]>;
1035let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001036def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037 [(set GR16:$dst, (add GR16:$src, 1))]>,
1038 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001039def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1041}
1042let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001043 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001045 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001047 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1049}
1050
1051let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001052def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001053 [(set GR8:$dst, (add GR8:$src, -1))]>;
1054let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001055def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056 [(set GR16:$dst, (add GR16:$src, -1))]>,
1057 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001058def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001059 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1060}
1061
1062let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001063 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001065 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001066 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001067 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001068 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1069}
Evan Cheng55687072007-09-14 21:48:26 +00001070} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071
1072// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001073let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1075def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001076 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001077 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1079def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001080 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001081 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1083def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001084 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001085 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1087}
1088
1089def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001090 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001091 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001092 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1093def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001094 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001095 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001096 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1097def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001098 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001099 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1101
1102def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001103 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001104 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001105 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1106def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001107 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001108 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001109 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1110def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001111 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001112 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1114def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001115 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001116 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1118 OpSize;
1119def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001120 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001121 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001122 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1123
1124let isTwoAddress = 0 in {
1125 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001126 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001127 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001128 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1129 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001130 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001131 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001132 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1133 OpSize;
1134 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001135 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001136 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1138 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001139 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001140 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001141 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1142 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001143 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001144 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1146 OpSize;
1147 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001148 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001149 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001150 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1151 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001152 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001153 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001154 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1155 OpSize;
1156 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001157 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001158 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001159 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1160}
1161
1162
1163let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001164def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001165 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001166 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001167def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001168 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001170def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001171 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001172 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1173}
Evan Chengb783fa32007-07-19 01:14:50 +00001174def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001175 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001176 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001177def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001178 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001179 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001180def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001181 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001182 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1183
Evan Chengb783fa32007-07-19 01:14:50 +00001184def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001185 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001186 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001187def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001188 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001189 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001190def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001191 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001192 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1193
Evan Chengb783fa32007-07-19 01:14:50 +00001194def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001195 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001196 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001197def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001198 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001199 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1200let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001201 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001202 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001203 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001204 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001205 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001207 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001208 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001209 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001210 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001211 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001212 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001213 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001214 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001215 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1216 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001217 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001218 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001219 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001220 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001221 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001222 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1223 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001224 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001225 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001226 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1227}
1228
1229
1230let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1231def XOR8rr : I<0x30, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001232 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001233 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1235def XOR16rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001236 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001237 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001238 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1239def XOR32rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001240 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001241 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1243}
1244
1245def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001246 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001247 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001248 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1249def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001250 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001251 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001252 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1253def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001254 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001255 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1257
1258def XOR8ri : Ii8<0x80, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001259 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001260 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001261 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1262def XOR16ri : Ii16<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001263 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001264 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001265 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1266def XOR32ri : Ii32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001267 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001268 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1270def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001271 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001272 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1274 OpSize;
1275def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001276 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001277 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001278 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1279let isTwoAddress = 0 in {
1280 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001281 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001282 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001283 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1284 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001285 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001286 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001287 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1288 OpSize;
1289 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001290 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001291 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001292 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1293 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001294 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001295 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001296 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1297 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001298 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001299 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1301 OpSize;
1302 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001303 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001304 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001305 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1306 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001307 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001308 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001309 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1310 OpSize;
1311 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001312 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001313 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001314 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1315}
Evan Cheng55687072007-09-14 21:48:26 +00001316} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317
1318// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001319let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001320let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001321def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001322 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001323 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001324def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001325 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001326 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001327def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001328 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001329 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1330}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001331
Evan Chengb783fa32007-07-19 01:14:50 +00001332def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001333 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001334 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1335let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001336def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001337 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001338 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001339def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001340 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1342}
1343
1344// Shift left by one. Not used because (add x, x) is slightly cheaper.
Evan Chengb783fa32007-07-19 01:14:50 +00001345def SHL8r1 : I<0xD0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001346 "shl{b}\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001347def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001348 "shl{w}\t$dst", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001349def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001350 "shl{l}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001351
1352let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001353 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001354 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001355 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001356 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001357 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001358 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001359 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001360 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001361 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001362 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1363 }
Evan Chengb783fa32007-07-19 01:14:50 +00001364 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001365 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001366 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001367 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001368 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001369 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1370 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001371 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001372 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001373 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1374
1375 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001376 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001377 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001378 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001379 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001380 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1382 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001383 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001384 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001385 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1386}
1387
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001388let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001389def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001390 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001391 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001392def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001393 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001394 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001395def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001396 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001397 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1398}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001399
Evan Chengb783fa32007-07-19 01:14:50 +00001400def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001401 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001402 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001403def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001404 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001405 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001406def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001407 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001408 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1409
1410// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001411def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001412 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001414def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001415 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001416 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001417def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001418 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001419 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1420
1421let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001422 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001423 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001424 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001425 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001426 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001427 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001428 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001429 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001430 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001431 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001432 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1433 }
Evan Chengb783fa32007-07-19 01:14:50 +00001434 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001436 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001437 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001438 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001439 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1440 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001441 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001442 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001443 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1444
1445 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001446 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001447 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001448 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001449 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001452 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001453 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001454 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1455}
1456
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001457let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001458def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001459 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001460 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001461def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001462 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001463 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001464def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001465 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001466 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1467}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001468
Evan Chengb783fa32007-07-19 01:14:50 +00001469def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001470 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001471 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001472def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001473 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001474 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1475 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001476def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001477 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001478 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1479
1480// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001481def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001482 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001483 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001484def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001485 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001487def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001488 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001489 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1490
1491let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001492 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001493 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001494 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001495 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001496 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001498 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001499 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001500 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001501 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1502 }
Evan Chengb783fa32007-07-19 01:14:50 +00001503 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001504 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001505 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001506 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001507 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001508 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1509 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001510 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001511 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001512 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1513
1514 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001515 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001516 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001517 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001518 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001519 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001520 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1521 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001522 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001523 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001524 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1525}
1526
1527// Rotate instructions
1528// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001529let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001530def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001531 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001532 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001533def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001534 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001535 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001536def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001537 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001538 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1539}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001540
Evan Chengb783fa32007-07-19 01:14:50 +00001541def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001543 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001544def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001545 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001546 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001547def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001548 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001549 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1550
1551// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001552def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001555def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001558def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001559 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001560 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1561
1562let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001563 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001564 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001565 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001566 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001567 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001568 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001569 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001570 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001571 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001572 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1573 }
Evan Chengb783fa32007-07-19 01:14:50 +00001574 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001575 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001576 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001577 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001578 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001579 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1580 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001581 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001582 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001583 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1584
1585 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001586 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001587 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001588 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001589 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001590 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001591 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1592 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001593 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001594 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001595 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1596}
1597
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001598let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001599def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001600 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001601 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001602def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001603 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001604 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001605def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001607 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1608}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001609
Evan Chengb783fa32007-07-19 01:14:50 +00001610def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001611 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001612 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001613def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001614 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001616def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001617 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001618 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1619
1620// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001621def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001622 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001624def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001625 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001626 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001627def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001628 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001629 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1630
1631let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001632 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001633 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001634 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001635 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001636 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001637 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001638 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001639 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001640 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001641 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1642 }
Evan Chengb783fa32007-07-19 01:14:50 +00001643 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001644 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001645 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001646 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001647 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001648 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1649 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001650 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001651 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001652 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1653
1654 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001655 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001656 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001657 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001658 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001659 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001660 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1661 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001662 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001663 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001664 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1665}
1666
1667
1668
1669// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001670let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001671def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001672 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001673 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001674def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001675 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001676 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001677def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001678 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001679 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001680 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001681def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001682 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001683 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001684 TB, OpSize;
1685}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001686
1687let isCommutable = 1 in { // These instructions commute to each other.
1688def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001689 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001690 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001691 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1692 (i8 imm:$src3)))]>,
1693 TB;
1694def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001695 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001696 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001697 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1698 (i8 imm:$src3)))]>,
1699 TB;
1700def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001701 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1704 (i8 imm:$src3)))]>,
1705 TB, OpSize;
1706def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001707 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001708 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001709 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1710 (i8 imm:$src3)))]>,
1711 TB, OpSize;
1712}
1713
1714let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001715 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001716 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001717 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001718 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001719 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001720 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001721 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001722 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001723 addr:$dst)]>, TB;
1724 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001725 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001726 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001727 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001728 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1729 (i8 imm:$src3)), addr:$dst)]>,
1730 TB;
1731 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001732 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001733 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001734 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1735 (i8 imm:$src3)), addr:$dst)]>,
1736 TB;
1737
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001738 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001739 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001740 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001741 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001742 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001743 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001744 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001745 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001746 addr:$dst)]>, TB, OpSize;
1747 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001748 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001749 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001750 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001751 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1752 (i8 imm:$src3)), addr:$dst)]>,
1753 TB, OpSize;
1754 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001755 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001756 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001757 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1758 (i8 imm:$src3)), addr:$dst)]>,
1759 TB, OpSize;
1760}
Evan Cheng55687072007-09-14 21:48:26 +00001761} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001762
1763
1764// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001765let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001766let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001767def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1768 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001769 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1771let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001772def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1773 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001774 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001776def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1777 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001778 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001779 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1780} // end isConvertibleToThreeAddress
1781} // end isCommutable
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001782def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1783 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001784 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001785 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001786def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1787 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001788 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001789 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1790def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1791 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1794
Evan Chengb783fa32007-07-19 01:14:50 +00001795def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001796 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001797 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1798
1799let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001800def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1801 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001802 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001804def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1805 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001806 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001807 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001808def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1809 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001810 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001811 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1812def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1813 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001814 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001815 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001816}
1817
1818let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001819 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001822 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001823 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001825 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001826 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001827 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001828 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001829 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001830 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001831 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001832 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001833 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001834 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001835 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001836 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001837 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001838 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001839 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001840 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001841 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001842 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001843 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001844 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1846}
1847
1848let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001849def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001850 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001851 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1852}
Evan Chengb783fa32007-07-19 01:14:50 +00001853def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001854 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001856def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001857 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001858 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001859def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001860 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001861 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1862
1863let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001864 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001865 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001866 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001867 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001868 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001870 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001871 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001872 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1873}
1874
Evan Chengb783fa32007-07-19 01:14:50 +00001875def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001876 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001877 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001878def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001879 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001880 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001881def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001882 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001883 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001884def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001887def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001888 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001889 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001890def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001891 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001892 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1893
Evan Chengb783fa32007-07-19 01:14:50 +00001894def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001895 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001896 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001897def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001899 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001900def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001903def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001904 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001905 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng55687072007-09-14 21:48:26 +00001906 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001907def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1910let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001911 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001912 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001913 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001914 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001915 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001916 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001917 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001918 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001919 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001920 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001921 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001924 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001927 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001928 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001930 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001931 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001932 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001933 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001934 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001935 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001936 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001937 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1938}
1939
Evan Chengb783fa32007-07-19 01:14:50 +00001940def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001941 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00001942 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943
1944let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001945 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001946 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001948 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001949 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001950 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001951 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001953 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001954 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00001956 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001957}
Evan Chengb783fa32007-07-19 01:14:50 +00001958def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001959 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001960 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001961def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001964def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001965 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001966 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00001967} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001968
Evan Cheng55687072007-09-14 21:48:26 +00001969let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001971def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001972 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001973 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001974def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001975 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001976 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
1977}
Evan Chengb783fa32007-07-19 01:14:50 +00001978def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
1981 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001982def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001983 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00001985} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001986} // end Two Address instructions
1987
1988// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00001989let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001990def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00001991 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001992 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
1994def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00001995 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001996 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001997 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
1998def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001999 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2002 OpSize;
2003def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002004 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002005 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002006 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2007
2008def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002009 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002010 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002011 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2012 OpSize;
2013def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002014 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002015 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002016 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2017def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002018 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002019 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002020 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2021 OpSize;
2022def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002023 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002024 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002025 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00002026} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002027
2028//===----------------------------------------------------------------------===//
2029// Test instructions are just like AND, except they don't generate a result.
2030//
Evan Cheng55687072007-09-14 21:48:26 +00002031 let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002032let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002033def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002034 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002035 [(X86cmp (and GR8:$src1, GR8:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002036def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002037 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002038 [(X86cmp (and GR16:$src1, GR16:$src2), 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002039def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002040 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002041 [(X86cmp (and GR32:$src1, GR32:$src2), 0)]>;
2042}
2043
Evan Chengb783fa32007-07-19 01:14:50 +00002044def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002045 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002046 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002047def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002048 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002049 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0)]>,
2050 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002051def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0)]>;
2054
2055def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002056 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002057 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002058 [(X86cmp (and GR8:$src1, imm:$src2), 0)]>;
2059def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002060 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002061 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002062 [(X86cmp (and GR16:$src1, imm:$src2), 0)]>, OpSize;
2063def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002064 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002065 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002066 [(X86cmp (and GR32:$src1, imm:$src2), 0)]>;
2067
2068def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002069 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002070 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002071 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0)]>;
2072def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002073 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002074 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002075 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0)]>,
2076 OpSize;
2077def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002078 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002079 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002080 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002081} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002082
2083
2084// Condition code ops, incl. set if equal/not equal/...
Evan Cheng55687072007-09-14 21:48:26 +00002085let Defs = [EFLAGS], Uses = [AH] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002086def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Evan Cheng55687072007-09-14 21:48:26 +00002087let Defs = [AH], Uses = [EFLAGS] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002088def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002089
2090def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002091 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002092 "sete\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002093 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2094 TB; // GR8 = ==
2095def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002096 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002097 "sete\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002098 [(store (X86setcc X86_COND_E), addr:$dst)]>,
2099 TB; // [mem8] = ==
2100def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002101 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002102 "setne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002103 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2104 TB; // GR8 = !=
2105def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002106 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002107 "setne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002108 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
2109 TB; // [mem8] = !=
2110def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002111 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002112 "setl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002113 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2114 TB; // GR8 = < signed
2115def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002116 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002117 "setl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118 [(store (X86setcc X86_COND_L), addr:$dst)]>,
2119 TB; // [mem8] = < signed
2120def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002121 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002122 "setge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2124 TB; // GR8 = >= signed
2125def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002126 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002127 "setge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
2129 TB; // [mem8] = >= signed
2130def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002131 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002132 "setle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2134 TB; // GR8 = <= signed
2135def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002136 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002137 "setle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
2139 TB; // [mem8] = <= signed
2140def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002141 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "setg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002143 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2144 TB; // GR8 = > signed
2145def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002146 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "setg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 [(store (X86setcc X86_COND_G), addr:$dst)]>,
2149 TB; // [mem8] = > signed
2150
2151def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002152 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002153 "setb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002154 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2155 TB; // GR8 = < unsign
2156def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002157 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002158 "setb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002159 [(store (X86setcc X86_COND_B), addr:$dst)]>,
2160 TB; // [mem8] = < unsign
2161def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002162 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002163 "setae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2165 TB; // GR8 = >= unsign
2166def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002167 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002168 "setae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002169 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
2170 TB; // [mem8] = >= unsign
2171def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002172 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002173 "setbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2175 TB; // GR8 = <= unsign
2176def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002177 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002178 "setbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
2180 TB; // [mem8] = <= unsign
2181def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002182 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002183 "seta\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2185 TB; // GR8 = > signed
2186def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002187 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002188 "seta\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002189 [(store (X86setcc X86_COND_A), addr:$dst)]>,
2190 TB; // [mem8] = > signed
2191
2192def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002193 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002194 "sets\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002195 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2196 TB; // GR8 = <sign bit>
2197def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002198 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002199 "sets\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002200 [(store (X86setcc X86_COND_S), addr:$dst)]>,
2201 TB; // [mem8] = <sign bit>
2202def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002203 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002204 "setns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002205 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2206 TB; // GR8 = !<sign bit>
2207def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002208 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002209 "setns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002210 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
2211 TB; // [mem8] = !<sign bit>
2212def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002213 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002214 "setp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002215 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2216 TB; // GR8 = parity
2217def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002218 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002219 "setp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002220 [(store (X86setcc X86_COND_P), addr:$dst)]>,
2221 TB; // [mem8] = parity
2222def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002223 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002224 "setnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002225 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2226 TB; // GR8 = not parity
2227def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002228 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002229 "setnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
2231 TB; // [mem8] = not parity
2232
2233// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002234let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002235def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002236 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002237 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002238 [(X86cmp GR8:$src1, GR8:$src2)]>;
2239def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002240 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002241 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002242 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
2243def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002244 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002245 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002246 [(X86cmp GR32:$src1, GR32:$src2)]>;
2247def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002248 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002249 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002250 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
2251def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002252 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002253 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002254 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
2255def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002256 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002257 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002258 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
2259def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002260 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002261 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002262 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
2263def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002264 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002265 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002266 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
2267def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002268 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002269 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002270 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
2271def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002272 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002273 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002274 [(X86cmp GR8:$src1, imm:$src2)]>;
2275def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002276 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002277 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002278 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
2279def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002280 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002281 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002282 [(X86cmp GR32:$src1, imm:$src2)]>;
2283def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002284 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002285 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002286 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
2287def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002288 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002289 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002290 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
2291def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002292 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002293 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002294 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
2295def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002296 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002297 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002298 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
2299def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002300 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002301 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002302 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
2303def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002304 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002305 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002306 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
2307def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002308 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002309 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002310 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002311} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002312
2313// Sign/Zero extenders
Evan Chengb783fa32007-07-19 01:14:50 +00002314def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002315 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002316 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002317def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002318 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002319 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002320def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002321 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002322 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002323def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002324 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002325 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002326def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002327 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002328 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002329def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002330 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002331 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2332
Evan Chengb783fa32007-07-19 01:14:50 +00002333def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002334 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002335 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002336def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002337 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002338 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002339def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002340 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002341 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002342def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002343 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002344 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002345def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002346 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002347 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002348def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002350 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2351
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002352let Defs = [AX], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00002353def CBW : I<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002354 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2355let Defs = [EAX], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002356def CWDE : I<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002357 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002358
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002359let Defs = [AX,DX], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002360def CWD : I<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002361 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2362let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002363def CDQ : I<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002364 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002365
2366
2367//===----------------------------------------------------------------------===//
2368// Alias Instructions
2369//===----------------------------------------------------------------------===//
2370
2371// Alias instructions that map movr0 to xor.
2372// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Cheng55687072007-09-14 21:48:26 +00002373let Defs = [EFLAGS], isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002374def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002375 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002376 [(set GR8:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002377def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002378 "xor{w}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002379 [(set GR16:$dst, 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002380def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002381 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002382 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002383}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384
2385// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2386// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengb783fa32007-07-19 01:14:50 +00002387def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002388 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002389def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002390 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002391
Evan Chengb783fa32007-07-19 01:14:50 +00002392def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002393 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002394def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002395 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002396let isLoad = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002397def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002398 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002399def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002400 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002401}
Evan Chengb783fa32007-07-19 01:14:50 +00002402def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002403 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002404def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002405 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002406
2407//===----------------------------------------------------------------------===//
2408// Thread Local Storage Instructions
2409//
2410
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002411let Uses = [EBX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002412def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
Dan Gohman91888f02007-07-31 20:11:57 +00002413 "leal\t${sym:mem}(,%ebx,1), $dst",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002414 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002415
2416let AddedComplexity = 10 in
Evan Chengb783fa32007-07-19 01:14:50 +00002417def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002418 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002419 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2420
2421let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002422def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002423 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002424 [(set GR32:$dst,
2425 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2426
Evan Chengb783fa32007-07-19 01:14:50 +00002427def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002428 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002429 [(set GR32:$dst, X86TLStp)]>;
2430
2431//===----------------------------------------------------------------------===//
2432// DWARF Pseudo Instructions
2433//
2434
Evan Chengb783fa32007-07-19 01:14:50 +00002435def DWARF_LOC : I<0, Pseudo, (outs),
2436 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohmanf8133d72007-07-26 15:24:15 +00002437 "; .loc ${file:debug}, ${line:debug}, ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002438 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2439 (i32 imm:$file))]>;
2440
2441//===----------------------------------------------------------------------===//
2442// EH Pseudo Instructions
2443//
2444let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002445 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002446def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002447 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002448 [(X86ehret GR32:$addr)]>;
2449
2450}
2451
2452//===----------------------------------------------------------------------===//
2453// Non-Instruction Patterns
2454//===----------------------------------------------------------------------===//
2455
2456// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2457def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2458def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2459def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2460def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2461def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2462
2463def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2464 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2465def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2466 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2467def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2468 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2469def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2470 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2471
2472def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2473 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2474def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2475 (MOV32mi addr:$dst, texternalsym:$src)>;
2476
2477// Calls
2478def : Pat<(X86tailcall GR32:$dst),
2479 (CALL32r GR32:$dst)>;
2480
2481def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2482 (CALLpcrel32 tglobaladdr:$dst)>;
2483def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2484 (CALLpcrel32 texternalsym:$dst)>;
2485
2486def : Pat<(X86call (i32 tglobaladdr:$dst)),
2487 (CALLpcrel32 tglobaladdr:$dst)>;
2488def : Pat<(X86call (i32 texternalsym:$dst)),
2489 (CALLpcrel32 texternalsym:$dst)>;
2490
2491// X86 specific add which produces a flag.
2492def : Pat<(addc GR32:$src1, GR32:$src2),
2493 (ADD32rr GR32:$src1, GR32:$src2)>;
2494def : Pat<(addc GR32:$src1, (load addr:$src2)),
2495 (ADD32rm GR32:$src1, addr:$src2)>;
2496def : Pat<(addc GR32:$src1, imm:$src2),
2497 (ADD32ri GR32:$src1, imm:$src2)>;
2498def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2499 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2500
2501def : Pat<(subc GR32:$src1, GR32:$src2),
2502 (SUB32rr GR32:$src1, GR32:$src2)>;
2503def : Pat<(subc GR32:$src1, (load addr:$src2)),
2504 (SUB32rm GR32:$src1, addr:$src2)>;
2505def : Pat<(subc GR32:$src1, imm:$src2),
2506 (SUB32ri GR32:$src1, imm:$src2)>;
2507def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2508 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2509
2510def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2511 (MOV8mi addr:$dst, imm:$src)>;
2512def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2513 (MOV8mr addr:$dst, GR8:$src)>;
2514
2515// Comparisons.
2516
2517// TEST R,R is smaller than CMP R,0
2518def : Pat<(X86cmp GR8:$src1, 0),
2519 (TEST8rr GR8:$src1, GR8:$src1)>;
2520def : Pat<(X86cmp GR16:$src1, 0),
2521 (TEST16rr GR16:$src1, GR16:$src1)>;
2522def : Pat<(X86cmp GR32:$src1, 0),
2523 (TEST32rr GR32:$src1, GR32:$src1)>;
2524
2525// {s|z}extload bool -> {s|z}extload byte
2526def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2527def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2528def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2529def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2530def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2531
2532// extload bool -> extload byte
2533def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2534def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2535def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2536def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2537def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2538def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2539
2540// anyext -> zext
2541def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2542def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2543def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2544def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2545def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2546def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2547
2548//===----------------------------------------------------------------------===//
2549// Some peepholes
2550//===----------------------------------------------------------------------===//
2551
2552// (shl x, 1) ==> (add x, x)
2553def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2554def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2555def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2556
2557// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2558def : Pat<(or (srl GR32:$src1, CL:$amt),
2559 (shl GR32:$src2, (sub 32, CL:$amt))),
2560 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2561
2562def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2563 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2564 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2565
2566// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2567def : Pat<(or (shl GR32:$src1, CL:$amt),
2568 (srl GR32:$src2, (sub 32, CL:$amt))),
2569 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2570
2571def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2572 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2573 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2574
2575// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2576def : Pat<(or (srl GR16:$src1, CL:$amt),
2577 (shl GR16:$src2, (sub 16, CL:$amt))),
2578 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2579
2580def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2581 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2582 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2583
2584// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2585def : Pat<(or (shl GR16:$src1, CL:$amt),
2586 (srl GR16:$src2, (sub 16, CL:$amt))),
2587 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2588
2589def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2590 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2591 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2592
2593
2594//===----------------------------------------------------------------------===//
2595// Floating Point Stack Support
2596//===----------------------------------------------------------------------===//
2597
2598include "X86InstrFPStack.td"
2599
2600//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00002601// X86-64 Support
2602//===----------------------------------------------------------------------===//
2603
2604include "X86InstrX86-64.td"
2605
2606//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002607// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2608//===----------------------------------------------------------------------===//
2609
2610include "X86InstrMMX.td"
2611
2612//===----------------------------------------------------------------------===//
2613// XMM Floating point support (requires SSE / SSE2)
2614//===----------------------------------------------------------------------===//
2615
2616include "X86InstrSSE.td"