blob: fb9fefa2f1909b5b8e866b19564f5d0697bb3129 [file] [log] [blame]
Arnold Schwaighofer373e8652007-10-12 21:30:57 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set --*- tablegen -*-===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002//
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
Evan Cheng621216e2007-09-29 00:00:36 +000026def SDTX86Cmov : SDTypeProfile<1, 4,
Evan Cheng950aac02007-09-25 01:57:46 +000027 [SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>,
28 SDTCisVT<3, i8>, SDTCisVT<4, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029
Evan Cheng621216e2007-09-29 00:00:36 +000030def SDTX86BrCond : SDTypeProfile<0, 3,
Evan Cheng950aac02007-09-25 01:57:46 +000031 [SDTCisVT<0, OtherVT>,
32 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000033
Evan Cheng621216e2007-09-29 00:00:36 +000034def SDTX86SetCC : SDTypeProfile<1, 2,
Evan Cheng950aac02007-09-25 01:57:46 +000035 [SDTCisVT<0, i8>,
36 SDTCisVT<1, i8>, SDTCisVT<2, i32>]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037
38def SDTX86Ret : SDTypeProfile<0, 1, [SDTCisVT<0, i16>]>;
39
40def SDT_X86CallSeqStart : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
41def SDT_X86CallSeqEnd : SDTypeProfile<0, 2, [ SDTCisVT<0, i32>,
42 SDTCisVT<1, i32> ]>;
43
44def SDT_X86Call : SDTypeProfile<0, 1, [SDTCisVT<0, iPTR>]>;
45
46def SDTX86RepStr : SDTypeProfile<0, 1, [SDTCisVT<0, OtherVT>]>;
47
48def SDTX86RdTsc : SDTypeProfile<0, 0, []>;
49
50def SDTX86Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>, SDTCisPtrTy<0>]>;
51
52def SDT_X86TLSADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
53
54def SDT_X86TLSTP : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
55
56def SDT_X86EHRET : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
57
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000058def SDT_X86TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
59
Dan Gohmanf17a25c2007-07-18 16:29:46 +000060def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
61def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
62
Evan Cheng621216e2007-09-29 00:00:36 +000063def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064
Evan Cheng621216e2007-09-29 00:00:36 +000065def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000066def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000067 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000068def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000069
70def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
71 [SDNPHasChain, SDNPOptInFlag]>;
72
73def X86callseq_start :
74 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
75 [SDNPHasChain, SDNPOutFlag]>;
76def X86callseq_end :
77 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +000078 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000079
80def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
81 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
82
83def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
84 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
85
86def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
87 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
88def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
89 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
90
91def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
92 [SDNPHasChain, SDNPOutFlag]>;
93
94def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
95def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
96
97def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
98 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
99def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
100
101def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
102 [SDNPHasChain]>;
103
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000104def X86tcret : SDNode<"X86ISD::TC_RETURN", SDT_X86TCRET,
105 [SDNPHasChain, SDNPOptInFlag]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000106
107//===----------------------------------------------------------------------===//
108// X86 Operand Definitions.
109//
110
111// *mem - Operand definitions for the funky X86 addressing mode operands.
112//
113class X86MemOperand<string printMethod> : Operand<iPTR> {
114 let PrintMethod = printMethod;
115 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
116}
117
118def i8mem : X86MemOperand<"printi8mem">;
119def i16mem : X86MemOperand<"printi16mem">;
120def i32mem : X86MemOperand<"printi32mem">;
121def i64mem : X86MemOperand<"printi64mem">;
122def i128mem : X86MemOperand<"printi128mem">;
123def f32mem : X86MemOperand<"printf32mem">;
124def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000125def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126def f128mem : X86MemOperand<"printf128mem">;
127
128def lea32mem : Operand<i32> {
129 let PrintMethod = "printi32mem";
130 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
131}
132
133def SSECC : Operand<i8> {
134 let PrintMethod = "printSSECC";
135}
136
137def piclabel: Operand<i32> {
138 let PrintMethod = "printPICLabel";
139}
140
141// A couple of more descriptive operand definitions.
142// 16-bits but only 8 bits are significant.
143def i16i8imm : Operand<i16>;
144// 32-bits but only 8 bits are significant.
145def i32i8imm : Operand<i32>;
146
147// Branch targets have OtherVT type.
148def brtarget : Operand<OtherVT>;
149
150//===----------------------------------------------------------------------===//
151// X86 Complex Pattern Definitions.
152//
153
154// Define X86 specific addressing mode.
155def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
156def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
157 [add, mul, shl, or, frameindex], []>;
158
159//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000160// X86 Instruction Predicate Definitions.
161def HasMMX : Predicate<"Subtarget->hasMMX()">;
162def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
163def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
164def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
165def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000166def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
167def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000168def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
169def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Evan Cheng09e13792007-08-01 23:45:51 +0000170def HasLow4G : Predicate<"Subtarget->hasLow4GUserSpaceAddress()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000171def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
172def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
173def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
174
175//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000176// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177//
178
Evan Cheng86ab7d32007-07-31 08:04:03 +0000179include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000180
181//===----------------------------------------------------------------------===//
182// Pattern fragments...
183//
184
185// X86 specific condition code. These correspond to CondCode in
186// X86InstrInfo.h. They must be kept in synch.
187def X86_COND_A : PatLeaf<(i8 0)>;
188def X86_COND_AE : PatLeaf<(i8 1)>;
189def X86_COND_B : PatLeaf<(i8 2)>;
190def X86_COND_BE : PatLeaf<(i8 3)>;
191def X86_COND_E : PatLeaf<(i8 4)>;
192def X86_COND_G : PatLeaf<(i8 5)>;
193def X86_COND_GE : PatLeaf<(i8 6)>;
194def X86_COND_L : PatLeaf<(i8 7)>;
195def X86_COND_LE : PatLeaf<(i8 8)>;
196def X86_COND_NE : PatLeaf<(i8 9)>;
197def X86_COND_NO : PatLeaf<(i8 10)>;
198def X86_COND_NP : PatLeaf<(i8 11)>;
199def X86_COND_NS : PatLeaf<(i8 12)>;
200def X86_COND_O : PatLeaf<(i8 13)>;
201def X86_COND_P : PatLeaf<(i8 14)>;
202def X86_COND_S : PatLeaf<(i8 15)>;
203
204def i16immSExt8 : PatLeaf<(i16 imm), [{
205 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
206 // sign extended field.
207 return (int16_t)N->getValue() == (int8_t)N->getValue();
208}]>;
209
210def i32immSExt8 : PatLeaf<(i32 imm), [{
211 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
212 // sign extended field.
213 return (int32_t)N->getValue() == (int8_t)N->getValue();
214}]>;
215
216// Helper fragments for loads.
217def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
218def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
219def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
220def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
221
222def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
223def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000224def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000225
226def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
227def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
228def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
229def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
230def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
231
232def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
233def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
234def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
235def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
236def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
237def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
238
239def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
240def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
241def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
242def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
243def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
244def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
245
246//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000247// Instruction list...
248//
249
250// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
251// a stack adjustment and the codegen must know that they may modify the stack
252// pointer before prolog-epilog rewriting occurs.
Evan Chenge4f1f572007-09-28 01:35:02 +0000253// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become sub / add
Evan Cheng037364a2007-09-28 01:19:48 +0000254// which can clobber EFLAGS.
255let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Bill Wendling22f8deb2007-11-13 00:44:25 +0000256def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt),
257 "#ADJCALLSTACKDOWN",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000258 [(X86callseq_start imm:$amt)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000259def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000260 "#ADJCALLSTACKUP",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000261 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
262}
Evan Chengb783fa32007-07-19 01:14:50 +0000263def IMPLICIT_USE : I<0, Pseudo, (outs), (ins variable_ops),
264 "#IMPLICIT_USE", []>;
265def IMPLICIT_DEF : I<0, Pseudo, (outs variable_ops), (ins),
266 "#IMPLICIT_DEF", []>;
267def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000268 "#IMPLICIT_DEF $dst",
269 [(set GR8:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000270def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000271 "#IMPLICIT_DEF $dst",
272 [(set GR16:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000273def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274 "#IMPLICIT_DEF $dst",
275 [(set GR32:$dst, (undef))]>;
276
277// Nop
Evan Chengb783fa32007-07-19 01:14:50 +0000278def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000279
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000280
281//===----------------------------------------------------------------------===//
282// Control Flow Instructions...
283//
284
285// Return instructions.
286let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +0000287 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000288 def RET : I<0xC3, RawFrm, (outs), (ins), "ret", [(X86retflag 0)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000289 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt), "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000290 [(X86retflag imm:$amt)]>;
291}
292
293// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000294let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000295 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
296 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000297
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000298let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000299 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000300
Owen Andersonf8053082007-11-12 07:39:39 +0000301// Indirect branches
302let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000303 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000304 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000305 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000306 [(brind (loadi32 addr:$dst))]>;
307}
308
309// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000310let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000311def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000312 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000313def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000314 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000315def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000316 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000317def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000318 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000319def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000320 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000321def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000322 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000323
Dan Gohman91888f02007-07-31 20:11:57 +0000324def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000325 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000326def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000327 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000328def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000329 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000330def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000331 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000332
Dan Gohman91888f02007-07-31 20:11:57 +0000333def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000334 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000335def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000336 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000337def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000338 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000339def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000340 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000341def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000342 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000343def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000344 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000345} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346
347//===----------------------------------------------------------------------===//
348// Call Instructions...
349//
Evan Cheng37e7c752007-07-21 00:34:19 +0000350let isCall = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000351 // All calls clobber the non-callee saved registers...
352 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
353 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng950aac02007-09-25 01:57:46 +0000354 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000355 def CALLpcrel32 : I<0xE8, RawFrm, (outs), (ins i32imm:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000356 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000357 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000358 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000359 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000360 "call\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361 }
362
363// Tail call stuff.
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000364
365def TAILCALL : I<0, Pseudo, (outs), (ins ),
366 "#TAILCALL",
367 []>;
368
Evan Cheng37e7c752007-07-21 00:34:19 +0000369let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000370def TCRETURNdi : I<0, Pseudo, (outs), (ins i32imm:$dst, i32imm:$offset),
371 "#TC_RETURN $dst $offset",
372 []>;
373
374let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
375def TCRETURNri : I<0, Pseudo, (outs), (ins GR32:$dst, i32imm:$offset),
376 "#TC_RETURN $dst $offset",
377 []>;
378
379let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
380 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAILCALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000381 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000382let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000383 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst # TAILCALL",
384 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000385let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000386 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +0000387 "jmp\t{*}$dst # TAILCALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000388
389//===----------------------------------------------------------------------===//
390// Miscellaneous Instructions...
391//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000392let Defs = [EBP, ESP], Uses = [EBP, ESP] in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000393def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000394 (outs), (ins), "leave", []>;
395
396let Defs = [ESP], Uses = [ESP] in {
Evan Chengd8434332007-09-26 01:29:06 +0000397def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000398
Evan Chengd8434332007-09-26 01:29:06 +0000399def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000400}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000401
Evan Chengd8434332007-09-26 01:29:06 +0000402let Defs = [ESP, EFLAGS], Uses = [ESP] in
Evan Chengf1341312007-09-26 21:28:00 +0000403def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000404let Defs = [ESP], Uses = [ESP, EFLAGS] in
Evan Chengf1341312007-09-26 21:28:00 +0000405def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000406
Evan Chengb783fa32007-07-19 01:14:50 +0000407def MovePCtoStack : I<0, Pseudo, (outs), (ins piclabel:$label),
Dan Gohman91888f02007-07-31 20:11:57 +0000408 "call\t$label", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000409
410let isTwoAddress = 1 in // GR32 = bswap GR32
411 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000412 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000413 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000414 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
415
Evan Chengb783fa32007-07-19 01:14:50 +0000416// FIXME: Model xchg* as two address instructions?
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000417def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
Evan Chengb783fa32007-07-19 01:14:50 +0000418 (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000419 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000420def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000421 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000422 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000423def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000424 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000425 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000426
427def XCHG8mr : I<0x86, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000428 (outs), (ins i8mem:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000429 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000430def XCHG16mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000431 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000432 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000433def XCHG32mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000434 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000435 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000436def XCHG8rm : I<0x86, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000437 (outs), (ins GR8:$src1, i8mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000438 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000439def XCHG16rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000440 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000441 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442def XCHG32rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000443 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000444 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000445
446def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000447 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000448 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000449def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000450 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000451 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
453
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000454let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000455def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000456 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000457def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000458 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000459def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000460 [(X86rep_movs i32)]>, REP;
461}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000462
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000463let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000464def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000465 [(X86rep_stos i8)]>, REP;
466let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000467def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000468 [(X86rep_stos i16)]>, REP, OpSize;
469let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000470def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000471 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000472
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000473let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000474def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000475 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000476
477//===----------------------------------------------------------------------===//
478// Input/Output Instructions...
479//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000480let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000481def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000482 "in{b}\t{%dx, %al|%AL, %DX}", []>;
483let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000484def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000485 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
486let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000487def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000488 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000489
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000490let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000491def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000492 "in{b}\t{$port, %al|%AL, $port}", []>;
493let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000494def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000495 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
496let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000497def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000498 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000499
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000500let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000501def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000502 "out{b}\t{%al, %dx|%DX, %AL}", []>;
503let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000504def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000505 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
506let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000507def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000508 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000510let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000511def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000512 "out{b}\t{%al, $port|$port, %AL}", []>;
513let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000514def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000515 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
516let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000517def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000518 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000519
520//===----------------------------------------------------------------------===//
521// Move Instructions...
522//
Evan Chengb783fa32007-07-19 01:14:50 +0000523def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000524 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000525def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000526 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000527def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000528 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000529let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000530def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000531 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000532 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000533def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000534 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000535 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000536def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000537 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000538 [(set GR32:$dst, imm:$src)]>;
539}
Evan Chengb783fa32007-07-19 01:14:50 +0000540def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000541 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000542 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000543def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000544 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000545 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000546def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000547 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000548 [(store (i32 imm:$src), addr:$dst)]>;
549
Evan Cheng4e84e452007-08-30 05:49:43 +0000550let isLoad = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000551def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000552 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000553 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000554def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000555 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000556 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000557def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000558 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000560}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000561
Evan Chengb783fa32007-07-19 01:14:50 +0000562def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000563 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000564 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000565def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000566 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000567 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000568def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000569 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000570 [(store GR32:$src, addr:$dst)]>;
571
572//===----------------------------------------------------------------------===//
573// Fixed-Register Multiplication and Division Instructions...
574//
575
576// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000577let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000578def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000579 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
580 // This probably ought to be moved to a def : Pat<> if the
581 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000582 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000583let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000584def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000585 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000586let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000587def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
588 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000589let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000590def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000591 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000592 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
593 // This probably ought to be moved to a def : Pat<> if the
594 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000595 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000596let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000597def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000598 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng55687072007-09-14 21:48:26 +0000599let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000600def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000601 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000602
Evan Cheng55687072007-09-14 21:48:26 +0000603let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000604def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
605 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000606let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000607def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000608 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000609let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000610def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
611 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000612let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000613def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000614 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000615let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000616def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000617 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
618let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000619def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000620 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621
622// unsigned division/remainder
Evan Cheng55687072007-09-14 21:48:26 +0000623let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000624def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000625 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000626let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000627def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000628 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000629let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000630def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000631 "div{l}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000632let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000633def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000634 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000635let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000636def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000637 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000638let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000639def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000640 "div{l}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641
642// Signed division/remainder.
Evan Cheng55687072007-09-14 21:48:26 +0000643let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000644def IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000645 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000646let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000647def IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000648 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000649let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000650def IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000651 "idiv{l}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000652let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000653def IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000654 "idiv{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000655let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000656def IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000657 "idiv{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000658let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000659def IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000660 "idiv{l}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661
662
663//===----------------------------------------------------------------------===//
664// Two address Instructions...
665//
666let isTwoAddress = 1 in {
667
668// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000669let Uses = [EFLAGS] in {
Evan Cheng926658c2007-10-05 23:13:21 +0000670let isCommutable = 1 in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000671def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000672 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000673 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000674 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000675 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000676 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000677def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000678 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000679 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000680 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000681 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000682 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000683
684def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000685 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000686 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000687 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000688 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000689 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000691 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000692 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000693 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000694 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000695 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000697 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000698 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000699 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000700 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000701 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000702def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000703 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000704 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000706 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000707 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000708def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000709 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000710 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000712 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000713 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000714def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000715 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000716 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000718 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000719 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000720def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000721 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000722 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000724 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000725 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000726def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000727 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000728 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000729 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000730 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000731 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000732def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000733 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000734 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000735 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000736 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000737 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000738def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000739 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000740 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000741 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000742 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000743 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000744def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000745 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000746 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000747 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000748 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000749 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000750def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000751 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000752 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000754 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000755 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000756def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000757 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000758 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000760 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000761 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000762def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000763 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000764 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000765 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000766 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000768def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000769 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000770 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000772 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000774def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000775 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000776 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000777 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000778 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000779 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000781 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000782 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000783 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000784 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000785 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000787 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000788 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000789 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000790 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000791 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, 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 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000795 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000796 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000797 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000799 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000800 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000801 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000802 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000804def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000805 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000806 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000807 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000808 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000810def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000811 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000812 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000813 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000814 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000816def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000817 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000818 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000819 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000820 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000822def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000823 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000824 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000825 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000826 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000827 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000829 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000830 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000831 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000832 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000833 TB, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000835 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000836 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000837 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000838 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000839 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000840} // isCommutable = 1
841
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000843 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000844 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000845 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000846 X86_COND_NP, EFLAGS))]>,
847 TB;
Evan Cheng926658c2007-10-05 23:13:21 +0000848
849def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
850 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
851 "cmovb\t{$src2, $dst|$dst, $src2}",
852 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
853 X86_COND_B, EFLAGS))]>,
854 TB, OpSize;
855def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
856 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
857 "cmovb\t{$src2, $dst|$dst, $src2}",
858 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
859 X86_COND_B, EFLAGS))]>,
860 TB;
861def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
862 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
863 "cmovae\t{$src2, $dst|$dst, $src2}",
864 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
865 X86_COND_AE, EFLAGS))]>,
866 TB, OpSize;
867def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
868 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
869 "cmovae\t{$src2, $dst|$dst, $src2}",
870 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
871 X86_COND_AE, EFLAGS))]>,
872 TB;
873def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
874 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
875 "cmove\t{$src2, $dst|$dst, $src2}",
876 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
877 X86_COND_E, EFLAGS))]>,
878 TB, OpSize;
879def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
880 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
881 "cmove\t{$src2, $dst|$dst, $src2}",
882 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
883 X86_COND_E, EFLAGS))]>,
884 TB;
885def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
886 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
887 "cmovne\t{$src2, $dst|$dst, $src2}",
888 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
889 X86_COND_NE, EFLAGS))]>,
890 TB, OpSize;
891def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
892 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
893 "cmovne\t{$src2, $dst|$dst, $src2}",
894 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
895 X86_COND_NE, EFLAGS))]>,
896 TB;
897def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
898 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
899 "cmovbe\t{$src2, $dst|$dst, $src2}",
900 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
901 X86_COND_BE, EFLAGS))]>,
902 TB, OpSize;
903def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
904 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
905 "cmovbe\t{$src2, $dst|$dst, $src2}",
906 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
907 X86_COND_BE, EFLAGS))]>,
908 TB;
909def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
910 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
911 "cmova\t{$src2, $dst|$dst, $src2}",
912 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
913 X86_COND_A, EFLAGS))]>,
914 TB, OpSize;
915def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
916 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
917 "cmova\t{$src2, $dst|$dst, $src2}",
918 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
919 X86_COND_A, EFLAGS))]>,
920 TB;
921def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
922 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
923 "cmovl\t{$src2, $dst|$dst, $src2}",
924 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
925 X86_COND_L, EFLAGS))]>,
926 TB, OpSize;
927def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
928 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
929 "cmovl\t{$src2, $dst|$dst, $src2}",
930 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
931 X86_COND_L, EFLAGS))]>,
932 TB;
933def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
934 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
935 "cmovge\t{$src2, $dst|$dst, $src2}",
936 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
937 X86_COND_GE, EFLAGS))]>,
938 TB, OpSize;
939def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
940 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
941 "cmovge\t{$src2, $dst|$dst, $src2}",
942 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
943 X86_COND_GE, EFLAGS))]>,
944 TB;
945def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
946 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
947 "cmovle\t{$src2, $dst|$dst, $src2}",
948 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
949 X86_COND_LE, EFLAGS))]>,
950 TB, OpSize;
951def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
952 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
953 "cmovle\t{$src2, $dst|$dst, $src2}",
954 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
955 X86_COND_LE, EFLAGS))]>,
956 TB;
957def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
958 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
959 "cmovg\t{$src2, $dst|$dst, $src2}",
960 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
961 X86_COND_G, EFLAGS))]>,
962 TB, OpSize;
963def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
964 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
965 "cmovg\t{$src2, $dst|$dst, $src2}",
966 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
967 X86_COND_G, EFLAGS))]>,
968 TB;
969def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
970 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
971 "cmovs\t{$src2, $dst|$dst, $src2}",
972 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
973 X86_COND_S, EFLAGS))]>,
974 TB, OpSize;
975def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
976 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
977 "cmovs\t{$src2, $dst|$dst, $src2}",
978 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
979 X86_COND_S, EFLAGS))]>,
980 TB;
981def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
982 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
983 "cmovns\t{$src2, $dst|$dst, $src2}",
984 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
985 X86_COND_NS, EFLAGS))]>,
986 TB, OpSize;
987def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
988 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
989 "cmovns\t{$src2, $dst|$dst, $src2}",
990 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
991 X86_COND_NS, EFLAGS))]>,
992 TB;
993def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
994 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
995 "cmovp\t{$src2, $dst|$dst, $src2}",
996 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
997 X86_COND_P, EFLAGS))]>,
998 TB, OpSize;
999def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
1000 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
1001 "cmovp\t{$src2, $dst|$dst, $src2}",
1002 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
1003 X86_COND_P, EFLAGS))]>,
1004 TB;
1005def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
1006 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
1007 "cmovnp\t{$src2, $dst|$dst, $src2}",
1008 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
1009 X86_COND_NP, EFLAGS))]>,
1010 TB, OpSize;
Evan Cheng950aac02007-09-25 01:57:46 +00001011} // Uses = [EFLAGS]
1012
1013
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001014// unary instructions
1015let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001016let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001017def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001018 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001019def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001020 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001021def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001022 [(set GR32:$dst, (ineg GR32:$src))]>;
1023let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001024 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001026 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001027 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001028 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001029 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1030
1031}
Evan Cheng55687072007-09-14 21:48:26 +00001032} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001033
Dan Gohman91888f02007-07-31 20:11:57 +00001034def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001035 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001036def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001037 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001038def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001039 [(set GR32:$dst, (not GR32:$src))]>;
1040let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001041 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001043 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001044 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001045 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001046 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1047}
1048} // CodeSize
1049
1050// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001051let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001053def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054 [(set GR8:$dst, (add GR8:$src, 1))]>;
1055let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001056def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001057 [(set GR16:$dst, (add GR16:$src, 1))]>,
1058 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001059def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001060 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1061}
1062let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001063 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001065 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001066 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>,
1067 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001068 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001069 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>,
1070 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001071}
1072
1073let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001074def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001075 [(set GR8:$dst, (add GR8:$src, -1))]>;
1076let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001077def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001078 [(set GR16:$dst, (add GR16:$src, -1))]>,
1079 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001080def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001081 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1082}
1083
1084let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001085 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001087 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001088 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>,
1089 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001090 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Evan Cheng4a7e72f2007-10-19 21:23:22 +00001091 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>,
1092 Requires<[In32BitMode]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001093}
Evan Cheng55687072007-09-14 21:48:26 +00001094} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001095
1096// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001097let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001098let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1099def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001100 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001101 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001102 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1103def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001104 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001105 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001106 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1107def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001108 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001109 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001110 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1111}
1112
1113def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001114 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001115 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001116 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1117def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001118 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001119 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001120 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1121def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001122 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001123 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001124 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1125
1126def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001127 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001128 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001129 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1130def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001131 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001132 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001133 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1134def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001135 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001136 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001137 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1138def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001139 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001140 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001141 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1142 OpSize;
1143def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001144 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001145 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001146 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1147
1148let isTwoAddress = 0 in {
1149 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001150 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001151 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001152 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1153 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001154 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001155 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001156 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1157 OpSize;
1158 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001159 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001160 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001161 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1162 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001163 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001164 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001165 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1166 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001167 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001168 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001169 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1170 OpSize;
1171 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001172 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001173 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1175 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001176 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001177 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001178 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1179 OpSize;
1180 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001181 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001182 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001183 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1184}
1185
1186
1187let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001188def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001189 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001190 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001191def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001192 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001193 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001194def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001195 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001196 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1197}
Evan Chengb783fa32007-07-19 01:14:50 +00001198def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001199 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001201def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001202 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001203 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001204def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001205 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001206 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1207
Evan Chengb783fa32007-07-19 01:14:50 +00001208def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001209 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001210 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001211def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001212 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001213 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001214def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001215 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001216 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1217
Evan Chengb783fa32007-07-19 01:14:50 +00001218def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001219 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001220 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001221def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001222 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1224let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001225 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001226 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001227 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001228 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001229 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001230 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001231 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001232 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001233 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001234 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001235 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001236 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001237 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001238 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001239 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1240 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001241 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001242 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001243 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001244 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001245 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1247 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001248 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001249 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001250 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1251}
1252
1253
1254let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1255def XOR8rr : I<0x30, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001256 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001257 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001258 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1259def XOR16rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001260 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001261 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001262 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1263def XOR32rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001264 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001265 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001266 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1267}
1268
1269def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001270 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001271 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001272 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1273def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001274 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001275 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001276 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1277def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001278 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001279 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001280 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1281
1282def XOR8ri : Ii8<0x80, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001283 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001284 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001285 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1286def XOR16ri : Ii16<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001287 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001288 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001289 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1290def XOR32ri : Ii32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001291 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001292 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001293 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1294def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001295 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001296 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001297 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1298 OpSize;
1299def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001300 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001301 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001302 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1303let isTwoAddress = 0 in {
1304 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001305 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001306 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001307 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1308 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001309 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001310 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001311 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1312 OpSize;
1313 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001314 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001315 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001316 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1317 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001318 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001319 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001320 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1321 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001322 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001323 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001324 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1325 OpSize;
1326 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001327 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001328 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001329 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1330 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001331 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001332 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001333 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1334 OpSize;
1335 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001336 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001337 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001338 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1339}
Evan Cheng55687072007-09-14 21:48:26 +00001340} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001341
1342// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001343let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001344let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001345def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001346 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001347 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001348def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001349 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001350 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001351def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001352 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001353 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1354}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001355
Evan Chengb783fa32007-07-19 01:14:50 +00001356def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001357 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001358 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1359let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001360def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001361 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001362 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001363def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001364 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001365 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1366}
1367
1368// Shift left by one. Not used because (add x, x) is slightly cheaper.
Evan Chengb783fa32007-07-19 01:14:50 +00001369def SHL8r1 : I<0xD0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001370 "shl{b}\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001371def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001372 "shl{w}\t$dst", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001373def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001374 "shl{l}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001375
1376let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001377 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001378 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001379 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001380 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001381 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001382 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001383 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001384 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001385 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001386 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1387 }
Evan Chengb783fa32007-07-19 01:14:50 +00001388 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001389 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001390 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001391 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001392 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1394 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001395 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001396 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001397 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1398
1399 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001400 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001401 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001402 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001403 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001404 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001405 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1406 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001407 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001408 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001409 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1410}
1411
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001412let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001413def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001414 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001415 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001416def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001417 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001418 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001419def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001420 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001421 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1422}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001423
Evan Chengb783fa32007-07-19 01:14:50 +00001424def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001425 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001426 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001427def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001428 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001429 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001430def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001431 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001432 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1433
1434// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001435def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001436 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001437 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001438def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001440 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001441def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001442 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001443 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1444
1445let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001446 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001447 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001448 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001449 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001450 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001451 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001452 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001453 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001454 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001455 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001456 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1457 }
Evan Chengb783fa32007-07-19 01:14:50 +00001458 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001459 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001460 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001461 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001462 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001463 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1464 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001465 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001466 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001467 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1468
1469 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001470 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001471 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001472 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001473 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001474 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001475 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001476 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001477 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001478 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1479}
1480
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001481let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001482def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001483 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001484 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001485def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001486 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001487 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001488def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001489 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001490 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1491}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001492
Evan Chengb783fa32007-07-19 01:14:50 +00001493def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001494 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001495 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001496def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001497 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001498 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1499 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001500def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001501 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001502 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1503
1504// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001505def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001506 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001507 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001508def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001509 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001510 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001511def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001512 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001513 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1514
1515let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001516 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001517 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001518 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001519 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001520 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001521 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001522 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001523 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001524 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001525 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1526 }
Evan Chengb783fa32007-07-19 01:14:50 +00001527 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001528 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001529 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001530 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001531 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001532 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1533 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001534 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001535 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001536 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1537
1538 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001539 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001540 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001541 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001542 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001543 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001544 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1545 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001546 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001547 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1549}
1550
1551// Rotate instructions
1552// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001553let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001554def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001555 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001556 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001557def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001558 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001559 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001560def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001561 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001562 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1563}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001564
Evan Chengb783fa32007-07-19 01:14:50 +00001565def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001566 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001567 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001568def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001569 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001570 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001571def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001572 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001573 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1574
1575// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001576def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001577 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001578 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001579def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001580 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001581 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001582def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001583 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001584 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1585
1586let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001587 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001588 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001589 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001590 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001591 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001592 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001593 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001594 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001595 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001596 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1597 }
Evan Chengb783fa32007-07-19 01:14:50 +00001598 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001599 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001600 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001601 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1604 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001605 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001606 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001607 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1608
1609 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001610 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001611 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001612 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001613 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001614 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001615 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1616 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001617 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001618 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001619 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1620}
1621
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001622let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001623def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001624 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001625 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001626def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001627 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001628 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001629def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001630 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001631 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1632}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001633
Evan Chengb783fa32007-07-19 01:14:50 +00001634def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001635 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001636 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001637def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001638 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001639 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001640def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001641 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001642 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1643
1644// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001645def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001646 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001647 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001648def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001649 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001650 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001651def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001652 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1654
1655let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001656 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001657 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001658 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001659 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001660 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001661 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001662 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001663 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001665 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1666 }
Evan Chengb783fa32007-07-19 01:14:50 +00001667 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001668 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001669 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001670 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1673 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001674 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001675 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001676 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1677
1678 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001679 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001681 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001682 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001684 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1685 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001686 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001687 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001688 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1689}
1690
1691
1692
1693// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001694let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001695def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001696 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001697 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001698def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001699 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001700 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001701def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001702 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001703 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001704 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001705def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001706 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001707 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001708 TB, OpSize;
1709}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001710
1711let isCommutable = 1 in { // These instructions commute to each other.
1712def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001713 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001714 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001715 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1716 (i8 imm:$src3)))]>,
1717 TB;
1718def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001719 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001720 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001721 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1722 (i8 imm:$src3)))]>,
1723 TB;
1724def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001725 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001726 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001727 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1728 (i8 imm:$src3)))]>,
1729 TB, OpSize;
1730def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001731 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001732 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1734 (i8 imm:$src3)))]>,
1735 TB, OpSize;
1736}
1737
1738let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001739 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001740 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001741 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001743 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001744 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001745 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001746 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001747 addr:$dst)]>, TB;
1748 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001749 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001750 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001751 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001752 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1753 (i8 imm:$src3)), addr:$dst)]>,
1754 TB;
1755 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001756 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001757 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001758 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1759 (i8 imm:$src3)), addr:$dst)]>,
1760 TB;
1761
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001762 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001763 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001765 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001766 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001767 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001768 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001769 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001770 addr:$dst)]>, TB, OpSize;
1771 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001772 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001773 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001774 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001775 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1776 (i8 imm:$src3)), addr:$dst)]>,
1777 TB, OpSize;
1778 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001779 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001780 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001781 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1782 (i8 imm:$src3)), addr:$dst)]>,
1783 TB, OpSize;
1784}
Evan Cheng55687072007-09-14 21:48:26 +00001785} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001786
1787
1788// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001789let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001790let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001791def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1792 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001793 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001794 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1795let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001796def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1797 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001798 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001799 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001800def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1801 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001802 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001803 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1804} // end isConvertibleToThreeAddress
1805} // end isCommutable
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001806def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1807 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001808 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001809 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001810def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1811 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001812 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001813 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1814def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1815 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001816 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001817 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1818
Evan Chengb783fa32007-07-19 01:14:50 +00001819def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001820 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001821 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1822
1823let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001824def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1825 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001826 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001827 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001828def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1829 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001830 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001831 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001832def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1833 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001834 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001835 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1836def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1837 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001838 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001839 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001840}
1841
1842let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001843 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001844 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001845 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001846 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001847 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001848 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001849 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001850 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001851 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001852 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001853 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001854 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001855 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001856 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001857 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001858 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001859 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001860 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001861 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001862 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001863 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001864 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001865 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001866 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001867 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001868 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001869 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1870}
1871
Evan Cheng259471d2007-10-05 17:59:57 +00001872let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001873let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001874def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001875 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001876 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1877}
Evan Chengb783fa32007-07-19 01:14:50 +00001878def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001879 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001880 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001881def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001882 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001883 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001884def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001885 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001886 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1887
1888let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001889 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001890 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001891 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001892 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001893 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001894 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001895 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001896 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001897 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1898}
Evan Cheng259471d2007-10-05 17:59:57 +00001899} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001900
Evan Chengb783fa32007-07-19 01:14:50 +00001901def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001902 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001903 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001904def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001905 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001906 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001907def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001910def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001911 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001912 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001913def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001914 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001915 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001916def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001917 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001918 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1919
Evan Chengb783fa32007-07-19 01:14:50 +00001920def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, 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 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001923def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, 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 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001926def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001927 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001928 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001929def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001930 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001931 [(set GR16:$dst, (sub GR16:$src1, i16immSExt8:$src2))]>,
Evan Cheng55687072007-09-14 21:48:26 +00001932 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001933def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001934 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001935 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1936let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001937 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001938 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001939 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001940 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001941 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001942 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001943 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001944 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001945 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001946 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001947 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001948 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001949 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001950 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001951 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001952 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001953 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001954 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001955 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001956 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001957 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001958 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001959 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001960 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001961 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001962 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001963 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1964}
1965
Evan Cheng259471d2007-10-05 17:59:57 +00001966let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001967def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001968 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00001969 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001970
1971let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001972 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001973 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001974 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001975 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001976 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001978 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001979 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001981 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001982 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00001983 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001984}
Evan Chengb783fa32007-07-19 01:14:50 +00001985def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001986 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001987 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001988def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001989 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001990 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001991def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001992 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001993 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00001994} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00001995} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996
Evan Cheng55687072007-09-14 21:48:26 +00001997let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001998let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001999def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002000 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002001 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002002def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002003 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002004 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
2005}
Evan Chengb783fa32007-07-19 01:14:50 +00002006def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002007 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002008 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
2009 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002010def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002011 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002012 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00002013} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002014} // end Two Address instructions
2015
2016// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002017let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002018def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002019 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002020 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002021 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2022def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002023 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002024 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002025 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2026def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002027 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002028 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002029 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2030 OpSize;
2031def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002032 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002033 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002034 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2035
2036def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002037 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002038 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2040 OpSize;
2041def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002042 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002043 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2045def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002046 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002047 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002048 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2049 OpSize;
2050def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002051 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002052 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002053 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00002054} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002055
2056//===----------------------------------------------------------------------===//
2057// Test instructions are just like AND, except they don't generate a result.
2058//
Evan Cheng950aac02007-09-25 01:57:46 +00002059let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002060let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002061def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002062 "test{b}\t{$src2, $src1|$src1, $src2}",
2063 [(X86cmp (and GR8:$src1, GR8:$src2), 0),
2064 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002065def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002066 "test{w}\t{$src2, $src1|$src1, $src2}",
2067 [(X86cmp (and GR16:$src1, GR16:$src2), 0),
2068 (implicit EFLAGS)]>,
2069 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002070def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002071 "test{l}\t{$src2, $src1|$src1, $src2}",
2072 [(X86cmp (and GR32:$src1, GR32:$src2), 0),
2073 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002074}
2075
Evan Chengb783fa32007-07-19 01:14:50 +00002076def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002077 "test{b}\t{$src2, $src1|$src1, $src2}",
2078 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2079 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002080def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002081 "test{w}\t{$src2, $src1|$src1, $src2}",
2082 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2083 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002084def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002085 "test{l}\t{$src2, $src1|$src1, $src2}",
2086 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2087 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088
2089def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002090 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002091 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002092 [(X86cmp (and GR8:$src1, imm:$src2), 0),
2093 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002094def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002095 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002096 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002097 [(X86cmp (and GR16:$src1, imm:$src2), 0),
2098 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002099def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002100 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002101 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002102 [(X86cmp (and GR32:$src1, imm:$src2), 0),
2103 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002104
Evan Cheng621216e2007-09-29 00:00:36 +00002105def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002106 (outs), (ins i8mem:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002107 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002108 [(X86cmp (and (loadi8 addr:$src1), imm:$src2), 0),
2109 (implicit EFLAGS)]>;
2110def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002111 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002112 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002113 [(X86cmp (and (loadi16 addr:$src1), imm:$src2), 0),
2114 (implicit EFLAGS)]>, OpSize;
2115def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002116 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002117 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002118 [(X86cmp (and (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002119 (implicit EFLAGS)]>;
2120} // Defs = [EFLAGS]
2121
2122
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123// Condition code ops, incl. set if equal/not equal/...
Evan Cheng55687072007-09-14 21:48:26 +00002124let Defs = [EFLAGS], Uses = [AH] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002125def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Evan Cheng55687072007-09-14 21:48:26 +00002126let Defs = [AH], Uses = [EFLAGS] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002127def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128
Evan Cheng950aac02007-09-25 01:57:46 +00002129let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002130def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002131 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002132 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002133 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002134 TB; // GR8 = ==
2135def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002136 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002137 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002138 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002139 TB; // [mem8] = ==
2140def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002141 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002142 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002143 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002144 TB; // GR8 = !=
2145def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002146 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002147 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002148 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002149 TB; // [mem8] = !=
2150def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002151 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002152 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002153 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002154 TB; // GR8 = < signed
2155def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002156 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002157 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002158 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002159 TB; // [mem8] = < signed
2160def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002161 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002162 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002163 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002164 TB; // GR8 = >= signed
2165def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002166 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002167 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002168 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002169 TB; // [mem8] = >= signed
2170def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002171 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002172 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002173 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002174 TB; // GR8 = <= signed
2175def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002176 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002177 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002178 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179 TB; // [mem8] = <= signed
2180def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002181 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002182 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002183 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 TB; // GR8 = > signed
2185def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002186 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002187 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002188 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002189 TB; // [mem8] = > signed
2190
2191def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002192 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002193 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002194 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002195 TB; // GR8 = < unsign
2196def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002197 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002198 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002199 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002200 TB; // [mem8] = < unsign
2201def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002202 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002203 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002204 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002205 TB; // GR8 = >= unsign
2206def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002207 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002208 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002209 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002210 TB; // [mem8] = >= unsign
2211def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002212 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002213 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002214 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002215 TB; // GR8 = <= unsign
2216def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002217 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002219 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002220 TB; // [mem8] = <= unsign
2221def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002222 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002224 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002225 TB; // GR8 = > signed
2226def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002227 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002228 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002229 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230 TB; // [mem8] = > signed
2231
2232def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002233 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002234 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002235 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002236 TB; // GR8 = <sign bit>
2237def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002238 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002239 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002240 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002241 TB; // [mem8] = <sign bit>
2242def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002243 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002244 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002245 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002246 TB; // GR8 = !<sign bit>
2247def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002248 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002249 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002250 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002251 TB; // [mem8] = !<sign bit>
2252def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002253 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002254 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002255 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002256 TB; // GR8 = parity
2257def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002258 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002259 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002260 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261 TB; // [mem8] = parity
2262def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002263 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002264 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002265 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002266 TB; // GR8 = not parity
2267def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002268 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002269 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002270 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002271 TB; // [mem8] = not parity
Evan Cheng950aac02007-09-25 01:57:46 +00002272} // Uses = [EFLAGS]
2273
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002274
2275// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002276let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002277def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002278 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002279 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002280 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002281def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002282 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002283 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002284 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002285def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002286 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002287 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002288 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002289def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002290 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002291 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002292 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2293 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002294def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002295 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002296 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002297 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2298 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002299def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002300 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002301 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002302 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2303 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002304def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002305 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002306 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002307 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2308 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002309def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002310 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002311 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002312 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2313 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002314def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002315 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002316 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002317 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2318 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002319def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002320 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002321 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002322 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002323def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002324 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002325 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002326 [(X86cmp GR16:$src1, imm:$src2),
2327 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002328def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002329 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002330 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002331 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002332def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002333 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002334 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002335 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2336 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002337def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002338 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002339 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002340 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2341 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002342def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002343 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002344 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002345 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2346 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002347def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002348 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002349 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002350 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2351 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002352def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002353 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002354 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002355 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2356 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002357def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002358 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002359 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002360 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2361 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002362def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002363 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002364 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002365 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002366 (implicit EFLAGS)]>;
2367} // Defs = [EFLAGS]
2368
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002369// Sign/Zero extenders
Evan Chengb783fa32007-07-19 01:14:50 +00002370def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002371 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002372 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002373def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002374 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002375 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002376def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002377 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002378 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002379def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002380 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002381 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002382def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002383 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002385def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002386 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002387 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2388
Evan Chengb783fa32007-07-19 01:14:50 +00002389def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002390 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002391 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002392def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002393 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002394 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002395def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002396 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002397 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002398def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002399 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002400 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002401def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002402 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002403 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002404def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002405 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002406 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2407
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002408let Defs = [AX], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00002409def CBW : I<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002410 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2411let Defs = [EAX], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002412def CWDE : I<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002413 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002414
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002415let Defs = [AX,DX], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002416def CWD : I<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002417 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2418let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002419def CDQ : I<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002420 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002421
2422
2423//===----------------------------------------------------------------------===//
2424// Alias Instructions
2425//===----------------------------------------------------------------------===//
2426
2427// Alias instructions that map movr0 to xor.
2428// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Cheng55687072007-09-14 21:48:26 +00002429let Defs = [EFLAGS], isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002430def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002431 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002432 [(set GR8:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002433def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002434 "xor{w}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002435 [(set GR16:$dst, 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002436def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002437 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002438 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002439}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002440
2441// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2442// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengb783fa32007-07-19 01:14:50 +00002443def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002444 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002445def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002446 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002447
Evan Chengb783fa32007-07-19 01:14:50 +00002448def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002449 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002450def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002451 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002452let isLoad = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002453def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002454 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002455def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002456 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002457}
Evan Chengb783fa32007-07-19 01:14:50 +00002458def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002459 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002460def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002461 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002462
2463//===----------------------------------------------------------------------===//
2464// Thread Local Storage Instructions
2465//
2466
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002467let Uses = [EBX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002468def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
Dan Gohman91888f02007-07-31 20:11:57 +00002469 "leal\t${sym:mem}(,%ebx,1), $dst",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002470 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002471
2472let AddedComplexity = 10 in
Evan Chengb783fa32007-07-19 01:14:50 +00002473def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002474 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002475 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2476
2477let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002478def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002479 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002480 [(set GR32:$dst,
2481 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2482
Evan Chengb783fa32007-07-19 01:14:50 +00002483def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002484 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002485 [(set GR32:$dst, X86TLStp)]>;
2486
2487//===----------------------------------------------------------------------===//
2488// DWARF Pseudo Instructions
2489//
2490
Evan Chengb783fa32007-07-19 01:14:50 +00002491def DWARF_LOC : I<0, Pseudo, (outs),
2492 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002493 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002494 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2495 (i32 imm:$file))]>;
2496
2497//===----------------------------------------------------------------------===//
2498// EH Pseudo Instructions
2499//
2500let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002501 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002502def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002503 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002504 [(X86ehret GR32:$addr)]>;
2505
2506}
2507
2508//===----------------------------------------------------------------------===//
2509// Non-Instruction Patterns
2510//===----------------------------------------------------------------------===//
2511
2512// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2513def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2514def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2515def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2516def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2517def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2518
2519def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2520 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2521def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2522 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2523def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2524 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2525def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2526 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2527
2528def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2529 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2530def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2531 (MOV32mi addr:$dst, texternalsym:$src)>;
2532
2533// Calls
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002534// tailcall stuff
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002535def : Pat<(X86tailcall GR32:$dst),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002536 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002537
2538def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002539 (TAILCALL)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002540def : Pat<(X86tailcall (i32 texternalsym:$dst)),
Arnold Schwaighofere2d6bbb2007-10-11 19:40:01 +00002541 (TAILCALL)>;
2542
2543def : Pat<(X86tcret GR32:$dst, imm:$off),
2544 (TCRETURNri GR32:$dst, imm:$off)>;
2545
2546def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off),
2547 (TCRETURNdi texternalsym:$dst, imm:$off)>;
2548
2549def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off),
2550 (TCRETURNdi texternalsym:$dst, imm:$off)>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002551
2552def : Pat<(X86call (i32 tglobaladdr:$dst)),
2553 (CALLpcrel32 tglobaladdr:$dst)>;
2554def : Pat<(X86call (i32 texternalsym:$dst)),
2555 (CALLpcrel32 texternalsym:$dst)>;
2556
2557// X86 specific add which produces a flag.
2558def : Pat<(addc GR32:$src1, GR32:$src2),
2559 (ADD32rr GR32:$src1, GR32:$src2)>;
2560def : Pat<(addc GR32:$src1, (load addr:$src2)),
2561 (ADD32rm GR32:$src1, addr:$src2)>;
2562def : Pat<(addc GR32:$src1, imm:$src2),
2563 (ADD32ri GR32:$src1, imm:$src2)>;
2564def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2565 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2566
2567def : Pat<(subc GR32:$src1, GR32:$src2),
2568 (SUB32rr GR32:$src1, GR32:$src2)>;
2569def : Pat<(subc GR32:$src1, (load addr:$src2)),
2570 (SUB32rm GR32:$src1, addr:$src2)>;
2571def : Pat<(subc GR32:$src1, imm:$src2),
2572 (SUB32ri GR32:$src1, imm:$src2)>;
2573def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2574 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2575
2576def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2577 (MOV8mi addr:$dst, imm:$src)>;
2578def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2579 (MOV8mr addr:$dst, GR8:$src)>;
2580
2581// Comparisons.
2582
2583// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00002584def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002585 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002586def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002587 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002588def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002589 (TEST32rr GR32:$src1, GR32:$src1)>;
2590
2591// {s|z}extload bool -> {s|z}extload byte
2592def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2593def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2594def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2595def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2596def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2597
2598// extload bool -> extload byte
2599def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2600def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2601def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2602def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2603def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2604def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2605
2606// anyext -> zext
2607def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2608def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2609def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2610def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2611def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2612def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2613
2614//===----------------------------------------------------------------------===//
2615// Some peepholes
2616//===----------------------------------------------------------------------===//
2617
2618// (shl x, 1) ==> (add x, x)
2619def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2620def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2621def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2622
2623// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2624def : Pat<(or (srl GR32:$src1, CL:$amt),
2625 (shl GR32:$src2, (sub 32, CL:$amt))),
2626 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2627
2628def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2629 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2630 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2631
2632// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2633def : Pat<(or (shl GR32:$src1, CL:$amt),
2634 (srl GR32:$src2, (sub 32, CL:$amt))),
2635 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2636
2637def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2638 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2639 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2640
2641// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2642def : Pat<(or (srl GR16:$src1, CL:$amt),
2643 (shl GR16:$src2, (sub 16, CL:$amt))),
2644 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2645
2646def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2647 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2648 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2649
2650// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2651def : Pat<(or (shl GR16:$src1, CL:$amt),
2652 (srl GR16:$src2, (sub 16, CL:$amt))),
2653 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2654
2655def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2656 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2657 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2658
2659
2660//===----------------------------------------------------------------------===//
2661// Floating Point Stack Support
2662//===----------------------------------------------------------------------===//
2663
2664include "X86InstrFPStack.td"
2665
2666//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00002667// X86-64 Support
2668//===----------------------------------------------------------------------===//
2669
2670include "X86InstrX86-64.td"
2671
2672//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002673// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2674//===----------------------------------------------------------------------===//
2675
2676include "X86InstrMMX.td"
2677
2678//===----------------------------------------------------------------------===//
2679// XMM Floating point support (requires SSE / SSE2)
2680//===----------------------------------------------------------------------===//
2681
2682include "X86InstrSSE.td"