blob: 4f6e372560ecf83a3cc56be8e8de6eb9822c7205 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
20def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
24def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
26def SDTX86Cmov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>]>;
29
30def SDTX86BrCond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i8>]>;
32
33def SDTX86SetCC : SDTypeProfile<1, 1,
34 [SDTCisVT<0, i8>, SDTCisVT<1, i8>]>;
35
36def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
37
38def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
39def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
40 SDTCisVT<1, i32> ]>;
41
42def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
43
44def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
45
46def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
47
48def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
49
50def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
51
52def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
53
54def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
55
56def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
57def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
58
59def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest,
60 [SDNPHasChain, SDNPOutFlag]>;
61
62def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov,
63 [SDNPInFlag, SDNPOutFlag]>;
64def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
65 [SDNPHasChain, SDNPInFlag]>;
66def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC,
67 [SDNPInFlag, SDNPOutFlag]>;
68
69def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
70 [SDNPHasChain, SDNPOptInFlag]>;
71
72def X86callseq_start :
73 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
74 [SDNPHasChain, SDNPOutFlag]>;
75def X86callseq_end :
76 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
77 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
78
79def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
80 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
81
82def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
83 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
84
85def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
86 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
87def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
88 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
89
90def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
91 [SDNPHasChain, SDNPOutFlag]>;
92
93def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
94def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
95
96def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
97 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
98def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
99
100def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
101 [SDNPHasChain]>;
102
103
104//===----------------------------------------------------------------------===//
105// X86 Operand Definitions.
106//
107
108// *mem - Operand definitions for the funky X86 addressing mode operands.
109//
110class X86MemOperand<string printMethod> : Operand<iPTR> {
111 let PrintMethod = printMethod;
112 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
113}
114
115def i8mem : X86MemOperand<"printi8mem">;
116def i16mem : X86MemOperand<"printi16mem">;
117def i32mem : X86MemOperand<"printi32mem">;
118def i64mem : X86MemOperand<"printi64mem">;
119def i128mem : X86MemOperand<"printi128mem">;
120def f32mem : X86MemOperand<"printf32mem">;
121def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000122def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000123def f128mem : X86MemOperand<"printf128mem">;
124
125def lea32mem : Operand<i32> {
126 let PrintMethod = "printi32mem";
127 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
128}
129
130def SSECC : Operand<i8> {
131 let PrintMethod = "printSSECC";
132}
133
134def piclabel: Operand<i32> {
135 let PrintMethod = "printPICLabel";
136}
137
138// A couple of more descriptive operand definitions.
139// 16-bits but only 8 bits are significant.
140def i16i8imm : Operand<i16>;
141// 32-bits but only 8 bits are significant.
142def i32i8imm : Operand<i32>;
143
144// Branch targets have OtherVT type.
145def brtarget : Operand<OtherVT>;
146
147//===----------------------------------------------------------------------===//
148// X86 Complex Pattern Definitions.
149//
150
151// Define X86 specific addressing mode.
152def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
153def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
154 [add, mul, shl, or, frameindex], []>;
155
156//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000157// X86 Instruction Predicate Definitions.
158def HasMMX : Predicate<"Subtarget->hasMMX()">;
159def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
160def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
161def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
162def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
163def FPStack : Predicate<"!Subtarget->hasSSE2()">;
164def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
165def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Evan Cheng09e13792007-08-01 23:45:51 +0000166def HasLow4G : Predicate<"Subtarget->hasLow4GUserSpaceAddress()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
168def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
169def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
170
171//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000172// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173//
174
Evan Cheng86ab7d32007-07-31 08:04:03 +0000175include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176
177//===----------------------------------------------------------------------===//
178// Pattern fragments...
179//
180
181// X86 specific condition code. These correspond to CondCode in
182// X86InstrInfo.h. They must be kept in synch.
183def X86_COND_A : PatLeaf<(i8 0)>;
184def X86_COND_AE : PatLeaf<(i8 1)>;
185def X86_COND_B : PatLeaf<(i8 2)>;
186def X86_COND_BE : PatLeaf<(i8 3)>;
187def X86_COND_E : PatLeaf<(i8 4)>;
188def X86_COND_G : PatLeaf<(i8 5)>;
189def X86_COND_GE : PatLeaf<(i8 6)>;
190def X86_COND_L : PatLeaf<(i8 7)>;
191def X86_COND_LE : PatLeaf<(i8 8)>;
192def X86_COND_NE : PatLeaf<(i8 9)>;
193def X86_COND_NO : PatLeaf<(i8 10)>;
194def X86_COND_NP : PatLeaf<(i8 11)>;
195def X86_COND_NS : PatLeaf<(i8 12)>;
196def X86_COND_O : PatLeaf<(i8 13)>;
197def X86_COND_P : PatLeaf<(i8 14)>;
198def X86_COND_S : PatLeaf<(i8 15)>;
199
200def i16immSExt8 : PatLeaf<(i16 imm), [{
201 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
202 // sign extended field.
203 return (int16_t)N->getValue() == (int8_t)N->getValue();
204}]>;
205
206def i32immSExt8 : PatLeaf<(i32 imm), [{
207 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
208 // sign extended field.
209 return (int32_t)N->getValue() == (int8_t)N->getValue();
210}]>;
211
212// Helper fragments for loads.
213def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
214def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
215def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
216def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
217
218def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
219def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000220def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000221
222def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
223def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
224def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
225def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
226def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
227
228def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
229def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
230def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
231def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
232def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
233def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
234
235def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
236def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
237def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
238def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
239def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
240def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
241
242//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243// Instruction list...
244//
245
246// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
247// a stack adjustment and the codegen must know that they may modify the stack
248// pointer before prolog-epilog rewriting occurs.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000249let Defs = [ESP], Uses = [ESP] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000250def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt), "#ADJCALLSTACKDOWN",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000251 [(X86callseq_start imm:$amt)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000252def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000253 "#ADJCALLSTACKUP",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000254 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
255}
Evan Chengb783fa32007-07-19 01:14:50 +0000256def IMPLICIT_USE : I<0, Pseudo, (outs), (ins variable_ops),
257 "#IMPLICIT_USE", []>;
258def IMPLICIT_DEF : I<0, Pseudo, (outs variable_ops), (ins),
259 "#IMPLICIT_DEF", []>;
260def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000261 "#IMPLICIT_DEF $dst",
262 [(set GR8:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000263def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000264 "#IMPLICIT_DEF $dst",
265 [(set GR16:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000266def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000267 "#IMPLICIT_DEF $dst",
268 [(set GR32:$dst, (undef))]>;
269
270// Nop
Evan Chengb783fa32007-07-19 01:14:50 +0000271def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000272
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000273
274//===----------------------------------------------------------------------===//
275// Control Flow Instructions...
276//
277
278// Return instructions.
279let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +0000280 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000281 def RET : I<0xC3, RawFrm, (outs), (ins), "ret", [(X86retflag 0)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000282 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt), "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000283 [(X86retflag imm:$amt)]>;
284}
285
286// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000287let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000288 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
289 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290
291// Indirect branches
292let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000293 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000294
Evan Cheng37e7c752007-07-21 00:34:19 +0000295let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000296 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000297 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000298 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000299 [(brind (loadi32 addr:$dst))]>;
300}
301
302// Conditional branches
Dan Gohman91888f02007-07-31 20:11:57 +0000303def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304 [(X86brcond bb:$dst, X86_COND_E)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000305def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306 [(X86brcond bb:$dst, X86_COND_NE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000307def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000308 [(X86brcond bb:$dst, X86_COND_L)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000309def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000310 [(X86brcond bb:$dst, X86_COND_LE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000311def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000312 [(X86brcond bb:$dst, X86_COND_G)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000313def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000314 [(X86brcond bb:$dst, X86_COND_GE)]>, TB;
315
Dan Gohman91888f02007-07-31 20:11:57 +0000316def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000317 [(X86brcond bb:$dst, X86_COND_B)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000318def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000319 [(X86brcond bb:$dst, X86_COND_BE)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000320def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000321 [(X86brcond bb:$dst, X86_COND_A)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000322def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323 [(X86brcond bb:$dst, X86_COND_AE)]>, TB;
324
Dan Gohman91888f02007-07-31 20:11:57 +0000325def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000326 [(X86brcond bb:$dst, X86_COND_S)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000327def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000328 [(X86brcond bb:$dst, X86_COND_NS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000329def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000330 [(X86brcond bb:$dst, X86_COND_P)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000331def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000332 [(X86brcond bb:$dst, X86_COND_NP)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000333def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000334 [(X86brcond bb:$dst, X86_COND_O)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000335def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000336 [(X86brcond bb:$dst, X86_COND_NO)]>, TB;
337
338//===----------------------------------------------------------------------===//
339// Call Instructions...
340//
Evan Cheng37e7c752007-07-21 00:34:19 +0000341let isCall = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000342 // All calls clobber the non-callee saved registers...
343 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
344 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
345 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000346 def CALLpcrel32 : I<0xE8, RawFrm, (outs), (ins i32imm:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000347 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000348 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000349 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000350 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000351 "call\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000352 }
353
354// Tail call stuff.
Evan Cheng37e7c752007-07-21 00:34:19 +0000355let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000356 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAIL CALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000357 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000358let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000359 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp\t{*}$dst # TAIL CALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000360 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000361let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000362 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000363 "jmp\t{*}$dst # TAIL CALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000364
365//===----------------------------------------------------------------------===//
366// Miscellaneous Instructions...
367//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000368let Defs = [EBP, ESP], Uses = [EBP, ESP] in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000369def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000370 (outs), (ins), "leave", []>;
371
372let Defs = [ESP], Uses = [ESP] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000373def POP32r : I<0x58, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000374 (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000375
376def PUSH32r : I<0x50, AddRegFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000377 (outs), (ins GR32:$reg), "push{l}\t$reg", []>;
378}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000379
Evan Chengb783fa32007-07-19 01:14:50 +0000380def MovePCtoStack : I<0, Pseudo, (outs), (ins piclabel:$label),
Dan Gohman91888f02007-07-31 20:11:57 +0000381 "call\t$label", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000382
383let isTwoAddress = 1 in // GR32 = bswap GR32
384 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000385 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000386 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000387 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
388
Evan Chengb783fa32007-07-19 01:14:50 +0000389// FIXME: Model xchg* as two address instructions?
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000390def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
Evan Chengb783fa32007-07-19 01:14:50 +0000391 (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000392 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000393def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000394 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000395 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000396def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000397 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000398 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000399
400def XCHG8mr : I<0x86, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000401 (outs), (ins i8mem:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000402 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000403def XCHG16mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000404 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000405 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406def XCHG32mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000407 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000408 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409def XCHG8rm : I<0x86, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000410 (outs), (ins GR8:$src1, i8mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000411 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000412def XCHG16rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000413 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000414 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000415def XCHG32rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000416 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000417 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000418
419def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000420 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000421 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000422def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000423 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000424 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000425 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
426
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000427let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000428def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000429 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000430def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000431 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000432def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000433 [(X86rep_movs i32)]>, REP;
434}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000435
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000436let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000437def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000438 [(X86rep_stos i8)]>, REP;
439let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000440def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000441 [(X86rep_stos i16)]>, REP, OpSize;
442let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000443def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000444 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000446let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000447def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000448 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000449
450//===----------------------------------------------------------------------===//
451// Input/Output Instructions...
452//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000453let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000454def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000455 "in{b}\t{%dx, %al|%AL, %DX}", []>;
456let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000457def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000458 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
459let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000460def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000461 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000462
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000463let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000464def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000465 "in{b}\t{$port, %al|%AL, $port}", []>;
466let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000467def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000468 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
469let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000470def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000471 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000472
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000473let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000474def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000475 "out{b}\t{%al, %dx|%DX, %AL}", []>;
476let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000477def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000478 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
479let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000480def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000481 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000482
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000483let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000484def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000485 "out{b}\t{%al, $port|$port, %AL}", []>;
486let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000487def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000488 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
489let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000490def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000491 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000492
493//===----------------------------------------------------------------------===//
494// Move Instructions...
495//
Evan Chengb783fa32007-07-19 01:14:50 +0000496def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000497 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000498def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000499 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000500def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000501 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000502let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000503def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000504 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000505 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000506def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000507 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000508 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000509def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000510 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000511 [(set GR32:$dst, imm:$src)]>;
512}
Evan Chengb783fa32007-07-19 01:14:50 +0000513def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000514 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000516def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000517 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000518 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000519def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000520 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000521 [(store (i32 imm:$src), addr:$dst)]>;
522
Evan Cheng4e84e452007-08-30 05:49:43 +0000523let isLoad = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000524def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000525 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000526 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000527def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000528 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000530def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000531 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000533}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000534
Evan Chengb783fa32007-07-19 01:14:50 +0000535def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000536 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000537 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000538def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000539 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000540 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000541def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000542 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000543 [(store GR32:$src, addr:$dst)]>;
544
545//===----------------------------------------------------------------------===//
546// Fixed-Register Multiplication and Division Instructions...
547//
548
549// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000550let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000551def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000552 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
553 // This probably ought to be moved to a def : Pat<> if the
554 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000555 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000556let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000557def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000558 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000559let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000560def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
561 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000562let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000563def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000564 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000565 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
566 // This probably ought to be moved to a def : Pat<> if the
567 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000568 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000569let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000570def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000571 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng55687072007-09-14 21:48:26 +0000572let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000573def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000574 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000575
Evan Cheng55687072007-09-14 21:48:26 +0000576let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000577def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
578 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000579let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000580def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000581 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000582let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000583def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
584 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000585let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000586def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000587 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000588let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000589def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000590 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
591let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000592def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000593 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000594
595// unsigned division/remainder
Evan Cheng55687072007-09-14 21:48:26 +0000596let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000597def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000598 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000599let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000600def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000601 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000602let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000603def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000604 "div{l}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000605let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000606def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000607 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000608let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000609def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000610 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000611let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000612def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000613 "div{l}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000614
615// Signed division/remainder.
Evan Cheng55687072007-09-14 21:48:26 +0000616let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000617def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000618 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000619let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000620def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000621 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000622let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000623def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000624 "idiv{l}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000625let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000626def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000627 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000628let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000629def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000630 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000631let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000632def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000633 "idiv{l}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000634
635
636//===----------------------------------------------------------------------===//
637// Two address Instructions...
638//
639let isTwoAddress = 1 in {
640
641// Conditional moves
642def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000643 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000644 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000645 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
646 X86_COND_B))]>,
647 TB, OpSize;
648def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000649 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000650 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000651 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
652 X86_COND_B))]>,
653 TB, OpSize;
654def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000655 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000656 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000657 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
658 X86_COND_B))]>,
659 TB;
660def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000661 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000662 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000663 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
664 X86_COND_B))]>,
665 TB;
666
667def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000668 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000669 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000670 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
671 X86_COND_AE))]>,
672 TB, OpSize;
673def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000674 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000675 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
677 X86_COND_AE))]>,
678 TB, OpSize;
679def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000680 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000681 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000682 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
683 X86_COND_AE))]>,
684 TB;
685def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000686 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000687 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000688 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
689 X86_COND_AE))]>,
690 TB;
691
692def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000693 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000694 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000695 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
696 X86_COND_E))]>,
697 TB, OpSize;
698def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000699 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000700 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000701 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
702 X86_COND_E))]>,
703 TB, OpSize;
704def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000705 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000706 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000707 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
708 X86_COND_E))]>,
709 TB;
710def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000711 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000712 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
714 X86_COND_E))]>,
715 TB;
716
717def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000718 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000719 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
721 X86_COND_NE))]>,
722 TB, OpSize;
723def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000724 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000725 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000726 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
727 X86_COND_NE))]>,
728 TB, OpSize;
729def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000730 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000731 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000732 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
733 X86_COND_NE))]>,
734 TB;
735def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000736 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000737 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000738 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
739 X86_COND_NE))]>,
740 TB;
741
742def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000743 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000744 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000745 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
746 X86_COND_BE))]>,
747 TB, OpSize;
748def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000749 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000750 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000751 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
752 X86_COND_BE))]>,
753 TB, OpSize;
754def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000755 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000756 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000757 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
758 X86_COND_BE))]>,
759 TB;
760def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000761 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000762 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000763 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
764 X86_COND_BE))]>,
765 TB;
766
767def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000768 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000769 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000770 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
771 X86_COND_A))]>,
772 TB, OpSize;
773def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000774 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000775 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000776 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
777 X86_COND_A))]>,
778 TB, OpSize;
779def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000780 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000781 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000782 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
783 X86_COND_A))]>,
784 TB;
785def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000786 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000787 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000788 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
789 X86_COND_A))]>,
790 TB;
791
792def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000793 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000794 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
796 X86_COND_L))]>,
797 TB, OpSize;
798def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000799 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000800 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
802 X86_COND_L))]>,
803 TB, OpSize;
804def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000805 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000806 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
808 X86_COND_L))]>,
809 TB;
810def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000811 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000812 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
814 X86_COND_L))]>,
815 TB;
816
817def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000818 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000819 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000820 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
821 X86_COND_GE))]>,
822 TB, OpSize;
823def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000824 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000825 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000826 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
827 X86_COND_GE))]>,
828 TB, OpSize;
829def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000830 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000831 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000832 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
833 X86_COND_GE))]>,
834 TB;
835def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000836 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000837 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000838 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
839 X86_COND_GE))]>,
840 TB;
841
842def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000843 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000844 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
846 X86_COND_LE))]>,
847 TB, OpSize;
848def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000849 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000850 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000851 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
852 X86_COND_LE))]>,
853 TB, OpSize;
854def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000855 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000856 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000857 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
858 X86_COND_LE))]>,
859 TB;
860def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000861 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000862 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000863 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
864 X86_COND_LE))]>,
865 TB;
866
867def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000868 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000869 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000870 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
871 X86_COND_G))]>,
872 TB, OpSize;
873def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000874 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000875 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000876 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
877 X86_COND_G))]>,
878 TB, OpSize;
879def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000880 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000881 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000882 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
883 X86_COND_G))]>,
884 TB;
885def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000886 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000887 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000888 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
889 X86_COND_G))]>,
890 TB;
891
892def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000893 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000894 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000895 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
896 X86_COND_S))]>,
897 TB, OpSize;
898def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000899 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000900 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000901 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
902 X86_COND_S))]>,
903 TB, OpSize;
904def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000905 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000906 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000907 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
908 X86_COND_S))]>,
909 TB;
910def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000911 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000912 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000913 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
914 X86_COND_S))]>,
915 TB;
916
917def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000918 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000919 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000920 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
921 X86_COND_NS))]>,
922 TB, OpSize;
923def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000924 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000925 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000926 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
927 X86_COND_NS))]>,
928 TB, OpSize;
929def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000930 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000931 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000932 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
933 X86_COND_NS))]>,
934 TB;
935def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000936 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000937 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000938 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
939 X86_COND_NS))]>,
940 TB;
941
942def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000943 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000944 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000945 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
946 X86_COND_P))]>,
947 TB, OpSize;
948def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000949 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000950 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000951 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
952 X86_COND_P))]>,
953 TB, OpSize;
954def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000955 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000956 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000957 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
958 X86_COND_P))]>,
959 TB;
960def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000961 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000962 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000963 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
964 X86_COND_P))]>,
965 TB;
966
967def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000968 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000969 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000970 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
971 X86_COND_NP))]>,
972 TB, OpSize;
973def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000974 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000975 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000976 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
977 X86_COND_NP))]>,
978 TB, OpSize;
979def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000980 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000981 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000982 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
983 X86_COND_NP))]>,
984 TB;
985def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000986 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000987 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000988 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
989 X86_COND_NP))]>,
990 TB;
991
992
993// unary instructions
994let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +0000995let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000996def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000997 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000998def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000999 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001000def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001001 [(set GR32:$dst, (ineg GR32:$src))]>;
1002let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001003 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001004 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001005 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001007 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1009
1010}
Evan Cheng55687072007-09-14 21:48:26 +00001011} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001012
Dan Gohman91888f02007-07-31 20:11:57 +00001013def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001015def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001016 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001017def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 [(set GR32:$dst, (not GR32:$src))]>;
1019let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001020 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001021 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001022 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001024 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1026}
1027} // CodeSize
1028
1029// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001030let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001031let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001032def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033 [(set GR8:$dst, (add GR8:$src, 1))]>;
1034let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001035def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001036 [(set GR16:$dst, (add GR16:$src, 1))]>,
1037 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001038def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1040}
1041let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001042 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001043 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001044 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001046 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001047 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1048}
1049
1050let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001051def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052 [(set GR8:$dst, (add GR8:$src, -1))]>;
1053let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001054def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001055 [(set GR16:$dst, (add GR16:$src, -1))]>,
1056 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001057def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001058 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1059}
1060
1061let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001062 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001063 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001064 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001065 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001066 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1068}
Evan Cheng55687072007-09-14 21:48:26 +00001069} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001070
1071// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001072let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001073let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1074def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001075 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001076 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001077 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1078def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001079 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001080 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1082def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001083 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001084 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001085 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1086}
1087
1088def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001089 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001090 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001091 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1092def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001093 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001094 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1096def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001097 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001098 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001099 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1100
1101def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001102 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001103 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1105def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001106 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001107 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1109def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001110 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001111 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001112 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1113def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001114 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001115 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001116 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1117 OpSize;
1118def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001119 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001120 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1122
1123let isTwoAddress = 0 in {
1124 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001125 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001126 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001127 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1128 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001129 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001130 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001131 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1132 OpSize;
1133 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001134 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001135 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1137 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001138 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001139 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1141 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001142 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001143 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001144 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1145 OpSize;
1146 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001147 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001148 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001149 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1150 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001151 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001152 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1154 OpSize;
1155 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001156 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001157 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1159}
1160
1161
1162let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001163def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001164 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001166def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001167 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001168 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001169def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001170 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001171 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1172}
Evan Chengb783fa32007-07-19 01:14:50 +00001173def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001174 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001175 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001176def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001177 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001178 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001179def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001180 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001181 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1182
Evan Chengb783fa32007-07-19 01:14:50 +00001183def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001184 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001185 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001186def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001187 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001188 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001189def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001190 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001191 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1192
Evan Chengb783fa32007-07-19 01:14:50 +00001193def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001194 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001195 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001196def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001197 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001198 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1199let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001200 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001201 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001202 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001203 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001204 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001205 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001206 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001207 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001208 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001209 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001210 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001212 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001213 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001214 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1215 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001216 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001217 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001218 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001219 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001220 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001221 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1222 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001223 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001224 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001225 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1226}
1227
1228
1229let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1230def XOR8rr : I<0x30, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001231 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001232 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1234def XOR16rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001235 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001236 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001237 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1238def XOR32rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001239 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001240 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001241 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1242}
1243
1244def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001245 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001246 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001247 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1248def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001249 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001250 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001251 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1252def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001253 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001254 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001255 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1256
1257def XOR8ri : Ii8<0x80, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001258 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001259 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1261def XOR16ri : Ii16<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001262 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001263 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1265def XOR32ri : Ii32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001266 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001267 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001268 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1269def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001270 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001271 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1273 OpSize;
1274def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001275 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001276 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1278let isTwoAddress = 0 in {
1279 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001280 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001281 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001282 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1283 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001284 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001285 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1287 OpSize;
1288 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001289 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001290 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1292 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001293 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001294 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1296 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001297 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001298 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001299 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1300 OpSize;
1301 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001302 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001303 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1305 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001306 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001307 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1309 OpSize;
1310 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001311 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001312 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1314}
Evan Cheng55687072007-09-14 21:48:26 +00001315} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001316
1317// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001318let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001319let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001320def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001321 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001322 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001323def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001324 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001325 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001326def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001327 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001328 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1329}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001330
Evan Chengb783fa32007-07-19 01:14:50 +00001331def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001332 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1334let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001335def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001336 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001337 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001338def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001339 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001340 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1341}
1342
1343// Shift left by one. Not used because (add x, x) is slightly cheaper.
Evan Chengb783fa32007-07-19 01:14:50 +00001344def SHL8r1 : I<0xD0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001345 "shl{b}\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001346def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001347 "shl{w}\t$dst", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001348def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001349 "shl{l}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001350
1351let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001352 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001353 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001354 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001355 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001356 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001357 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001358 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001359 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001360 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001361 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1362 }
Evan Chengb783fa32007-07-19 01:14:50 +00001363 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001364 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001366 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001367 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001368 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1369 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001370 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001371 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001372 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1373
1374 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001375 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001376 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001378 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001379 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001380 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1381 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001382 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001383 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001384 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1385}
1386
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001387let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001388def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001389 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001390 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001391def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001392 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001393 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001394def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001395 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001396 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1397}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001398
Evan Chengb783fa32007-07-19 01:14:50 +00001399def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001400 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001401 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001402def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001403 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001404 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001405def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001406 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001407 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1408
1409// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001410def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001411 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001412 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001413def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001414 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001415 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001416def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001418 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1419
1420let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001421 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001422 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001423 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001424 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001425 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001426 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001427 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001428 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001429 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001430 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001431 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1432 }
Evan Chengb783fa32007-07-19 01:14:50 +00001433 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001434 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001435 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001436 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001437 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001438 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1439 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001440 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001441 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001442 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1443
1444 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001445 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001446 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001448 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001449 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001450 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001451 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001452 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001453 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1454}
1455
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001456let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001457def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001459 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001460def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001461 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001462 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001463def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001464 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001465 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1466}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467
Evan Chengb783fa32007-07-19 01:14:50 +00001468def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001469 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001470 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001471def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001472 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001473 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1474 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001475def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001476 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001477 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1478
1479// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001480def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001482 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001483def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001484 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001485 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001486def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001487 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001488 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1489
1490let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001491 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001492 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001493 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001494 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001495 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001496 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001497 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001498 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001499 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001500 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1501 }
Evan Chengb783fa32007-07-19 01:14:50 +00001502 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001503 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001504 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001505 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001507 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1508 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001509 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001510 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001511 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1512
1513 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001514 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001515 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001517 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001518 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001519 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1520 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001521 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001522 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001523 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1524}
1525
1526// Rotate instructions
1527// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001528let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001529def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001530 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001531 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001532def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001533 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001534 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001535def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001536 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001537 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1538}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001539
Evan Chengb783fa32007-07-19 01:14:50 +00001540def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001541 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001542 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001543def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001544 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001545 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001546def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1549
1550// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001551def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001552 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001553 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001554def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001555 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001556 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001557def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001559 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1560
1561let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001562 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001563 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001564 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001565 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001566 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001568 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001569 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001570 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001571 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1572 }
Evan Chengb783fa32007-07-19 01:14:50 +00001573 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001574 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001575 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001576 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001577 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1579 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001580 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001581 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001582 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1583
1584 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001585 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001586 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001587 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001588 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001589 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001590 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1591 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001592 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001593 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001594 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1595}
1596
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001597let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001598def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001599 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001600 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001601def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001603 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001604def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001605 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001606 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1607}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001608
Evan Chengb783fa32007-07-19 01:14:50 +00001609def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001610 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001611 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001612def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001613 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001614 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001615def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001616 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1618
1619// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001620def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001621 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001622 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001623def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001624 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001625 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001626def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001627 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001628 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1629
1630let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001631 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001632 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001633 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001634 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001635 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001636 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001637 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001638 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001639 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001640 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1641 }
Evan Chengb783fa32007-07-19 01:14:50 +00001642 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001643 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001644 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001645 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001646 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001647 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1648 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001649 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001650 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001651 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1652
1653 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001654 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001657 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001659 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1660 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001661 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001662 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001663 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1664}
1665
1666
1667
1668// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001669let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001670def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001672 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001673def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001674 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001675 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001676def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001677 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001678 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001679 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001680def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001681 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001682 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001683 TB, OpSize;
1684}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001685
1686let isCommutable = 1 in { // These instructions commute to each other.
1687def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001688 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001689 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001690 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1691 (i8 imm:$src3)))]>,
1692 TB;
1693def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001694 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001695 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001696 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1697 (i8 imm:$src3)))]>,
1698 TB;
1699def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001700 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001701 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001702 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1703 (i8 imm:$src3)))]>,
1704 TB, OpSize;
1705def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001706 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001707 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001708 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1709 (i8 imm:$src3)))]>,
1710 TB, OpSize;
1711}
1712
1713let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001714 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001715 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001718 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001719 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001722 addr:$dst)]>, TB;
1723 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001724 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001725 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001726 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1728 (i8 imm:$src3)), addr:$dst)]>,
1729 TB;
1730 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001731 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001732 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1734 (i8 imm:$src3)), addr:$dst)]>,
1735 TB;
1736
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001737 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001738 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001739 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001740 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001741 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001742 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001743 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001744 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001745 addr:$dst)]>, TB, OpSize;
1746 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001747 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001748 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001749 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001750 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1751 (i8 imm:$src3)), addr:$dst)]>,
1752 TB, OpSize;
1753 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001754 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001755 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001756 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1757 (i8 imm:$src3)), addr:$dst)]>,
1758 TB, OpSize;
1759}
Evan Cheng55687072007-09-14 21:48:26 +00001760} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001761
1762
1763// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001764let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001765let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001766def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1767 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001769 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1770let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001771def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1772 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001773 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001775def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1776 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001778 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1779} // end isConvertibleToThreeAddress
1780} // end isCommutable
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001781def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1782 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001783 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001784 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001785def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1786 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001787 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001788 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1789def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1790 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001791 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001792 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1793
Evan Chengb783fa32007-07-19 01:14:50 +00001794def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001795 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001796 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1797
1798let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001799def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1800 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001801 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001802 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001803def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1804 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001805 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001806 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001807def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1808 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001809 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001810 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1811def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1812 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001813 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001814 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001815}
1816
1817let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001818 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001819 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001820 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001821 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001822 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001823 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001824 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001825 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001826 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001828 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001829 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001830 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001831 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001832 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001833 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001834 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001835 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001836 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001837 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001838 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001839 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001841 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001842 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001843 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001844 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1845}
1846
1847let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001848def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001849 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001850 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1851}
Evan Chengb783fa32007-07-19 01:14:50 +00001852def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001853 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001854 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001855def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001856 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001858def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1861
1862let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001863 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001864 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001865 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001866 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001867 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001868 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001869 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001870 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001871 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1872}
1873
Evan Chengb783fa32007-07-19 01:14:50 +00001874def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001876 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001877def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001878 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001879 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001880def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001881 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001882 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001883def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001884 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001885 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001886def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001887 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001888 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001889def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1892
Evan Chengb783fa32007-07-19 01:14:50 +00001893def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001894 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001895 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001896def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001897 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001898 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001899def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001900 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001901 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001902def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001903 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001904 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng55687072007-09-14 21:48:26 +00001905 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001906def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001907 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001908 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1909let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001910 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001911 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001912 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001913 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001914 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001916 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001917 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001919 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001920 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001921 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001922 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001923 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001924 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001925 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001926 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001927 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001928 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001929 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001930 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001931 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001932 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001933 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001934 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001935 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001936 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1937}
1938
Evan Chengb783fa32007-07-19 01:14:50 +00001939def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001940 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00001941 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942
1943let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001944 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001945 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001946 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001947 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001948 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001949 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001950 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001951 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001952 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001953 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001954 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00001955 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956}
Evan Chengb783fa32007-07-19 01:14:50 +00001957def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001958 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001959 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001960def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001961 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001962 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001963def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001964 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001965 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00001966} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001967
Evan Cheng55687072007-09-14 21:48:26 +00001968let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001969let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001970def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001971 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001972 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001973def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001974 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001975 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
1976}
Evan Chengb783fa32007-07-19 01:14:50 +00001977def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001978 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001979 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
1980 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001981def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001983 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00001984} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001985} // end Two Address instructions
1986
1987// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00001988let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001989def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00001990 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001991 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
1993def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00001994 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
1997def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00001998 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001999 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002000 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2001 OpSize;
2002def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002003 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2006
2007def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002008 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002009 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002010 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2011 OpSize;
2012def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002013 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002014 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002015 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2016def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002017 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002018 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002019 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2020 OpSize;
2021def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002022 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002023 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002024 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00002025} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002026
2027//===----------------------------------------------------------------------===//
2028// Test instructions are just like AND, except they don't generate a result.
2029//
Evan Cheng55687072007-09-14 21:48:26 +00002030 let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002031let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002032def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034 [(X86cmp (and GR8:$src1, GR8:$src2), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002035def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002036 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002037 [(X86cmp (and GR16:$src1, GR16:$src2), 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002038def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002039 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002040 [(X86cmp (and GR32:$src1, GR32:$src2), 0)]>;
2041}
2042
Evan Chengb783fa32007-07-19 01:14:50 +00002043def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002044 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002045 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002046def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002047 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002048 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0)]>,
2049 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002050def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002051 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002052 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0)]>;
2053
2054def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002055 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002056 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002057 [(X86cmp (and GR8:$src1, imm:$src2), 0)]>;
2058def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002059 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002060 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002061 [(X86cmp (and GR16:$src1, imm:$src2), 0)]>, OpSize;
2062def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002063 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002064 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002065 [(X86cmp (and GR32:$src1, imm:$src2), 0)]>;
2066
2067def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002068 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002069 "test{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002070 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0)]>;
2071def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002072 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002073 "test{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0)]>,
2075 OpSize;
2076def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002077 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002078 "test{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002079 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002080} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002081
2082
2083// Condition code ops, incl. set if equal/not equal/...
Evan Cheng55687072007-09-14 21:48:26 +00002084let Defs = [EFLAGS], Uses = [AH] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002085def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Evan Cheng55687072007-09-14 21:48:26 +00002086let Defs = [AH], Uses = [EFLAGS] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002087def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088
2089def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002090 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002091 "sete\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002092 [(set GR8:$dst, (X86setcc X86_COND_E))]>,
2093 TB; // GR8 = ==
2094def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002095 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002096 "sete\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002097 [(store (X86setcc X86_COND_E), addr:$dst)]>,
2098 TB; // [mem8] = ==
2099def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002100 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002101 "setne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002102 [(set GR8:$dst, (X86setcc X86_COND_NE))]>,
2103 TB; // GR8 = !=
2104def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002105 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002106 "setne\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107 [(store (X86setcc X86_COND_NE), addr:$dst)]>,
2108 TB; // [mem8] = !=
2109def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002110 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002111 "setl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112 [(set GR8:$dst, (X86setcc X86_COND_L))]>,
2113 TB; // GR8 = < signed
2114def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002115 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002116 "setl\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002117 [(store (X86setcc X86_COND_L), addr:$dst)]>,
2118 TB; // [mem8] = < signed
2119def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002120 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002121 "setge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002122 [(set GR8:$dst, (X86setcc X86_COND_GE))]>,
2123 TB; // GR8 = >= signed
2124def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002125 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002126 "setge\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002127 [(store (X86setcc X86_COND_GE), addr:$dst)]>,
2128 TB; // [mem8] = >= signed
2129def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002130 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002131 "setle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002132 [(set GR8:$dst, (X86setcc X86_COND_LE))]>,
2133 TB; // GR8 = <= signed
2134def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002135 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002136 "setle\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002137 [(store (X86setcc X86_COND_LE), addr:$dst)]>,
2138 TB; // [mem8] = <= signed
2139def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002140 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002141 "setg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002142 [(set GR8:$dst, (X86setcc X86_COND_G))]>,
2143 TB; // GR8 = > signed
2144def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002145 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002146 "setg\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002147 [(store (X86setcc X86_COND_G), addr:$dst)]>,
2148 TB; // [mem8] = > signed
2149
2150def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002151 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "setb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 [(set GR8:$dst, (X86setcc X86_COND_B))]>,
2154 TB; // GR8 = < unsign
2155def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002156 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "setb\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 [(store (X86setcc X86_COND_B), addr:$dst)]>,
2159 TB; // [mem8] = < unsign
2160def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002161 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002162 "setae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163 [(set GR8:$dst, (X86setcc X86_COND_AE))]>,
2164 TB; // GR8 = >= unsign
2165def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002166 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002167 "setae\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168 [(store (X86setcc X86_COND_AE), addr:$dst)]>,
2169 TB; // [mem8] = >= unsign
2170def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002171 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002172 "setbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002173 [(set GR8:$dst, (X86setcc X86_COND_BE))]>,
2174 TB; // GR8 = <= unsign
2175def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002176 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002177 "setbe\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002178 [(store (X86setcc X86_COND_BE), addr:$dst)]>,
2179 TB; // [mem8] = <= unsign
2180def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002181 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002182 "seta\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002183 [(set GR8:$dst, (X86setcc X86_COND_A))]>,
2184 TB; // GR8 = > signed
2185def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002186 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002187 "seta\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002188 [(store (X86setcc X86_COND_A), addr:$dst)]>,
2189 TB; // [mem8] = > signed
2190
2191def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002192 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "sets\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002194 [(set GR8:$dst, (X86setcc X86_COND_S))]>,
2195 TB; // GR8 = <sign bit>
2196def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002197 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002198 "sets\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002199 [(store (X86setcc X86_COND_S), addr:$dst)]>,
2200 TB; // [mem8] = <sign bit>
2201def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002202 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002203 "setns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204 [(set GR8:$dst, (X86setcc X86_COND_NS))]>,
2205 TB; // GR8 = !<sign bit>
2206def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002207 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002208 "setns\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002209 [(store (X86setcc X86_COND_NS), addr:$dst)]>,
2210 TB; // [mem8] = !<sign bit>
2211def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002212 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "setp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 [(set GR8:$dst, (X86setcc X86_COND_P))]>,
2215 TB; // GR8 = parity
2216def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002217 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "setp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002219 [(store (X86setcc X86_COND_P), addr:$dst)]>,
2220 TB; // [mem8] = parity
2221def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002222 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "setnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002224 [(set GR8:$dst, (X86setcc X86_COND_NP))]>,
2225 TB; // GR8 = not parity
2226def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002227 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002228 "setnp\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002229 [(store (X86setcc X86_COND_NP), addr:$dst)]>,
2230 TB; // [mem8] = not parity
2231
2232// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002233let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002234def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002235 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002236 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002237 [(X86cmp GR8:$src1, GR8:$src2)]>;
2238def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002239 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002240 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002241 [(X86cmp GR16:$src1, GR16:$src2)]>, OpSize;
2242def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002243 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002244 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002245 [(X86cmp GR32:$src1, GR32:$src2)]>;
2246def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002247 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002248 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002249 [(X86cmp (loadi8 addr:$src1), GR8:$src2)]>;
2250def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002251 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002252 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002253 [(X86cmp (loadi16 addr:$src1), GR16:$src2)]>, OpSize;
2254def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002255 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002256 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002257 [(X86cmp (loadi32 addr:$src1), GR32:$src2)]>;
2258def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002259 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002260 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261 [(X86cmp GR8:$src1, (loadi8 addr:$src2))]>;
2262def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002263 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002264 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002265 [(X86cmp GR16:$src1, (loadi16 addr:$src2))]>, OpSize;
2266def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002267 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002268 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269 [(X86cmp GR32:$src1, (loadi32 addr:$src2))]>;
2270def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002271 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002272 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273 [(X86cmp GR8:$src1, imm:$src2)]>;
2274def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002275 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002276 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002277 [(X86cmp GR16:$src1, imm:$src2)]>, OpSize;
2278def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002279 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002280 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002281 [(X86cmp GR32:$src1, imm:$src2)]>;
2282def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002283 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002284 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002285 [(X86cmp (loadi8 addr:$src1), imm:$src2)]>;
2286def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002287 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002288 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289 [(X86cmp (loadi16 addr:$src1), imm:$src2)]>, OpSize;
2290def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002291 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002292 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002293 [(X86cmp (loadi32 addr:$src1), imm:$src2)]>;
2294def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002295 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002296 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002297 [(X86cmp GR16:$src1, i16immSExt8:$src2)]>, OpSize;
2298def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002299 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002300 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002301 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2)]>, OpSize;
2302def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002303 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002304 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002305 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2)]>;
2306def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002307 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002308 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002309 [(X86cmp GR32:$src1, i32immSExt8:$src2)]>;
Evan Cheng55687072007-09-14 21:48:26 +00002310} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002311
2312// Sign/Zero extenders
Evan Chengb783fa32007-07-19 01:14:50 +00002313def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002314 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002315 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002316def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002317 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002318 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002319def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002320 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002321 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002322def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002323 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002324 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002325def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002326 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002327 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002328def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002329 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002330 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2331
Evan Chengb783fa32007-07-19 01:14:50 +00002332def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002334 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002335def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002336 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002337 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002338def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002340 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002341def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002342 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002343 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002344def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002345 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002346 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002347def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002348 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002349 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2350
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002351let Defs = [AX], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00002352def CBW : I<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002353 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2354let Defs = [EAX], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002355def CWDE : I<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002356 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002357
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002358let Defs = [AX,DX], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002359def CWD : I<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002360 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2361let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002362def CDQ : I<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002363 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002364
2365
2366//===----------------------------------------------------------------------===//
2367// Alias Instructions
2368//===----------------------------------------------------------------------===//
2369
2370// Alias instructions that map movr0 to xor.
2371// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Cheng55687072007-09-14 21:48:26 +00002372let Defs = [EFLAGS], isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002373def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002374 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002375 [(set GR8:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002376def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002377 "xor{w}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002378 [(set GR16:$dst, 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002379def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002380 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002381 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002382}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002383
2384// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2385// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengb783fa32007-07-19 01:14:50 +00002386def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002387 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002388def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002389 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002390
Evan Chengb783fa32007-07-19 01:14:50 +00002391def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002392 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002393def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002394 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002395let isLoad = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002396def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002397 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002398def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002399 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002400}
Evan Chengb783fa32007-07-19 01:14:50 +00002401def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002402 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002403def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002404 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002405
2406//===----------------------------------------------------------------------===//
2407// Thread Local Storage Instructions
2408//
2409
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002410let Uses = [EBX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002411def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
Dan Gohman91888f02007-07-31 20:11:57 +00002412 "leal\t${sym:mem}(,%ebx,1), $dst",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002413 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002414
2415let AddedComplexity = 10 in
Evan Chengb783fa32007-07-19 01:14:50 +00002416def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002417 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002418 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2419
2420let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002421def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002422 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002423 [(set GR32:$dst,
2424 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2425
Evan Chengb783fa32007-07-19 01:14:50 +00002426def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002427 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002428 [(set GR32:$dst, X86TLStp)]>;
2429
2430//===----------------------------------------------------------------------===//
2431// DWARF Pseudo Instructions
2432//
2433
Evan Chengb783fa32007-07-19 01:14:50 +00002434def DWARF_LOC : I<0, Pseudo, (outs),
2435 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohmanf8133d72007-07-26 15:24:15 +00002436 "; .loc ${file:debug}, ${line:debug}, ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002437 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2438 (i32 imm:$file))]>;
2439
2440//===----------------------------------------------------------------------===//
2441// EH Pseudo Instructions
2442//
2443let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002444 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002445def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002446 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002447 [(X86ehret GR32:$addr)]>;
2448
2449}
2450
2451//===----------------------------------------------------------------------===//
2452// Non-Instruction Patterns
2453//===----------------------------------------------------------------------===//
2454
2455// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2456def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2457def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2458def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2459def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2460def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2461
2462def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2463 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2464def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2465 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2466def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2467 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2468def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2469 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2470
2471def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2472 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2473def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2474 (MOV32mi addr:$dst, texternalsym:$src)>;
2475
2476// Calls
2477def : Pat<(X86tailcall GR32:$dst),
2478 (CALL32r GR32:$dst)>;
2479
2480def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2481 (CALLpcrel32 tglobaladdr:$dst)>;
2482def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2483 (CALLpcrel32 texternalsym:$dst)>;
2484
2485def : Pat<(X86call (i32 tglobaladdr:$dst)),
2486 (CALLpcrel32 tglobaladdr:$dst)>;
2487def : Pat<(X86call (i32 texternalsym:$dst)),
2488 (CALLpcrel32 texternalsym:$dst)>;
2489
2490// X86 specific add which produces a flag.
2491def : Pat<(addc GR32:$src1, GR32:$src2),
2492 (ADD32rr GR32:$src1, GR32:$src2)>;
2493def : Pat<(addc GR32:$src1, (load addr:$src2)),
2494 (ADD32rm GR32:$src1, addr:$src2)>;
2495def : Pat<(addc GR32:$src1, imm:$src2),
2496 (ADD32ri GR32:$src1, imm:$src2)>;
2497def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2498 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2499
2500def : Pat<(subc GR32:$src1, GR32:$src2),
2501 (SUB32rr GR32:$src1, GR32:$src2)>;
2502def : Pat<(subc GR32:$src1, (load addr:$src2)),
2503 (SUB32rm GR32:$src1, addr:$src2)>;
2504def : Pat<(subc GR32:$src1, imm:$src2),
2505 (SUB32ri GR32:$src1, imm:$src2)>;
2506def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2507 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2508
2509def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2510 (MOV8mi addr:$dst, imm:$src)>;
2511def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2512 (MOV8mr addr:$dst, GR8:$src)>;
2513
2514// Comparisons.
2515
2516// TEST R,R is smaller than CMP R,0
2517def : Pat<(X86cmp GR8:$src1, 0),
2518 (TEST8rr GR8:$src1, GR8:$src1)>;
2519def : Pat<(X86cmp GR16:$src1, 0),
2520 (TEST16rr GR16:$src1, GR16:$src1)>;
2521def : Pat<(X86cmp GR32:$src1, 0),
2522 (TEST32rr GR32:$src1, GR32:$src1)>;
2523
2524// {s|z}extload bool -> {s|z}extload byte
2525def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2526def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2527def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2528def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2529def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2530
2531// extload bool -> extload byte
2532def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2533def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2534def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2535def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2536def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2537def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2538
2539// anyext -> zext
2540def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2541def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2542def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2543def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2544def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2545def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2546
2547//===----------------------------------------------------------------------===//
2548// Some peepholes
2549//===----------------------------------------------------------------------===//
2550
2551// (shl x, 1) ==> (add x, x)
2552def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2553def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2554def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2555
2556// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2557def : Pat<(or (srl GR32:$src1, CL:$amt),
2558 (shl GR32:$src2, (sub 32, CL:$amt))),
2559 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2560
2561def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2562 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2563 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2564
2565// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2566def : Pat<(or (shl GR32:$src1, CL:$amt),
2567 (srl GR32:$src2, (sub 32, CL:$amt))),
2568 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2569
2570def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2571 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2572 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2573
2574// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2575def : Pat<(or (srl GR16:$src1, CL:$amt),
2576 (shl GR16:$src2, (sub 16, CL:$amt))),
2577 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2578
2579def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2580 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2581 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2582
2583// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2584def : Pat<(or (shl GR16:$src1, CL:$amt),
2585 (srl GR16:$src2, (sub 16, CL:$amt))),
2586 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2587
2588def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2589 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2590 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2591
2592
2593//===----------------------------------------------------------------------===//
2594// Floating Point Stack Support
2595//===----------------------------------------------------------------------===//
2596
2597include "X86InstrFPStack.td"
2598
2599//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00002600// X86-64 Support
2601//===----------------------------------------------------------------------===//
2602
2603include "X86InstrX86-64.td"
2604
2605//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002606// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2607//===----------------------------------------------------------------------===//
2608
2609include "X86InstrMMX.td"
2610
2611//===----------------------------------------------------------------------===//
2612// XMM Floating point support (requires SSE / SSE2)
2613//===----------------------------------------------------------------------===//
2614
2615include "X86InstrSSE.td"