blob: 915507ad7066020d1b14c1c367123af40e08dcd4 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the X86 instruction set, defining the instructions, and
11// properties of the instructions which are needed for code generation, machine
12// code emission, and analysis.
13//
14//===----------------------------------------------------------------------===//
15
16//===----------------------------------------------------------------------===//
17// X86 specific DAG Nodes.
18//
19
20def SDTIntShiftDOp: SDTypeProfile<1, 3,
21 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
22 SDTCisInt<0>, SDTCisInt<3>]>;
23
24def SDTX86CmpTest : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
25
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
58def X86shld : SDNode<"X86ISD::SHLD", SDTIntShiftDOp>;
59def X86shrd : SDNode<"X86ISD::SHRD", SDTIntShiftDOp>;
60
Evan Cheng621216e2007-09-29 00:00:36 +000061def X86cmp : SDNode<"X86ISD::CMP" , SDTX86CmpTest>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062
Evan Cheng621216e2007-09-29 00:00:36 +000063def X86cmov : SDNode<"X86ISD::CMOV", SDTX86Cmov>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064def X86brcond : SDNode<"X86ISD::BRCOND", SDTX86BrCond,
Evan Cheng950aac02007-09-25 01:57:46 +000065 [SDNPHasChain]>;
Evan Cheng621216e2007-09-29 00:00:36 +000066def X86setcc : SDNode<"X86ISD::SETCC", SDTX86SetCC>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000067
68def X86retflag : SDNode<"X86ISD::RET_FLAG", SDTX86Ret,
69 [SDNPHasChain, SDNPOptInFlag]>;
70
71def X86callseq_start :
72 SDNode<"ISD::CALLSEQ_START", SDT_X86CallSeqStart,
73 [SDNPHasChain, SDNPOutFlag]>;
74def X86callseq_end :
75 SDNode<"ISD::CALLSEQ_END", SDT_X86CallSeqEnd,
76 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
77
78def X86call : SDNode<"X86ISD::CALL", SDT_X86Call,
79 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
80
81def X86tailcall: SDNode<"X86ISD::TAILCALL", SDT_X86Call,
82 [SDNPHasChain, SDNPOutFlag, SDNPOptInFlag]>;
83
84def X86rep_stos: SDNode<"X86ISD::REP_STOS", SDTX86RepStr,
85 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
86def X86rep_movs: SDNode<"X86ISD::REP_MOVS", SDTX86RepStr,
87 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
88
89def X86rdtsc : SDNode<"X86ISD::RDTSC_DAG",SDTX86RdTsc,
90 [SDNPHasChain, SDNPOutFlag]>;
91
92def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
93def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
94
95def X86tlsaddr : SDNode<"X86ISD::TLSADDR", SDT_X86TLSADDR,
96 [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>;
97def X86TLStp : SDNode<"X86ISD::THREAD_POINTER", SDT_X86TLSTP, []>;
98
99def X86ehret : SDNode<"X86ISD::EH_RETURN", SDT_X86EHRET,
100 [SDNPHasChain]>;
101
102
103//===----------------------------------------------------------------------===//
104// X86 Operand Definitions.
105//
106
107// *mem - Operand definitions for the funky X86 addressing mode operands.
108//
109class X86MemOperand<string printMethod> : Operand<iPTR> {
110 let PrintMethod = printMethod;
111 let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc, i32imm);
112}
113
114def i8mem : X86MemOperand<"printi8mem">;
115def i16mem : X86MemOperand<"printi16mem">;
116def i32mem : X86MemOperand<"printi32mem">;
117def i64mem : X86MemOperand<"printi64mem">;
118def i128mem : X86MemOperand<"printi128mem">;
119def f32mem : X86MemOperand<"printf32mem">;
120def f64mem : X86MemOperand<"printf64mem">;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000121def f80mem : X86MemOperand<"printf80mem">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000122def f128mem : X86MemOperand<"printf128mem">;
123
124def lea32mem : Operand<i32> {
125 let PrintMethod = "printi32mem";
126 let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm);
127}
128
129def SSECC : Operand<i8> {
130 let PrintMethod = "printSSECC";
131}
132
133def piclabel: Operand<i32> {
134 let PrintMethod = "printPICLabel";
135}
136
137// A couple of more descriptive operand definitions.
138// 16-bits but only 8 bits are significant.
139def i16i8imm : Operand<i16>;
140// 32-bits but only 8 bits are significant.
141def i32i8imm : Operand<i32>;
142
143// Branch targets have OtherVT type.
144def brtarget : Operand<OtherVT>;
145
146//===----------------------------------------------------------------------===//
147// X86 Complex Pattern Definitions.
148//
149
150// Define X86 specific addressing mode.
151def addr : ComplexPattern<iPTR, 4, "SelectAddr", [], []>;
152def lea32addr : ComplexPattern<i32, 4, "SelectLEAAddr",
153 [add, mul, shl, or, frameindex], []>;
154
155//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000156// X86 Instruction Predicate Definitions.
157def HasMMX : Predicate<"Subtarget->hasMMX()">;
158def HasSSE1 : Predicate<"Subtarget->hasSSE1()">;
159def HasSSE2 : Predicate<"Subtarget->hasSSE2()">;
160def HasSSE3 : Predicate<"Subtarget->hasSSE3()">;
161def HasSSSE3 : Predicate<"Subtarget->hasSSSE3()">;
Dale Johannesene0e0fd02007-09-23 14:52:20 +0000162def FPStackf32 : Predicate<"!Subtarget->hasSSE1()">;
163def FPStackf64 : Predicate<"!Subtarget->hasSSE2()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000164def In32BitMode : Predicate<"!Subtarget->is64Bit()">;
165def In64BitMode : Predicate<"Subtarget->is64Bit()">;
Evan Cheng09e13792007-08-01 23:45:51 +0000166def HasLow4G : Predicate<"Subtarget->hasLow4GUserSpaceAddress()">;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000167def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
168def NotSmallCode : Predicate<"TM.getCodeModel() != CodeModel::Small">;
169def IsStatic : Predicate<"TM.getRelocationModel() == Reloc::Static">;
170
171//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +0000172// X86 Instruction Format Definitions.
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000173//
174
Evan Cheng86ab7d32007-07-31 08:04:03 +0000175include "X86InstrFormats.td"
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000176
177//===----------------------------------------------------------------------===//
178// Pattern fragments...
179//
180
181// X86 specific condition code. These correspond to CondCode in
182// X86InstrInfo.h. They must be kept in synch.
183def X86_COND_A : PatLeaf<(i8 0)>;
184def X86_COND_AE : PatLeaf<(i8 1)>;
185def X86_COND_B : PatLeaf<(i8 2)>;
186def X86_COND_BE : PatLeaf<(i8 3)>;
187def X86_COND_E : PatLeaf<(i8 4)>;
188def X86_COND_G : PatLeaf<(i8 5)>;
189def X86_COND_GE : PatLeaf<(i8 6)>;
190def X86_COND_L : PatLeaf<(i8 7)>;
191def X86_COND_LE : PatLeaf<(i8 8)>;
192def X86_COND_NE : PatLeaf<(i8 9)>;
193def X86_COND_NO : PatLeaf<(i8 10)>;
194def X86_COND_NP : PatLeaf<(i8 11)>;
195def X86_COND_NS : PatLeaf<(i8 12)>;
196def X86_COND_O : PatLeaf<(i8 13)>;
197def X86_COND_P : PatLeaf<(i8 14)>;
198def X86_COND_S : PatLeaf<(i8 15)>;
199
200def i16immSExt8 : PatLeaf<(i16 imm), [{
201 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
202 // sign extended field.
203 return (int16_t)N->getValue() == (int8_t)N->getValue();
204}]>;
205
206def i32immSExt8 : PatLeaf<(i32 imm), [{
207 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
208 // sign extended field.
209 return (int32_t)N->getValue() == (int8_t)N->getValue();
210}]>;
211
212// Helper fragments for loads.
213def loadi8 : PatFrag<(ops node:$ptr), (i8 (load node:$ptr))>;
214def loadi16 : PatFrag<(ops node:$ptr), (i16 (load node:$ptr))>;
215def loadi32 : PatFrag<(ops node:$ptr), (i32 (load node:$ptr))>;
216def loadi64 : PatFrag<(ops node:$ptr), (i64 (load node:$ptr))>;
217
218def loadf32 : PatFrag<(ops node:$ptr), (f32 (load node:$ptr))>;
219def loadf64 : PatFrag<(ops node:$ptr), (f64 (load node:$ptr))>;
Dale Johannesen4ab00bd2007-08-05 18:49:15 +0000220def loadf80 : PatFrag<(ops node:$ptr), (f80 (load node:$ptr))>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000221
222def sextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (sextloadi1 node:$ptr))>;
223def sextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (sextloadi1 node:$ptr))>;
224def sextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (sextloadi8 node:$ptr))>;
225def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>;
226def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>;
227
228def zextloadi8i1 : PatFrag<(ops node:$ptr), (i8 (zextloadi1 node:$ptr))>;
229def zextloadi16i1 : PatFrag<(ops node:$ptr), (i16 (zextloadi1 node:$ptr))>;
230def zextloadi32i1 : PatFrag<(ops node:$ptr), (i32 (zextloadi1 node:$ptr))>;
231def zextloadi16i8 : PatFrag<(ops node:$ptr), (i16 (zextloadi8 node:$ptr))>;
232def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>;
233def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>;
234
235def extloadi8i1 : PatFrag<(ops node:$ptr), (i8 (extloadi1 node:$ptr))>;
236def extloadi16i1 : PatFrag<(ops node:$ptr), (i16 (extloadi1 node:$ptr))>;
237def extloadi32i1 : PatFrag<(ops node:$ptr), (i32 (extloadi1 node:$ptr))>;
238def extloadi16i8 : PatFrag<(ops node:$ptr), (i16 (extloadi8 node:$ptr))>;
239def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>;
240def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>;
241
242//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000243// Instruction list...
244//
245
246// ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into
247// a stack adjustment and the codegen must know that they may modify the stack
248// pointer before prolog-epilog rewriting occurs.
Evan Chenge4f1f572007-09-28 01:35:02 +0000249// Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become sub / add
Evan Cheng037364a2007-09-28 01:19:48 +0000250// which can clobber EFLAGS.
251let Defs = [ESP, EFLAGS], Uses = [ESP] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000252def ADJCALLSTACKDOWN : I<0, Pseudo, (outs), (ins i32imm:$amt), "#ADJCALLSTACKDOWN",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000253 [(X86callseq_start imm:$amt)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000254def ADJCALLSTACKUP : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000255 "#ADJCALLSTACKUP",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000256 [(X86callseq_end imm:$amt1, imm:$amt2)]>;
257}
Evan Chengb783fa32007-07-19 01:14:50 +0000258def IMPLICIT_USE : I<0, Pseudo, (outs), (ins variable_ops),
259 "#IMPLICIT_USE", []>;
260def IMPLICIT_DEF : I<0, Pseudo, (outs variable_ops), (ins),
261 "#IMPLICIT_DEF", []>;
262def IMPLICIT_DEF_GR8 : I<0, Pseudo, (outs GR8:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000263 "#IMPLICIT_DEF $dst",
264 [(set GR8:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000265def IMPLICIT_DEF_GR16 : I<0, Pseudo, (outs GR16:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000266 "#IMPLICIT_DEF $dst",
267 [(set GR16:$dst, (undef))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000268def IMPLICIT_DEF_GR32 : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000269 "#IMPLICIT_DEF $dst",
270 [(set GR32:$dst, (undef))]>;
271
272// Nop
Evan Chengb783fa32007-07-19 01:14:50 +0000273def NOOP : I<0x90, RawFrm, (outs), (ins), "nop", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000275
276//===----------------------------------------------------------------------===//
277// Control Flow Instructions...
278//
279
280// Return instructions.
281let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +0000282 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000283 def RET : I<0xC3, RawFrm, (outs), (ins), "ret", [(X86retflag 0)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000284 def RETI : Ii16<0xC2, RawFrm, (outs), (ins i16imm:$amt), "ret\t$amt",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000285 [(X86retflag imm:$amt)]>;
286}
287
288// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng37e7c752007-07-21 00:34:19 +0000289let isBranch = 1, isTerminator = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000290 class IBr<bits<8> opcode, dag ins, string asm, list<dag> pattern> :
291 I<opcode, RawFrm, (outs), ins, asm, pattern>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000292
293// Indirect branches
294let isBranch = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000295 def JMP : IBr<0xE9, (ins brtarget:$dst), "jmp\t$dst", [(br bb:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000296
Evan Cheng37e7c752007-07-21 00:34:19 +0000297let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
Dan Gohman91888f02007-07-31 20:11:57 +0000298 def JMP32r : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000299 [(brind GR32:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +0000300 def JMP32m : I<0xFF, MRM4m, (outs), (ins i32mem:$dst), "jmp{l}\t{*}$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000301 [(brind (loadi32 addr:$dst))]>;
302}
303
304// Conditional branches
Evan Cheng950aac02007-09-25 01:57:46 +0000305let Uses = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +0000306def JE : IBr<0x84, (ins brtarget:$dst), "je\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000307 [(X86brcond bb:$dst, X86_COND_E, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000308def JNE : IBr<0x85, (ins brtarget:$dst), "jne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000309 [(X86brcond bb:$dst, X86_COND_NE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000310def JL : IBr<0x8C, (ins brtarget:$dst), "jl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000311 [(X86brcond bb:$dst, X86_COND_L, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000312def JLE : IBr<0x8E, (ins brtarget:$dst), "jle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000313 [(X86brcond bb:$dst, X86_COND_LE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000314def JG : IBr<0x8F, (ins brtarget:$dst), "jg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000315 [(X86brcond bb:$dst, X86_COND_G, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000316def JGE : IBr<0x8D, (ins brtarget:$dst), "jge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000317 [(X86brcond bb:$dst, X86_COND_GE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000318
Dan Gohman91888f02007-07-31 20:11:57 +0000319def JB : IBr<0x82, (ins brtarget:$dst), "jb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000320 [(X86brcond bb:$dst, X86_COND_B, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000321def JBE : IBr<0x86, (ins brtarget:$dst), "jbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000322 [(X86brcond bb:$dst, X86_COND_BE, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000323def JA : IBr<0x87, (ins brtarget:$dst), "ja\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000324 [(X86brcond bb:$dst, X86_COND_A, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000325def JAE : IBr<0x83, (ins brtarget:$dst), "jae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000326 [(X86brcond bb:$dst, X86_COND_AE, EFLAGS)]>, TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000327
Dan Gohman91888f02007-07-31 20:11:57 +0000328def JS : IBr<0x88, (ins brtarget:$dst), "js\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000329 [(X86brcond bb:$dst, X86_COND_S, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000330def JNS : IBr<0x89, (ins brtarget:$dst), "jns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000331 [(X86brcond bb:$dst, X86_COND_NS, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000332def JP : IBr<0x8A, (ins brtarget:$dst), "jp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000333 [(X86brcond bb:$dst, X86_COND_P, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000334def JNP : IBr<0x8B, (ins brtarget:$dst), "jnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000335 [(X86brcond bb:$dst, X86_COND_NP, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000336def JO : IBr<0x80, (ins brtarget:$dst), "jo\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000337 [(X86brcond bb:$dst, X86_COND_O, EFLAGS)]>, TB;
Dan Gohman91888f02007-07-31 20:11:57 +0000338def JNO : IBr<0x81, (ins brtarget:$dst), "jno\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +0000339 [(X86brcond bb:$dst, X86_COND_NO, EFLAGS)]>, TB;
Evan Cheng950aac02007-09-25 01:57:46 +0000340} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000341
342//===----------------------------------------------------------------------===//
343// Call Instructions...
344//
Evan Cheng37e7c752007-07-21 00:34:19 +0000345let isCall = 1 in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000346 // All calls clobber the non-callee saved registers...
347 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
348 MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7,
Evan Cheng950aac02007-09-25 01:57:46 +0000349 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000350 def CALLpcrel32 : I<0xE8, RawFrm, (outs), (ins i32imm:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000351 "call\t${dst:call}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000352 def CALL32r : I<0xFF, MRM2r, (outs), (ins GR32:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000353 "call\t{*}$dst", [(X86call GR32:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000354 def CALL32m : I<0xFF, MRM2m, (outs), (ins i32mem:$dst, variable_ops),
Dan Gohman91888f02007-07-31 20:11:57 +0000355 "call\t{*}$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000356 }
357
358// Tail call stuff.
Evan Cheng37e7c752007-07-21 00:34:19 +0000359let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000360 def TAILJMPd : IBr<0xE9, (ins i32imm:$dst), "jmp\t${dst:call} # TAIL CALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000361 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000362let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Dan Gohman91888f02007-07-31 20:11:57 +0000363 def TAILJMPr : I<0xFF, MRM4r, (outs), (ins GR32:$dst), "jmp\t{*}$dst # TAIL CALL",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000364 []>;
Evan Cheng37e7c752007-07-21 00:34:19 +0000365let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengb783fa32007-07-19 01:14:50 +0000366 def TAILJMPm : I<0xFF, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +0000367 "jmp\t{*}$dst # TAIL CALL", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000368
369//===----------------------------------------------------------------------===//
370// Miscellaneous Instructions...
371//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000372let Defs = [EBP, ESP], Uses = [EBP, ESP] in
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000373def LEAVE : I<0xC9, RawFrm,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000374 (outs), (ins), "leave", []>;
375
376let Defs = [ESP], Uses = [ESP] in {
Evan Chengd8434332007-09-26 01:29:06 +0000377def POP32r : I<0x58, AddRegFrm, (outs GR32:$reg), (ins), "pop{l}\t$reg", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000378
Evan Chengd8434332007-09-26 01:29:06 +0000379def PUSH32r : I<0x50, AddRegFrm, (outs), (ins GR32:$reg), "push{l}\t$reg",[]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000380}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000381
Evan Chengd8434332007-09-26 01:29:06 +0000382let Defs = [ESP, EFLAGS], Uses = [ESP] in
Evan Chengf1341312007-09-26 21:28:00 +0000383def POPFD : I<0x9D, RawFrm, (outs), (ins), "popf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000384let Defs = [ESP], Uses = [ESP, EFLAGS] in
Evan Chengf1341312007-09-26 21:28:00 +0000385def PUSHFD : I<0x9C, RawFrm, (outs), (ins), "pushf", []>;
Evan Chengd8434332007-09-26 01:29:06 +0000386
Evan Chengb783fa32007-07-19 01:14:50 +0000387def MovePCtoStack : I<0, Pseudo, (outs), (ins piclabel:$label),
Dan Gohman91888f02007-07-31 20:11:57 +0000388 "call\t$label", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000389
390let isTwoAddress = 1 in // GR32 = bswap GR32
391 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengb783fa32007-07-19 01:14:50 +0000392 (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000393 "bswap{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000394 [(set GR32:$dst, (bswap GR32:$src))]>, TB;
395
Evan Chengb783fa32007-07-19 01:14:50 +0000396// FIXME: Model xchg* as two address instructions?
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000397def XCHG8rr : I<0x86, MRMDestReg, // xchg GR8, GR8
Evan Chengb783fa32007-07-19 01:14:50 +0000398 (outs), (ins GR8:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000399 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000400def XCHG16rr : I<0x87, MRMDestReg, // xchg GR16, GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000401 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000402 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000403def XCHG32rr : I<0x87, MRMDestReg, // xchg GR32, GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000404 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000405 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000406
407def XCHG8mr : I<0x86, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000408 (outs), (ins i8mem:$src1, GR8:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000409 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000410def XCHG16mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000411 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000412 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000413def XCHG32mr : I<0x87, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000414 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000415 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000416def XCHG8rm : I<0x86, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000417 (outs), (ins GR8:$src1, i8mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000418 "xchg{b}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000419def XCHG16rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000420 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000421 "xchg{w}\t{$src2|$src1}, {$src1|$src2}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000422def XCHG32rm : I<0x87, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000423 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000424 "xchg{l}\t{$src2|$src1}, {$src1|$src2}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000425
426def LEA16r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000427 (outs GR16:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000428 "lea{w}\t{$src|$dst}, {$dst|$src}", []>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000429def LEA32r : I<0x8D, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +0000430 (outs GR32:$dst), (ins lea32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000431 "lea{l}\t{$src|$dst}, {$dst|$src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000432 [(set GR32:$dst, lea32addr:$src)]>, Requires<[In32BitMode]>;
433
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000434let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI] in {
Evan Chengb783fa32007-07-19 01:14:50 +0000435def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000436 [(X86rep_movs i8)]>, REP;
Evan Chengb783fa32007-07-19 01:14:50 +0000437def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000438 [(X86rep_movs i16)]>, REP, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000439def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000440 [(X86rep_movs i32)]>, REP;
441}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000442
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000443let Defs = [ECX,EDI], Uses = [AL,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000444def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000445 [(X86rep_stos i8)]>, REP;
446let Defs = [ECX,EDI], Uses = [AX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000447def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000448 [(X86rep_stos i16)]>, REP, OpSize;
449let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI] in
Evan Chengb783fa32007-07-19 01:14:50 +0000450def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000451 [(X86rep_stos i32)]>, REP;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000452
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000453let Defs = [RAX, RDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000454def RDTSC : I<0x31, RawFrm, (outs), (ins), "rdtsc", [(X86rdtsc)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000455 TB;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000456
457//===----------------------------------------------------------------------===//
458// Input/Output Instructions...
459//
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000460let Defs = [AL], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000461def IN8rr : I<0xEC, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000462 "in{b}\t{%dx, %al|%AL, %DX}", []>;
463let Defs = [AX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000464def IN16rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000465 "in{w}\t{%dx, %ax|%AX, %DX}", []>, OpSize;
466let Defs = [EAX], Uses = [DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000467def IN32rr : I<0xED, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000468 "in{l}\t{%dx, %eax|%EAX, %DX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000469
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000470let Defs = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000471def IN8ri : Ii8<0xE4, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000472 "in{b}\t{$port, %al|%AL, $port}", []>;
473let Defs = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000474def IN16ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000475 "in{w}\t{$port, %ax|%AX, $port}", []>, OpSize;
476let Defs = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000477def IN32ri : Ii8<0xE5, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000478 "in{l}\t{$port, %eax|%EAX, $port}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000479
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000480let Uses = [DX, AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000481def OUT8rr : I<0xEE, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000482 "out{b}\t{%al, %dx|%DX, %AL}", []>;
483let Uses = [DX, AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000484def OUT16rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000485 "out{w}\t{%ax, %dx|%DX, %AX}", []>, OpSize;
486let Uses = [DX, EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000487def OUT32rr : I<0xEF, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000488 "out{l}\t{%eax, %dx|%DX, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000489
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000490let Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000491def OUT8ir : Ii8<0xE6, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000492 "out{b}\t{%al, $port|$port, %AL}", []>;
493let Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000494def OUT16ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000495 "out{w}\t{%ax, $port|$port, %AX}", []>, OpSize;
496let Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000497def OUT32ir : Ii8<0xE7, RawFrm, (outs), (ins i16i8imm:$port),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000498 "out{l}\t{%eax, $port|$port, %EAX}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000499
500//===----------------------------------------------------------------------===//
501// Move Instructions...
502//
Evan Chengb783fa32007-07-19 01:14:50 +0000503def MOV8rr : I<0x88, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000504 "mov{b}\t{$src, $dst|$dst, $src}", []>;
Evan Chengb783fa32007-07-19 01:14:50 +0000505def MOV16rr : I<0x89, MRMDestReg, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000506 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000507def MOV32rr : I<0x89, MRMDestReg, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000508 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000509let isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000510def MOV8ri : Ii8 <0xB0, AddRegFrm, (outs GR8 :$dst), (ins i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000511 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000512 [(set GR8:$dst, imm:$src)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000513def MOV16ri : Ii16<0xB8, AddRegFrm, (outs GR16:$dst), (ins i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000514 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000515 [(set GR16:$dst, imm:$src)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000516def MOV32ri : Ii32<0xB8, AddRegFrm, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000517 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000518 [(set GR32:$dst, imm:$src)]>;
519}
Evan Chengb783fa32007-07-19 01:14:50 +0000520def MOV8mi : Ii8 <0xC6, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000521 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000522 [(store (i8 imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000523def MOV16mi : Ii16<0xC7, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000524 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000525 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000526def MOV32mi : Ii32<0xC7, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000527 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000528 [(store (i32 imm:$src), addr:$dst)]>;
529
Evan Cheng4e84e452007-08-30 05:49:43 +0000530let isLoad = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +0000531def MOV8rm : I<0x8A, MRMSrcMem, (outs GR8 :$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000532 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000533 [(set GR8:$dst, (load addr:$src))]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000534def MOV16rm : I<0x8B, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000535 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000536 [(set GR16:$dst, (load addr:$src))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000537def MOV32rm : I<0x8B, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000538 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000539 [(set GR32:$dst, (load addr:$src))]>;
Evan Cheng4e84e452007-08-30 05:49:43 +0000540}
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000541
Evan Chengb783fa32007-07-19 01:14:50 +0000542def MOV8mr : I<0x88, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000543 "mov{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000544 [(store GR8:$src, addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +0000545def MOV16mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000546 "mov{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000547 [(store GR16:$src, addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +0000548def MOV32mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000549 "mov{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000550 [(store GR32:$src, addr:$dst)]>;
551
552//===----------------------------------------------------------------------===//
553// Fixed-Register Multiplication and Division Instructions...
554//
555
556// Extra precision multiplication
Evan Cheng55687072007-09-14 21:48:26 +0000557let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Dan Gohman91888f02007-07-31 20:11:57 +0000558def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000559 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
560 // This probably ought to be moved to a def : Pat<> if the
561 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000562 [(set AL, (mul AL, GR8:$src))]>; // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000563let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000564def MUL16r : I<0xF7, MRM4r, (outs), (ins GR16:$src), "mul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000565 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000566let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000567def MUL32r : I<0xF7, MRM4r, (outs), (ins GR32:$src), "mul{l}\t$src", []>;
568 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000569let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000570def MUL8m : I<0xF6, MRM4m, (outs), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +0000571 "mul{b}\t$src",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000572 // FIXME: Used for 8-bit mul, ignore result upper 8 bits.
573 // This probably ought to be moved to a def : Pat<> if the
574 // syntax can be accepted.
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000575 [(set AL, (mul AL, (loadi8 addr:$src)))]>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000576let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000577def MUL16m : I<0xF7, MRM4m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000578 "mul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
Evan Cheng55687072007-09-14 21:48:26 +0000579let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000580def MUL32m : I<0xF7, MRM4m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000581 "mul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000582
Evan Cheng55687072007-09-14 21:48:26 +0000583let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000584def IMUL8r : I<0xF6, MRM5r, (outs), (ins GR8:$src), "imul{b}\t$src", []>;
585 // AL,AH = AL*GR8
Evan Cheng55687072007-09-14 21:48:26 +0000586let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Dan Gohman91888f02007-07-31 20:11:57 +0000587def IMUL16r : I<0xF7, MRM5r, (outs), (ins GR16:$src), "imul{w}\t$src", []>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000588 OpSize; // AX,DX = AX*GR16
Evan Cheng55687072007-09-14 21:48:26 +0000589let Defs = [EAX,EDX,EFLAGS], Uses = [EAX] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000590def IMUL32r : I<0xF7, MRM5r, (outs), (ins GR32:$src), "imul{l}\t$src", []>;
591 // EAX,EDX = EAX*GR32
Evan Cheng55687072007-09-14 21:48:26 +0000592let Defs = [AL,AH,EFLAGS], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +0000593def IMUL8m : I<0xF6, MRM5m, (outs), (ins i8mem :$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000594 "imul{b}\t$src", []>; // AL,AH = AL*[mem8]
Evan Cheng55687072007-09-14 21:48:26 +0000595let Defs = [AX,DX,EFLAGS], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000596def IMUL16m : I<0xF7, MRM5m, (outs), (ins i16mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000597 "imul{w}\t$src", []>, OpSize; // AX,DX = AX*[mem16]
598let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000599def IMUL32m : I<0xF7, MRM5m, (outs), (ins i32mem:$src),
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000600 "imul{l}\t$src", []>; // EAX,EDX = EAX*[mem32]
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000601
602// unsigned division/remainder
Evan Cheng55687072007-09-14 21:48:26 +0000603let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000604def DIV8r : I<0xF6, MRM6r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000605 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000606let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000607def DIV16r : I<0xF7, MRM6r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000608 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000609let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000610def DIV32r : I<0xF7, MRM6r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000611 "div{l}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000612let Defs = [AX,EFLAGS], Uses = [AL,AH] in
Evan Chengb783fa32007-07-19 01:14:50 +0000613def DIV8m : I<0xF6, MRM6m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000614 "div{b}\t$src", []>;
Evan Cheng55687072007-09-14 21:48:26 +0000615let Defs = [AX,DX,EFLAGS], Uses = [AX,DX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000616def DIV16m : I<0xF7, MRM6m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000617 "div{w}\t$src", []>, OpSize;
Evan Cheng55687072007-09-14 21:48:26 +0000618let Defs = [EAX,EDX,EFLAGS], Uses = [EAX,EDX] in
Evan Chengb783fa32007-07-19 01:14:50 +0000619def DIV32m : I<0xF7, MRM6m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000620 "div{l}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000621
622// Signed 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 IDIV8r : I<0xF6, MRM7r, (outs), (ins GR8:$src), // AX/r8 = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000625 "idiv{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 IDIV16r: I<0xF7, MRM7r, (outs), (ins GR16:$src), // DX:AX/r16 = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000628 "idiv{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 IDIV32r: I<0xF7, MRM7r, (outs), (ins GR32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000631 "idiv{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 IDIV8m : I<0xF6, MRM7m, (outs), (ins i8mem:$src), // AX/[mem8] = AL,AH
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000634 "idiv{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 IDIV16m: I<0xF7, MRM7m, (outs), (ins i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000637 "idiv{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 IDIV32m: I<0xF7, MRM7m, (outs), (ins i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Cheng6e4d1d92007-09-11 19:55:27 +0000640 "idiv{l}\t$src", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000641
642
643//===----------------------------------------------------------------------===//
644// Two address Instructions...
645//
646let isTwoAddress = 1 in {
647
648// Conditional moves
Evan Cheng950aac02007-09-25 01:57:46 +0000649let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000650def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000651 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000652 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000653 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000654 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000655 TB, OpSize;
656def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000657 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000658 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000659 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000660 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000661 TB, OpSize;
662def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000663 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000664 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000665 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000666 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000667 TB;
668def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000669 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000670 "cmovb\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000671 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000672 X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000673 TB;
674
675def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000676 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000677 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000678 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000679 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000680 TB, OpSize;
681def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000682 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000683 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000684 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000685 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000686 TB, OpSize;
687def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000688 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000689 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000690 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000691 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000692 TB;
693def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000694 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000695 "cmovae\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000696 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000697 X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000698 TB;
699
700def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000701 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000702 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000703 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000704 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000705 TB, OpSize;
706def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000707 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000708 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000709 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000710 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000711 TB, OpSize;
712def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000713 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000714 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000715 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000716 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000717 TB;
718def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000719 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000720 "cmove\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000721 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000722 X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000723 TB;
724
725def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000726 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000727 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000728 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000729 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000730 TB, OpSize;
731def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000732 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000733 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000734 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000735 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000736 TB, OpSize;
737def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000738 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000739 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000740 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000741 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000742 TB;
743def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000744 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000745 "cmovne\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000746 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000747 X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000748 TB;
749
750def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000751 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000752 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000753 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000754 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000755 TB, OpSize;
756def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000757 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000758 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000759 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000760 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000761 TB, OpSize;
762def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, 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 "cmovbe\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_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000767 TB;
768def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000769 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000770 "cmovbe\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000771 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000772 X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000773 TB;
774
775def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000776 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000777 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000778 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000779 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000780 TB, OpSize;
781def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000782 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000783 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000784 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000785 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000786 TB, OpSize;
787def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000788 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000789 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000790 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000791 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000792 TB;
793def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000794 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000795 "cmova\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000796 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000797 X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000798 TB;
799
800def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000801 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000802 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000803 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000804 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000805 TB, OpSize;
806def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000807 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000808 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000809 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000810 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000811 TB, OpSize;
812def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000813 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000814 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000815 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000816 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000817 TB;
818def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000819 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000820 "cmovl\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000821 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000822 X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000823 TB;
824
825def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000826 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000827 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000828 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000829 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000830 TB, OpSize;
831def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000832 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000833 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000834 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000835 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000836 TB, OpSize;
837def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000838 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000839 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000840 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000841 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000842 TB;
843def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000844 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000845 "cmovge\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000846 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000847 X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000848 TB;
849
850def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000851 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000852 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000853 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000854 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000855 TB, OpSize;
856def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000857 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000858 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000859 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000860 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000861 TB, OpSize;
862def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000863 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000864 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000865 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000866 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000867 TB;
868def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000869 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000870 "cmovle\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000871 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000872 X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000873 TB;
874
875def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000876 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000877 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000878 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000879 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000880 TB, OpSize;
881def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000882 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000883 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000884 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000885 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000886 TB, OpSize;
887def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000888 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000889 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000890 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000891 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000892 TB;
893def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000894 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000895 "cmovg\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000896 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000897 X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000898 TB;
899
900def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000901 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000902 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000903 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000904 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000905 TB, OpSize;
906def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000907 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000908 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000909 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000910 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000911 TB, OpSize;
912def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000913 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000914 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000915 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000916 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000917 TB;
918def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000919 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000920 "cmovs\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000921 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000922 X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000923 TB;
924
925def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000926 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000927 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000928 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000929 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000930 TB, OpSize;
931def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000932 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000933 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000934 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000935 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000936 TB, OpSize;
937def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000938 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000939 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000940 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000941 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000942 TB;
943def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000944 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000945 "cmovns\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000946 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000947 X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000948 TB;
949
950def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000951 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000952 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000953 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000954 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000955 TB, OpSize;
956def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000957 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000958 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000959 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000960 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000961 TB, OpSize;
962def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000963 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000964 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000965 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000966 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000967 TB;
968def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000969 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000970 "cmovp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000971 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000972 X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000973 TB;
974
975def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, GR16 = GR16
Evan Chengb783fa32007-07-19 01:14:50 +0000976 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000977 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000978 [(set GR16:$dst, (X86cmov GR16:$src1, GR16:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000979 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000980 TB, OpSize;
981def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, GR16 = [mem16]
Evan Chengb783fa32007-07-19 01:14:50 +0000982 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000983 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000984 [(set GR16:$dst, (X86cmov GR16:$src1, (loadi16 addr:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +0000985 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000986 TB, OpSize;
987def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, GR32 = GR32
Evan Chengb783fa32007-07-19 01:14:50 +0000988 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000989 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000990 [(set GR32:$dst, (X86cmov GR32:$src1, GR32:$src2,
Evan Cheng621216e2007-09-29 00:00:36 +0000991 X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000992 TB;
993def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, GR32 = [mem32]
Evan Chengb783fa32007-07-19 01:14:50 +0000994 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +0000995 "cmovnp\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000996 [(set GR32:$dst, (X86cmov GR32:$src1, (loadi32 addr:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +0000997 X86_COND_NP, EFLAGS))]>,
998 TB;
999} // Uses = [EFLAGS]
1000
1001
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001002// unary instructions
1003let CodeSize = 2 in {
Evan Cheng55687072007-09-14 21:48:26 +00001004let Defs = [EFLAGS] in {
Dan Gohman91888f02007-07-31 20:11:57 +00001005def NEG8r : I<0xF6, MRM3r, (outs GR8 :$dst), (ins GR8 :$src), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001006 [(set GR8:$dst, (ineg GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001007def NEG16r : I<0xF7, MRM3r, (outs GR16:$dst), (ins GR16:$src), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001008 [(set GR16:$dst, (ineg GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001009def NEG32r : I<0xF7, MRM3r, (outs GR32:$dst), (ins GR32:$src), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001010 [(set GR32:$dst, (ineg GR32:$src))]>;
1011let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001012 def NEG8m : I<0xF6, MRM3m, (outs), (ins i8mem :$dst), "neg{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001013 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001014 def NEG16m : I<0xF7, MRM3m, (outs), (ins i16mem:$dst), "neg{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001015 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001016 def NEG32m : I<0xF7, MRM3m, (outs), (ins i32mem:$dst), "neg{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001017 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
1018
1019}
Evan Cheng55687072007-09-14 21:48:26 +00001020} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001021
Dan Gohman91888f02007-07-31 20:11:57 +00001022def NOT8r : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001023 [(set GR8:$dst, (not GR8:$src))]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001024def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001025 [(set GR16:$dst, (not GR16:$src))]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001026def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001027 [(set GR32:$dst, (not GR32:$src))]>;
1028let isTwoAddress = 0 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001029 def NOT8m : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001030 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001031 def NOT16m : I<0xF7, MRM2m, (outs), (ins i16mem:$dst), "not{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001032 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001033 def NOT32m : I<0xF7, MRM2m, (outs), (ins i32mem:$dst), "not{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001034 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
1035}
1036} // CodeSize
1037
1038// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Cheng55687072007-09-14 21:48:26 +00001039let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001040let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001041def INC8r : I<0xFE, MRM0r, (outs GR8 :$dst), (ins GR8 :$src), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001042 [(set GR8:$dst, (add GR8:$src, 1))]>;
1043let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001044def INC16r : I<0x40, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001045 [(set GR16:$dst, (add GR16:$src, 1))]>,
1046 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001047def INC32r : I<0x40, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001048 [(set GR32:$dst, (add GR32:$src, 1))]>, Requires<[In32BitMode]>;
1049}
1050let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001051 def INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), "inc{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001052 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001053 def INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001054 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001055 def INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001056 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
1057}
1058
1059let CodeSize = 2 in
Dan Gohman91888f02007-07-31 20:11:57 +00001060def DEC8r : I<0xFE, MRM1r, (outs GR8 :$dst), (ins GR8 :$src), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001061 [(set GR8:$dst, (add GR8:$src, -1))]>;
1062let isConvertibleToThreeAddress = 1, CodeSize = 1 in { // Can xform into LEA.
Dan Gohman91888f02007-07-31 20:11:57 +00001063def DEC16r : I<0x48, AddRegFrm, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001064 [(set GR16:$dst, (add GR16:$src, -1))]>,
1065 OpSize, Requires<[In32BitMode]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001066def DEC32r : I<0x48, AddRegFrm, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001067 [(set GR32:$dst, (add GR32:$src, -1))]>, Requires<[In32BitMode]>;
1068}
1069
1070let isTwoAddress = 0, CodeSize = 2 in {
Dan Gohman91888f02007-07-31 20:11:57 +00001071 def DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), "dec{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001072 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Dan Gohman91888f02007-07-31 20:11:57 +00001073 def DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001074 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Dan Gohman91888f02007-07-31 20:11:57 +00001075 def DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001076 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
1077}
Evan Cheng55687072007-09-14 21:48:26 +00001078} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001079
1080// Logical operators...
Evan Cheng55687072007-09-14 21:48:26 +00001081let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001082let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
1083def AND8rr : I<0x20, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001084 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001085 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001086 [(set GR8:$dst, (and GR8:$src1, GR8:$src2))]>;
1087def AND16rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001088 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001089 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001090 [(set GR16:$dst, (and GR16:$src1, GR16:$src2))]>, OpSize;
1091def AND32rr : I<0x21, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001092 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001093 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001094 [(set GR32:$dst, (and GR32:$src1, GR32:$src2))]>;
1095}
1096
1097def AND8rm : I<0x22, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001098 (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001099 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001100 [(set GR8:$dst, (and GR8:$src1, (load addr:$src2)))]>;
1101def AND16rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001102 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001103 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001104 [(set GR16:$dst, (and GR16:$src1, (load addr:$src2)))]>, OpSize;
1105def AND32rm : I<0x23, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001106 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001107 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001108 [(set GR32:$dst, (and GR32:$src1, (load addr:$src2)))]>;
1109
1110def AND8ri : Ii8<0x80, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001111 (outs GR8 :$dst), (ins GR8 :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001112 "and{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001113 [(set GR8:$dst, (and GR8:$src1, imm:$src2))]>;
1114def AND16ri : Ii16<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001115 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001116 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001117 [(set GR16:$dst, (and GR16:$src1, imm:$src2))]>, OpSize;
1118def AND32ri : Ii32<0x81, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001119 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001120 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001121 [(set GR32:$dst, (and GR32:$src1, imm:$src2))]>;
1122def AND16ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001123 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001124 "and{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001125 [(set GR16:$dst, (and GR16:$src1, i16immSExt8:$src2))]>,
1126 OpSize;
1127def AND32ri8 : Ii8<0x83, MRM4r,
Evan Chengb783fa32007-07-19 01:14:50 +00001128 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001129 "and{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001130 [(set GR32:$dst, (and GR32:$src1, i32immSExt8:$src2))]>;
1131
1132let isTwoAddress = 0 in {
1133 def AND8mr : I<0x20, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001134 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001135 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001136 [(store (and (load addr:$dst), GR8:$src), addr:$dst)]>;
1137 def AND16mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001138 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001139 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001140 [(store (and (load addr:$dst), GR16:$src), addr:$dst)]>,
1141 OpSize;
1142 def AND32mr : I<0x21, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001143 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001144 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001145 [(store (and (load addr:$dst), GR32:$src), addr:$dst)]>;
1146 def AND8mi : Ii8<0x80, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001147 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001148 "and{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001149 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1150 def AND16mi : Ii16<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001151 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001152 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001153 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1154 OpSize;
1155 def AND32mi : Ii32<0x81, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001156 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001157 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001158 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1159 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001160 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001161 "and{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001162 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1163 OpSize;
1164 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Chengb783fa32007-07-19 01:14:50 +00001165 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001166 "and{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001167 [(store (and (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1168}
1169
1170
1171let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001172def OR8rr : I<0x08, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001173 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001174 [(set GR8:$dst, (or GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001175def OR16rr : I<0x09, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001176 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001177 [(set GR16:$dst, (or GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001178def OR32rr : I<0x09, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001179 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001180 [(set GR32:$dst, (or GR32:$src1, GR32:$src2))]>;
1181}
Evan Chengb783fa32007-07-19 01:14:50 +00001182def OR8rm : I<0x0A, MRMSrcMem , (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001183 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001184 [(set GR8:$dst, (or GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001185def OR16rm : I<0x0B, MRMSrcMem , (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001186 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001187 [(set GR16:$dst, (or GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001188def OR32rm : I<0x0B, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001189 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001190 [(set GR32:$dst, (or GR32:$src1, (load addr:$src2)))]>;
1191
Evan Chengb783fa32007-07-19 01:14:50 +00001192def OR8ri : Ii8 <0x80, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001193 "or{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001194 [(set GR8:$dst, (or GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001195def OR16ri : Ii16<0x81, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001196 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001197 [(set GR16:$dst, (or GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001198def OR32ri : Ii32<0x81, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001199 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001200 [(set GR32:$dst, (or GR32:$src1, imm:$src2))]>;
1201
Evan Chengb783fa32007-07-19 01:14:50 +00001202def OR16ri8 : Ii8<0x83, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001203 "or{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001204 [(set GR16:$dst, (or GR16:$src1, i16immSExt8:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001205def OR32ri8 : Ii8<0x83, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001206 "or{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001207 [(set GR32:$dst, (or GR32:$src1, i32immSExt8:$src2))]>;
1208let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001209 def OR8mr : I<0x08, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001210 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001211 [(store (or (load addr:$dst), GR8:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001212 def OR16mr : I<0x09, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001213 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001214 [(store (or (load addr:$dst), GR16:$src), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001215 def OR32mr : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001216 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001217 [(store (or (load addr:$dst), GR32:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001218 def OR8mi : Ii8<0x80, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001219 "or{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001220 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001221 def OR16mi : Ii16<0x81, MRM1m, (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001222 "or{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001223 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1224 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001225 def OR32mi : Ii32<0x81, MRM1m, (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001226 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001227 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001228 def OR16mi8 : Ii8<0x83, MRM1m, (outs), (ins i16mem:$dst, i16i8imm:$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), i16immSExt8:$src), addr:$dst)]>,
1231 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001232 def OR32mi8 : Ii8<0x83, MRM1m, (outs), (ins i32mem:$dst, i32i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001233 "or{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001234 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1235}
1236
1237
1238let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
1239def XOR8rr : I<0x30, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001240 (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001241 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001242 [(set GR8:$dst, (xor GR8:$src1, GR8:$src2))]>;
1243def XOR16rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001244 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001245 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001246 [(set GR16:$dst, (xor GR16:$src1, GR16:$src2))]>, OpSize;
1247def XOR32rr : I<0x31, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001248 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001249 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001250 [(set GR32:$dst, (xor GR32:$src1, GR32:$src2))]>;
1251}
1252
1253def XOR8rm : I<0x32, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001254 (outs GR8 :$dst), (ins GR8:$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001255 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001256 [(set GR8:$dst, (xor GR8:$src1, (load addr:$src2)))]>;
1257def XOR16rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001258 (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001259 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001260 [(set GR16:$dst, (xor GR16:$src1, (load addr:$src2)))]>, OpSize;
1261def XOR32rm : I<0x33, MRMSrcMem ,
Evan Chengb783fa32007-07-19 01:14:50 +00001262 (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001263 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001264 [(set GR32:$dst, (xor GR32:$src1, (load addr:$src2)))]>;
1265
1266def XOR8ri : Ii8<0x80, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001267 (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001268 "xor{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001269 [(set GR8:$dst, (xor GR8:$src1, imm:$src2))]>;
1270def XOR16ri : Ii16<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001271 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001272 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001273 [(set GR16:$dst, (xor GR16:$src1, imm:$src2))]>, OpSize;
1274def XOR32ri : Ii32<0x81, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001275 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001276 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001277 [(set GR32:$dst, (xor GR32:$src1, imm:$src2))]>;
1278def XOR16ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001279 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001280 "xor{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001281 [(set GR16:$dst, (xor GR16:$src1, i16immSExt8:$src2))]>,
1282 OpSize;
1283def XOR32ri8 : Ii8<0x83, MRM6r,
Evan Chengb783fa32007-07-19 01:14:50 +00001284 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001285 "xor{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001286 [(set GR32:$dst, (xor GR32:$src1, i32immSExt8:$src2))]>;
1287let isTwoAddress = 0 in {
1288 def XOR8mr : I<0x30, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001289 (outs), (ins i8mem :$dst, GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001290 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001291 [(store (xor (load addr:$dst), GR8:$src), addr:$dst)]>;
1292 def XOR16mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001293 (outs), (ins i16mem:$dst, GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001294 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001295 [(store (xor (load addr:$dst), GR16:$src), addr:$dst)]>,
1296 OpSize;
1297 def XOR32mr : I<0x31, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001298 (outs), (ins i32mem:$dst, GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001299 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001300 [(store (xor (load addr:$dst), GR32:$src), addr:$dst)]>;
1301 def XOR8mi : Ii8<0x80, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001302 (outs), (ins i8mem :$dst, i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001303 "xor{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001304 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
1305 def XOR16mi : Ii16<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001306 (outs), (ins i16mem:$dst, i16imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001307 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001308 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
1309 OpSize;
1310 def XOR32mi : Ii32<0x81, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001311 (outs), (ins i32mem:$dst, i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001312 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001313 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
1314 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001315 (outs), (ins i16mem:$dst, i16i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001316 "xor{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001317 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
1318 OpSize;
1319 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Chengb783fa32007-07-19 01:14:50 +00001320 (outs), (ins i32mem:$dst, i32i8imm :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001321 "xor{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001322 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
1323}
Evan Cheng55687072007-09-14 21:48:26 +00001324} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001325
1326// Shift instructions
Evan Cheng55687072007-09-14 21:48:26 +00001327let Defs = [EFLAGS] in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001328let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001329def SHL8rCL : I<0xD2, MRM4r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001330 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001331 [(set GR8:$dst, (shl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001332def SHL16rCL : I<0xD3, MRM4r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001333 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001334 [(set GR16:$dst, (shl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001335def SHL32rCL : I<0xD3, MRM4r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001336 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001337 [(set GR32:$dst, (shl GR32:$src, CL))]>;
1338}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001339
Evan Chengb783fa32007-07-19 01:14:50 +00001340def SHL8ri : Ii8<0xC0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001341 "shl{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001342 [(set GR8:$dst, (shl GR8:$src1, (i8 imm:$src2)))]>;
1343let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb783fa32007-07-19 01:14:50 +00001344def SHL16ri : Ii8<0xC1, MRM4r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001345 "shl{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001346 [(set GR16:$dst, (shl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001347def SHL32ri : Ii8<0xC1, MRM4r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001348 "shl{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001349 [(set GR32:$dst, (shl GR32:$src1, (i8 imm:$src2)))]>;
1350}
1351
1352// Shift left by one. Not used because (add x, x) is slightly cheaper.
Evan Chengb783fa32007-07-19 01:14:50 +00001353def SHL8r1 : I<0xD0, MRM4r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001354 "shl{b}\t$dst", []>;
Evan Chengb783fa32007-07-19 01:14:50 +00001355def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001356 "shl{w}\t$dst", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001357def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001358 "shl{l}\t$dst", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001359
1360let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001361 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001362 def SHL8mCL : I<0xD2, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001363 "shl{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001364 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001365 def SHL16mCL : I<0xD3, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001366 "shl{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001367 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001368 def SHL32mCL : I<0xD3, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001369 "shl{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001370 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>;
1371 }
Evan Chengb783fa32007-07-19 01:14:50 +00001372 def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001373 "shl{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001374 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001375 def SHL16mi : Ii8<0xC1, MRM4m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001376 "shl{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001377 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1378 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001379 def SHL32mi : Ii8<0xC1, MRM4m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001380 "shl{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001381 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1382
1383 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001384 def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001385 "shl{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001386 [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001387 def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001388 "shl{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001389 [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1390 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001391 def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001392 "shl{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001393 [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1394}
1395
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001396let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001397def SHR8rCL : I<0xD2, MRM5r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001398 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001399 [(set GR8:$dst, (srl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001400def SHR16rCL : I<0xD3, MRM5r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001401 "shr{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001402 [(set GR16:$dst, (srl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001403def SHR32rCL : I<0xD3, MRM5r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001404 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001405 [(set GR32:$dst, (srl GR32:$src, CL))]>;
1406}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001407
Evan Chengb783fa32007-07-19 01:14:50 +00001408def SHR8ri : Ii8<0xC0, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001409 "shr{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001410 [(set GR8:$dst, (srl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001411def SHR16ri : Ii8<0xC1, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001412 "shr{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001413 [(set GR16:$dst, (srl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001414def SHR32ri : Ii8<0xC1, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001415 "shr{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001416 [(set GR32:$dst, (srl GR32:$src1, (i8 imm:$src2)))]>;
1417
1418// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001419def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001420 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001421 [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001422def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001423 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001424 [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001425def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001426 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001427 [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>;
1428
1429let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001430 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001431 def SHR8mCL : I<0xD2, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001432 "shr{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001433 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001434 def SHR16mCL : I<0xD3, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001435 "shr{w}\t{%cl, $dst|$dst, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001436 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001437 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001438 def SHR32mCL : I<0xD3, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001439 "shr{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001440 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>;
1441 }
Evan Chengb783fa32007-07-19 01:14:50 +00001442 def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001443 "shr{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001444 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001445 def SHR16mi : Ii8<0xC1, MRM5m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001446 "shr{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001447 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1448 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001449 def SHR32mi : Ii8<0xC1, MRM5m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001450 "shr{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001451 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1452
1453 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001454 def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001455 "shr{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001456 [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001457 def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001458 "shr{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001459 [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001460 def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001461 "shr{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001462 [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1463}
1464
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001465let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001466def SAR8rCL : I<0xD2, MRM7r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001467 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001468 [(set GR8:$dst, (sra GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001469def SAR16rCL : I<0xD3, MRM7r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001470 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001471 [(set GR16:$dst, (sra GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001472def SAR32rCL : I<0xD3, MRM7r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001473 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001474 [(set GR32:$dst, (sra GR32:$src, CL))]>;
1475}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001476
Evan Chengb783fa32007-07-19 01:14:50 +00001477def SAR8ri : Ii8<0xC0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001478 "sar{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001479 [(set GR8:$dst, (sra GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001480def SAR16ri : Ii8<0xC1, MRM7r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001481 "sar{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001482 [(set GR16:$dst, (sra GR16:$src1, (i8 imm:$src2)))]>,
1483 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001484def SAR32ri : Ii8<0xC1, MRM7r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001485 "sar{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001486 [(set GR32:$dst, (sra GR32:$src1, (i8 imm:$src2)))]>;
1487
1488// Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001489def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001490 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001491 [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001492def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001493 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001494 [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001495def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001496 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001497 [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>;
1498
1499let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001500 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001501 def SAR8mCL : I<0xD2, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001502 "sar{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001503 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001504 def SAR16mCL : I<0xD3, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001505 "sar{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001506 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001507 def SAR32mCL : I<0xD3, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001508 "sar{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001509 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>;
1510 }
Evan Chengb783fa32007-07-19 01:14:50 +00001511 def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001512 "sar{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001513 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001514 def SAR16mi : Ii8<0xC1, MRM7m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001515 "sar{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001516 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1517 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001518 def SAR32mi : Ii8<0xC1, MRM7m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001519 "sar{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001520 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1521
1522 // Shift by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001523 def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001524 "sar{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001525 [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001526 def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001527 "sar{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001528 [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1529 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001530 def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001531 "sar{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001532 [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1533}
1534
1535// Rotate instructions
1536// FIXME: provide shorter instructions when imm8 == 1
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001537let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001538def ROL8rCL : I<0xD2, MRM0r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001539 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001540 [(set GR8:$dst, (rotl GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001541def ROL16rCL : I<0xD3, MRM0r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001542 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001543 [(set GR16:$dst, (rotl GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001544def ROL32rCL : I<0xD3, MRM0r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001545 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001546 [(set GR32:$dst, (rotl GR32:$src, CL))]>;
1547}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001548
Evan Chengb783fa32007-07-19 01:14:50 +00001549def ROL8ri : Ii8<0xC0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001550 "rol{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001551 [(set GR8:$dst, (rotl GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001552def ROL16ri : Ii8<0xC1, MRM0r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001553 "rol{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001554 [(set GR16:$dst, (rotl GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001555def ROL32ri : Ii8<0xC1, MRM0r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001556 "rol{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001557 [(set GR32:$dst, (rotl GR32:$src1, (i8 imm:$src2)))]>;
1558
1559// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001560def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001561 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001562 [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001563def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001564 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001565 [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001566def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001567 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001568 [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>;
1569
1570let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001571 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001572 def ROL8mCL : I<0xD2, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001573 "rol{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001574 [(store (rotl (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001575 def ROL16mCL : I<0xD3, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001576 "rol{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001577 [(store (rotl (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001578 def ROL32mCL : I<0xD3, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001579 "rol{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001580 [(store (rotl (loadi32 addr:$dst), CL), addr:$dst)]>;
1581 }
Evan Chengb783fa32007-07-19 01:14:50 +00001582 def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001583 "rol{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001584 [(store (rotl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001585 def ROL16mi : Ii8<0xC1, MRM0m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001586 "rol{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001587 [(store (rotl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1588 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001589 def ROL32mi : Ii8<0xC1, MRM0m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001590 "rol{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001591 [(store (rotl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1592
1593 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001594 def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001595 "rol{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001596 [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001597 def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001598 "rol{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001599 [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1600 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001601 def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001602 "rol{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001603 [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1604}
1605
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001606let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001607def ROR8rCL : I<0xD2, MRM1r, (outs GR8 :$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001608 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001609 [(set GR8:$dst, (rotr GR8:$src, CL))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001610def ROR16rCL : I<0xD3, MRM1r, (outs GR16:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001611 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001612 [(set GR16:$dst, (rotr GR16:$src, CL))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001613def ROR32rCL : I<0xD3, MRM1r, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001614 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001615 [(set GR32:$dst, (rotr GR32:$src, CL))]>;
1616}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001617
Evan Chengb783fa32007-07-19 01:14:50 +00001618def ROR8ri : Ii8<0xC0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001619 "ror{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001620 [(set GR8:$dst, (rotr GR8:$src1, (i8 imm:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001621def ROR16ri : Ii8<0xC1, MRM1r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001622 "ror{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001623 [(set GR16:$dst, (rotr GR16:$src1, (i8 imm:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001624def ROR32ri : Ii8<0xC1, MRM1r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001625 "ror{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001626 [(set GR32:$dst, (rotr GR32:$src1, (i8 imm:$src2)))]>;
1627
1628// Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001629def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001630 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001631 [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001632def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001633 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001634 [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001635def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
Dan Gohman91888f02007-07-31 20:11:57 +00001636 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001637 [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>;
1638
1639let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001640 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001641 def ROR8mCL : I<0xD2, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001642 "ror{b}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001643 [(store (rotr (loadi8 addr:$dst), CL), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001644 def ROR16mCL : I<0xD3, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001645 "ror{w}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001646 [(store (rotr (loadi16 addr:$dst), CL), addr:$dst)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001647 def ROR32mCL : I<0xD3, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001648 "ror{l}\t{%cl, $dst|$dst, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001649 [(store (rotr (loadi32 addr:$dst), CL), addr:$dst)]>;
1650 }
Evan Chengb783fa32007-07-19 01:14:50 +00001651 def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001652 "ror{b}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001653 [(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001654 def ROR16mi : Ii8<0xC1, MRM1m, (outs), (ins i16mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001655 "ror{w}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001656 [(store (rotr (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1657 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001658 def ROR32mi : Ii8<0xC1, MRM1m, (outs), (ins i32mem:$dst, i8imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00001659 "ror{l}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001660 [(store (rotr (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
1661
1662 // Rotate by 1
Evan Chengb783fa32007-07-19 01:14:50 +00001663 def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001664 "ror{b}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001665 [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001666 def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001667 "ror{w}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001668 [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
1669 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001670 def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00001671 "ror{l}\t$dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001672 [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>;
1673}
1674
1675
1676
1677// Double shift instructions (generalizations of rotate)
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001678let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001679def SHLD32rrCL : I<0xA5, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001680 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001681 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001682def SHRD32rrCL : I<0xAD, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001683 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001684 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2, CL))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001685def SHLD16rrCL : I<0xA5, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001686 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001687 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001688 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001689def SHRD16rrCL : I<0xAD, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001690 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001691 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2, CL))]>,
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001692 TB, OpSize;
1693}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001694
1695let isCommutable = 1 in { // These instructions commute to each other.
1696def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001697 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001698 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001699 [(set GR32:$dst, (X86shld GR32:$src1, GR32:$src2,
1700 (i8 imm:$src3)))]>,
1701 TB;
1702def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001703 (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001704 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001705 [(set GR32:$dst, (X86shrd GR32:$src1, GR32:$src2,
1706 (i8 imm:$src3)))]>,
1707 TB;
1708def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001709 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001710 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001711 [(set GR16:$dst, (X86shld GR16:$src1, GR16:$src2,
1712 (i8 imm:$src3)))]>,
1713 TB, OpSize;
1714def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00001715 (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001716 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001717 [(set GR16:$dst, (X86shrd GR16:$src1, GR16:$src2,
1718 (i8 imm:$src3)))]>,
1719 TB, OpSize;
1720}
1721
1722let isTwoAddress = 0 in {
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001723 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001724 def SHLD32mrCL : I<0xA5, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001725 "shld{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001726 [(store (X86shld (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001727 addr:$dst)]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00001728 def SHRD32mrCL : I<0xAD, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001729 "shrd{l}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001730 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001731 addr:$dst)]>, TB;
1732 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001733 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001734 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001735 "shld{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001736 [(store (X86shld (loadi32 addr:$dst), GR32:$src2,
1737 (i8 imm:$src3)), addr:$dst)]>,
1738 TB;
1739 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001740 (outs), (ins i32mem:$dst, GR32:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001741 "shrd{l}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001742 [(store (X86shrd (loadi32 addr:$dst), GR32:$src2,
1743 (i8 imm:$src3)), addr:$dst)]>,
1744 TB;
1745
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001746 let Uses = [CL] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001747 def SHLD16mrCL : I<0xA5, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001748 "shld{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001749 [(store (X86shld (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001750 addr:$dst)]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001751 def SHRD16mrCL : I<0xAD, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001752 "shrd{w}\t{%cl, $src2, $dst|$dst, $src2, %CL}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001753 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2, CL),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001754 addr:$dst)]>, TB, OpSize;
1755 }
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001756 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001757 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001758 "shld{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001759 [(store (X86shld (loadi16 addr:$dst), GR16:$src2,
1760 (i8 imm:$src3)), addr:$dst)]>,
1761 TB, OpSize;
1762 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00001763 (outs), (ins i16mem:$dst, GR16:$src2, i8imm:$src3),
Dan Gohman91888f02007-07-31 20:11:57 +00001764 "shrd{w}\t{$src3, $src2, $dst|$dst, $src2, $src3}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001765 [(store (X86shrd (loadi16 addr:$dst), GR16:$src2,
1766 (i8 imm:$src3)), addr:$dst)]>,
1767 TB, OpSize;
1768}
Evan Cheng55687072007-09-14 21:48:26 +00001769} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001770
1771
1772// Arithmetic.
Evan Cheng55687072007-09-14 21:48:26 +00001773let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001774let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001775def ADD8rr : I<0x00, MRMDestReg, (outs GR8 :$dst),
1776 (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001777 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001778 [(set GR8:$dst, (add GR8:$src1, GR8:$src2))]>;
1779let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001780def ADD16rr : I<0x01, MRMDestReg, (outs GR16:$dst),
1781 (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001782 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001783 [(set GR16:$dst, (add GR16:$src1, GR16:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001784def ADD32rr : I<0x01, MRMDestReg, (outs GR32:$dst),
1785 (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001786 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001787 [(set GR32:$dst, (add GR32:$src1, GR32:$src2))]>;
1788} // end isConvertibleToThreeAddress
1789} // end isCommutable
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001790def ADD8rm : I<0x02, MRMSrcMem, (outs GR8 :$dst),
1791 (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001792 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001793 [(set GR8:$dst, (add GR8:$src1, (load addr:$src2)))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001794def ADD16rm : I<0x03, MRMSrcMem, (outs GR16:$dst),
1795 (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001796 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001797 [(set GR16:$dst, (add GR16:$src1, (load addr:$src2)))]>,OpSize;
1798def ADD32rm : I<0x03, MRMSrcMem, (outs GR32:$dst),
1799 (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001800 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001801 [(set GR32:$dst, (add GR32:$src1, (load addr:$src2)))]>;
1802
Evan Chengb783fa32007-07-19 01:14:50 +00001803def ADD8ri : Ii8<0x80, MRM0r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001804 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001805 [(set GR8:$dst, (add GR8:$src1, imm:$src2))]>;
1806
1807let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001808def ADD16ri : Ii16<0x81, MRM0r, (outs GR16:$dst),
1809 (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001810 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001811 [(set GR16:$dst, (add GR16:$src1, imm:$src2))]>, OpSize;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001812def ADD32ri : Ii32<0x81, MRM0r, (outs GR32:$dst),
1813 (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001814 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001815 [(set GR32:$dst, (add GR32:$src1, imm:$src2))]>;
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001816def ADD16ri8 : Ii8<0x83, MRM0r, (outs GR16:$dst),
1817 (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001818 "add{w}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001819 [(set GR16:$dst, (add GR16:$src1, i16immSExt8:$src2))]>, OpSize;
1820def ADD32ri8 : Ii8<0x83, MRM0r, (outs GR32:$dst),
1821 (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001822 "add{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00001823 [(set GR32:$dst, (add GR32:$src1, i32immSExt8:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001824}
1825
1826let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001827 def ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001828 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001829 [(store (add (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001830 def ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001831 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001832 [(store (add (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001833 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001834 def ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001835 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001836 [(store (add (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001837 def ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001838 "add{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001839 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001840 def ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001841 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001842 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001843 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001844 def ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001845 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001846 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001847 def ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001848 "add{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001849 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001850 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001851 def ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001852 "add{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001853 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1854}
1855
Evan Cheng259471d2007-10-05 17:59:57 +00001856let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001857let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001858def ADC32rr : I<0x11, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001859 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001860 [(set GR32:$dst, (adde GR32:$src1, GR32:$src2))]>;
1861}
Evan Chengb783fa32007-07-19 01:14:50 +00001862def ADC32rm : I<0x13, MRMSrcMem , (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001863 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001864 [(set GR32:$dst, (adde GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001865def ADC32ri : Ii32<0x81, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001866 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001867 [(set GR32:$dst, (adde GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001868def ADC32ri8 : Ii8<0x83, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001869 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001870 [(set GR32:$dst, (adde GR32:$src1, i32immSExt8:$src2))]>;
1871
1872let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001873 def ADC32mr : I<0x11, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001874 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001875 [(store (adde (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001876 def ADC32mi : Ii32<0x81, MRM2m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001877 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001878 [(store (adde (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001879 def ADC32mi8 : Ii8<0x83, MRM2m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001880 "adc{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001881 [(store (adde (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1882}
Evan Cheng259471d2007-10-05 17:59:57 +00001883} // Uses = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001884
Evan Chengb783fa32007-07-19 01:14:50 +00001885def SUB8rr : I<0x28, MRMDestReg, (outs GR8 :$dst), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001886 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001887 [(set GR8:$dst, (sub GR8:$src1, GR8:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001888def SUB16rr : I<0x29, MRMDestReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001889 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001890 [(set GR16:$dst, (sub GR16:$src1, GR16:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001891def SUB32rr : I<0x29, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001892 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001893 [(set GR32:$dst, (sub GR32:$src1, GR32:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001894def SUB8rm : I<0x2A, MRMSrcMem, (outs GR8 :$dst), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001895 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001896 [(set GR8:$dst, (sub GR8:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001897def SUB16rm : I<0x2B, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001898 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001899 [(set GR16:$dst, (sub GR16:$src1, (load addr:$src2)))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001900def SUB32rm : I<0x2B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001901 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001902 [(set GR32:$dst, (sub GR32:$src1, (load addr:$src2)))]>;
1903
Evan Chengb783fa32007-07-19 01:14:50 +00001904def SUB8ri : Ii8 <0x80, MRM5r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001905 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001906 [(set GR8:$dst, (sub GR8:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001907def SUB16ri : Ii16<0x81, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001908 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001909 [(set GR16:$dst, (sub GR16:$src1, imm:$src2))]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001910def SUB32ri : Ii32<0x81, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001911 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001912 [(set GR32:$dst, (sub GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001913def SUB16ri8 : Ii8<0x83, MRM5r, (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$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, i16immSExt8:$src2))]>,
Evan Cheng55687072007-09-14 21:48:26 +00001916 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001917def SUB32ri8 : Ii8<0x83, MRM5r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001918 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001919 [(set GR32:$dst, (sub GR32:$src1, i32immSExt8:$src2))]>;
1920let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001921 def SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001922 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001923 [(store (sub (load addr:$dst), GR8:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001924 def SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001925 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001926 [(store (sub (load addr:$dst), GR16:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001927 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001928 def SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001929 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001930 [(store (sub (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001931 def SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001932 "sub{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001933 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001934 def SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001935 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001936 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001937 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001938 def SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001939 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001940 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001941 def SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001942 "sub{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001943 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
Evan Cheng55687072007-09-14 21:48:26 +00001944 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001945 def SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001946 "sub{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001947 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
1948}
1949
Evan Cheng259471d2007-10-05 17:59:57 +00001950let Uses = [EFLAGS] in {
Evan Chengb783fa32007-07-19 01:14:50 +00001951def SBB32rr : I<0x19, MRMDestReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001952 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00001953 [(set GR32:$dst, (sube GR32:$src1, GR32:$src2))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001954
1955let isTwoAddress = 0 in {
Evan Chengb783fa32007-07-19 01:14:50 +00001956 def SBB32mr : I<0x19, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001957 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001958 [(store (sube (load addr:$dst), GR32:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001959 def SBB8mi : Ii32<0x80, MRM3m, (outs), (ins i8mem:$dst, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001960 "sbb{b}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001961 [(store (sube (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001962 def SBB32mi : Ii32<0x81, MRM3m, (outs), (ins i32mem:$dst, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001963 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001964 [(store (sube (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001965 def SBB32mi8 : Ii8<0x83, MRM3m, (outs), (ins i32mem:$dst, i32i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001966 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Evan Cheng55687072007-09-14 21:48:26 +00001967 [(store (sube (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001968}
Evan Chengb783fa32007-07-19 01:14:50 +00001969def SBB32rm : I<0x1B, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001970 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001971 [(set GR32:$dst, (sube GR32:$src1, (load addr:$src2)))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001972def SBB32ri : Ii32<0x81, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001973 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001974 [(set GR32:$dst, (sube GR32:$src1, imm:$src2))]>;
Evan Chengb783fa32007-07-19 01:14:50 +00001975def SBB32ri8 : Ii8<0x83, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001976 "sbb{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001977 [(set GR32:$dst, (sube GR32:$src1, i32immSExt8:$src2))]>;
Evan Cheng259471d2007-10-05 17:59:57 +00001978} // Uses = [EFLAGS]
Evan Cheng55687072007-09-14 21:48:26 +00001979} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001980
Evan Cheng55687072007-09-14 21:48:26 +00001981let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001982let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Evan Chengb783fa32007-07-19 01:14:50 +00001983def IMUL16rr : I<0xAF, MRMSrcReg, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001984 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001985 [(set GR16:$dst, (mul GR16:$src1, GR16:$src2))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001986def IMUL32rr : I<0xAF, MRMSrcReg, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001987 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001988 [(set GR32:$dst, (mul GR32:$src1, GR32:$src2))]>, TB;
1989}
Evan Chengb783fa32007-07-19 01:14:50 +00001990def IMUL16rm : I<0xAF, MRMSrcMem, (outs GR16:$dst), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001991 "imul{w}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001992 [(set GR16:$dst, (mul GR16:$src1, (load addr:$src2)))]>,
1993 TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00001994def IMUL32rm : I<0xAF, MRMSrcMem, (outs GR32:$dst), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00001995 "imul{l}\t{$src2, $dst|$dst, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001996 [(set GR32:$dst, (mul GR32:$src1, (load addr:$src2)))]>, TB;
Evan Cheng55687072007-09-14 21:48:26 +00001997} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001998} // end Two Address instructions
1999
2000// Suprisingly enough, these are not two address instructions!
Evan Cheng55687072007-09-14 21:48:26 +00002001let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002002def IMUL16rri : Ii16<0x69, MRMSrcReg, // GR16 = GR16*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002003 (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002004 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002005 [(set GR16:$dst, (mul GR16:$src1, imm:$src2))]>, OpSize;
2006def IMUL32rri : Ii32<0x69, MRMSrcReg, // GR32 = GR32*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002007 (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002008 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002009 [(set GR32:$dst, (mul GR32:$src1, imm:$src2))]>;
2010def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // GR16 = GR16*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002011 (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002012 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002013 [(set GR16:$dst, (mul GR16:$src1, i16immSExt8:$src2))]>,
2014 OpSize;
2015def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // GR32 = GR32*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002016 (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002017 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002018 [(set GR32:$dst, (mul GR32:$src1, i32immSExt8:$src2))]>;
2019
2020def IMUL16rmi : Ii16<0x69, MRMSrcMem, // GR16 = [mem16]*I16
Evan Chengb783fa32007-07-19 01:14:50 +00002021 (outs GR16:$dst), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002022 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002023 [(set GR16:$dst, (mul (load addr:$src1), imm:$src2))]>,
2024 OpSize;
2025def IMUL32rmi : Ii32<0x69, MRMSrcMem, // GR32 = [mem32]*I32
Evan Chengb783fa32007-07-19 01:14:50 +00002026 (outs GR32:$dst), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002027 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002028 [(set GR32:$dst, (mul (load addr:$src1), imm:$src2))]>;
2029def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // GR16 = [mem16]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002030 (outs GR16:$dst), (ins i16mem:$src1, i16i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002031 "imul{w}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002032 [(set GR16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
2033 OpSize;
2034def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // GR32 = [mem32]*I8
Evan Chengb783fa32007-07-19 01:14:50 +00002035 (outs GR32:$dst), (ins i32mem:$src1, i32i8imm: $src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002036 "imul{l}\t{$src2, $src1, $dst|$dst, $src1, $src2}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002037 [(set GR32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Evan Cheng55687072007-09-14 21:48:26 +00002038} // Defs = [EFLAGS]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002039
2040//===----------------------------------------------------------------------===//
2041// Test instructions are just like AND, except they don't generate a result.
2042//
Evan Cheng950aac02007-09-25 01:57:46 +00002043let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002044let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Evan Chengb783fa32007-07-19 01:14:50 +00002045def TEST8rr : I<0x84, MRMDestReg, (outs), (ins GR8:$src1, GR8:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002046 "test{b}\t{$src2, $src1|$src1, $src2}",
2047 [(X86cmp (and GR8:$src1, GR8:$src2), 0),
2048 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002049def TEST16rr : I<0x85, MRMDestReg, (outs), (ins GR16:$src1, GR16:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002050 "test{w}\t{$src2, $src1|$src1, $src2}",
2051 [(X86cmp (and GR16:$src1, GR16:$src2), 0),
2052 (implicit EFLAGS)]>,
2053 OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002054def TEST32rr : I<0x85, MRMDestReg, (outs), (ins GR32:$src1, GR32:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002055 "test{l}\t{$src2, $src1|$src1, $src2}",
2056 [(X86cmp (and GR32:$src1, GR32:$src2), 0),
2057 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002058}
2059
Evan Chengb783fa32007-07-19 01:14:50 +00002060def TEST8rm : I<0x84, MRMSrcMem, (outs), (ins GR8 :$src1, i8mem :$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002061 "test{b}\t{$src2, $src1|$src1, $src2}",
2062 [(X86cmp (and GR8:$src1, (loadi8 addr:$src2)), 0),
2063 (implicit EFLAGS)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002064def TEST16rm : I<0x85, MRMSrcMem, (outs), (ins GR16:$src1, i16mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002065 "test{w}\t{$src2, $src1|$src1, $src2}",
2066 [(X86cmp (and GR16:$src1, (loadi16 addr:$src2)), 0),
2067 (implicit EFLAGS)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002068def TEST32rm : I<0x85, MRMSrcMem, (outs), (ins GR32:$src1, i32mem:$src2),
Evan Cheng621216e2007-09-29 00:00:36 +00002069 "test{l}\t{$src2, $src1|$src1, $src2}",
2070 [(X86cmp (and GR32:$src1, (loadi32 addr:$src2)), 0),
2071 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002072
2073def TEST8ri : Ii8 <0xF6, MRM0r, // flags = GR8 & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002074 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002075 "test{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002076 [(X86cmp (and GR8:$src1, imm:$src2), 0),
2077 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002078def TEST16ri : Ii16<0xF7, MRM0r, // flags = GR16 & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002079 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002080 "test{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002081 [(X86cmp (and GR16:$src1, imm:$src2), 0),
2082 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002083def TEST32ri : Ii32<0xF7, MRM0r, // flags = GR32 & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002084 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002085 "test{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002086 [(X86cmp (and GR32:$src1, imm:$src2), 0),
2087 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002088
Evan Cheng621216e2007-09-29 00:00:36 +00002089def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
Evan Chengb783fa32007-07-19 01:14:50 +00002090 (outs), (ins i8mem:$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 (loadi8 addr:$src1), imm:$src2), 0),
2093 (implicit EFLAGS)]>;
2094def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
Evan Chengb783fa32007-07-19 01:14:50 +00002095 (outs), (ins i16mem:$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 (loadi16 addr:$src1), imm:$src2), 0),
2098 (implicit EFLAGS)]>, OpSize;
2099def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
Evan Chengb783fa32007-07-19 01:14:50 +00002100 (outs), (ins i32mem:$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 (loadi32 addr:$src1), imm:$src2), 0),
Evan Cheng950aac02007-09-25 01:57:46 +00002103 (implicit EFLAGS)]>;
2104} // Defs = [EFLAGS]
2105
2106
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002107// Condition code ops, incl. set if equal/not equal/...
Evan Cheng55687072007-09-14 21:48:26 +00002108let Defs = [EFLAGS], Uses = [AH] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002109def SAHF : I<0x9E, RawFrm, (outs), (ins), "sahf", []>; // flags = AH
Evan Cheng55687072007-09-14 21:48:26 +00002110let Defs = [AH], Uses = [EFLAGS] in
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002111def LAHF : I<0x9F, RawFrm, (outs), (ins), "lahf", []>; // AH = flags
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002112
Evan Cheng950aac02007-09-25 01:57:46 +00002113let Uses = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002114def SETEr : I<0x94, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002115 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002116 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002117 [(set GR8:$dst, (X86setcc X86_COND_E, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002118 TB; // GR8 = ==
2119def SETEm : I<0x94, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002120 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002121 "sete\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002122 [(store (X86setcc X86_COND_E, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002123 TB; // [mem8] = ==
2124def SETNEr : I<0x95, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002125 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002126 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002127 [(set GR8:$dst, (X86setcc X86_COND_NE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002128 TB; // GR8 = !=
2129def SETNEm : I<0x95, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002130 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002131 "setne\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002132 [(store (X86setcc X86_COND_NE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002133 TB; // [mem8] = !=
2134def SETLr : I<0x9C, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002135 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002136 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002137 [(set GR8:$dst, (X86setcc X86_COND_L, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002138 TB; // GR8 = < signed
2139def SETLm : I<0x9C, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002140 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002141 "setl\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002142 [(store (X86setcc X86_COND_L, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002143 TB; // [mem8] = < signed
2144def SETGEr : I<0x9D, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002145 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002146 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002147 [(set GR8:$dst, (X86setcc X86_COND_GE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002148 TB; // GR8 = >= signed
2149def SETGEm : I<0x9D, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002150 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002151 "setge\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002152 [(store (X86setcc X86_COND_GE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002153 TB; // [mem8] = >= signed
2154def SETLEr : I<0x9E, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002155 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002156 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002157 [(set GR8:$dst, (X86setcc X86_COND_LE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002158 TB; // GR8 = <= signed
2159def SETLEm : I<0x9E, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002160 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002161 "setle\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002162 [(store (X86setcc X86_COND_LE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002163 TB; // [mem8] = <= signed
2164def SETGr : I<0x9F, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002165 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002166 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002167 [(set GR8:$dst, (X86setcc X86_COND_G, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002168 TB; // GR8 = > signed
2169def SETGm : I<0x9F, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002170 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002171 "setg\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002172 [(store (X86setcc X86_COND_G, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002173 TB; // [mem8] = > signed
2174
2175def SETBr : I<0x92, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002176 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002177 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002178 [(set GR8:$dst, (X86setcc X86_COND_B, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002179 TB; // GR8 = < unsign
2180def SETBm : I<0x92, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002181 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002182 "setb\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002183 [(store (X86setcc X86_COND_B, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002184 TB; // [mem8] = < unsign
2185def SETAEr : I<0x93, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002186 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002187 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002188 [(set GR8:$dst, (X86setcc X86_COND_AE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002189 TB; // GR8 = >= unsign
2190def SETAEm : I<0x93, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002191 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002192 "setae\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002193 [(store (X86setcc X86_COND_AE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002194 TB; // [mem8] = >= unsign
2195def SETBEr : I<0x96, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002196 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002197 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002198 [(set GR8:$dst, (X86setcc X86_COND_BE, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002199 TB; // GR8 = <= unsign
2200def SETBEm : I<0x96, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002201 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002202 "setbe\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002203 [(store (X86setcc X86_COND_BE, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002204 TB; // [mem8] = <= unsign
2205def SETAr : I<0x97, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002206 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002207 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002208 [(set GR8:$dst, (X86setcc X86_COND_A, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002209 TB; // GR8 = > signed
2210def SETAm : I<0x97, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002211 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002212 "seta\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002213 [(store (X86setcc X86_COND_A, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002214 TB; // [mem8] = > signed
2215
2216def SETSr : I<0x98, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002217 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002218 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002219 [(set GR8:$dst, (X86setcc X86_COND_S, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002220 TB; // GR8 = <sign bit>
2221def SETSm : I<0x98, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002222 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002223 "sets\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002224 [(store (X86setcc X86_COND_S, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002225 TB; // [mem8] = <sign bit>
2226def SETNSr : I<0x99, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002227 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002228 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002229 [(set GR8:$dst, (X86setcc X86_COND_NS, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002230 TB; // GR8 = !<sign bit>
2231def SETNSm : I<0x99, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002232 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002233 "setns\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002234 [(store (X86setcc X86_COND_NS, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002235 TB; // [mem8] = !<sign bit>
2236def SETPr : I<0x9A, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002237 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002238 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002239 [(set GR8:$dst, (X86setcc X86_COND_P, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002240 TB; // GR8 = parity
2241def SETPm : I<0x9A, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002242 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002243 "setp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002244 [(store (X86setcc X86_COND_P, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002245 TB; // [mem8] = parity
2246def SETNPr : I<0x9B, MRM0r,
Evan Chengb783fa32007-07-19 01:14:50 +00002247 (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002248 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002249 [(set GR8:$dst, (X86setcc X86_COND_NP, EFLAGS))]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002250 TB; // GR8 = not parity
2251def SETNPm : I<0x9B, MRM0m,
Evan Chengb783fa32007-07-19 01:14:50 +00002252 (outs), (ins i8mem:$dst),
Dan Gohman91888f02007-07-31 20:11:57 +00002253 "setnp\t$dst",
Evan Cheng621216e2007-09-29 00:00:36 +00002254 [(store (X86setcc X86_COND_NP, EFLAGS), addr:$dst)]>,
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002255 TB; // [mem8] = not parity
Evan Cheng950aac02007-09-25 01:57:46 +00002256} // Uses = [EFLAGS]
2257
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002258
2259// Integer comparisons
Evan Cheng55687072007-09-14 21:48:26 +00002260let Defs = [EFLAGS] in {
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002261def CMP8rr : I<0x38, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002262 (outs), (ins GR8 :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002263 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002264 [(X86cmp GR8:$src1, GR8:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002265def CMP16rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002266 (outs), (ins GR16:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002267 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002268 [(X86cmp GR16:$src1, GR16:$src2), (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002269def CMP32rr : I<0x39, MRMDestReg,
Evan Chengb783fa32007-07-19 01:14:50 +00002270 (outs), (ins GR32:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002271 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002272 [(X86cmp GR32:$src1, GR32:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002273def CMP8mr : I<0x38, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002274 (outs), (ins i8mem :$src1, GR8 :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002275 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002276 [(X86cmp (loadi8 addr:$src1), GR8:$src2),
2277 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002278def CMP16mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002279 (outs), (ins i16mem:$src1, GR16:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002280 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002281 [(X86cmp (loadi16 addr:$src1), GR16:$src2),
2282 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002283def CMP32mr : I<0x39, MRMDestMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002284 (outs), (ins i32mem:$src1, GR32:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002285 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002286 [(X86cmp (loadi32 addr:$src1), GR32:$src2),
2287 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002288def CMP8rm : I<0x3A, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002289 (outs), (ins GR8 :$src1, i8mem :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002290 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002291 [(X86cmp GR8:$src1, (loadi8 addr:$src2)),
2292 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002293def CMP16rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002294 (outs), (ins GR16:$src1, i16mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002295 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002296 [(X86cmp GR16:$src1, (loadi16 addr:$src2)),
2297 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002298def CMP32rm : I<0x3B, MRMSrcMem,
Evan Chengb783fa32007-07-19 01:14:50 +00002299 (outs), (ins GR32:$src1, i32mem:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002300 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002301 [(X86cmp GR32:$src1, (loadi32 addr:$src2)),
2302 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002303def CMP8ri : Ii8<0x80, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002304 (outs), (ins GR8:$src1, i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002305 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002306 [(X86cmp GR8:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002307def CMP16ri : Ii16<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002308 (outs), (ins GR16:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002309 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002310 [(X86cmp GR16:$src1, imm:$src2),
2311 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002312def CMP32ri : Ii32<0x81, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002313 (outs), (ins GR32:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002314 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002315 [(X86cmp GR32:$src1, imm:$src2), (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002316def CMP8mi : Ii8 <0x80, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002317 (outs), (ins i8mem :$src1, i8imm :$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002318 "cmp{b}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002319 [(X86cmp (loadi8 addr:$src1), imm:$src2),
2320 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002321def CMP16mi : Ii16<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002322 (outs), (ins i16mem:$src1, i16imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002323 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002324 [(X86cmp (loadi16 addr:$src1), imm:$src2),
2325 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002326def CMP32mi : Ii32<0x81, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002327 (outs), (ins i32mem:$src1, i32imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002328 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002329 [(X86cmp (loadi32 addr:$src1), imm:$src2),
2330 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002331def CMP16ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002332 (outs), (ins GR16:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002333 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002334 [(X86cmp GR16:$src1, i16immSExt8:$src2),
2335 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002336def CMP16mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002337 (outs), (ins i16mem:$src1, i16i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002338 "cmp{w}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002339 [(X86cmp (loadi16 addr:$src1), i16immSExt8:$src2),
2340 (implicit EFLAGS)]>, OpSize;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002341def CMP32mi8 : Ii8<0x83, MRM7m,
Evan Chengb783fa32007-07-19 01:14:50 +00002342 (outs), (ins i32mem:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002343 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002344 [(X86cmp (loadi32 addr:$src1), i32immSExt8:$src2),
2345 (implicit EFLAGS)]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002346def CMP32ri8 : Ii8<0x83, MRM7r,
Evan Chengb783fa32007-07-19 01:14:50 +00002347 (outs), (ins GR32:$src1, i32i8imm:$src2),
Dan Gohman91888f02007-07-31 20:11:57 +00002348 "cmp{l}\t{$src2, $src1|$src1, $src2}",
Evan Cheng621216e2007-09-29 00:00:36 +00002349 [(X86cmp GR32:$src1, i32immSExt8:$src2),
Evan Cheng950aac02007-09-25 01:57:46 +00002350 (implicit EFLAGS)]>;
2351} // Defs = [EFLAGS]
2352
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002353// Sign/Zero extenders
Evan Chengb783fa32007-07-19 01:14:50 +00002354def MOVSX16rr8 : I<0xBE, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002355 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002356 [(set GR16:$dst, (sext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002357def MOVSX16rm8 : I<0xBE, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002358 "movs{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002359 [(set GR16:$dst, (sextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002360def MOVSX32rr8 : I<0xBE, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002361 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002362 [(set GR32:$dst, (sext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002363def MOVSX32rm8 : I<0xBE, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002364 "movs{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002365 [(set GR32:$dst, (sextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002366def MOVSX32rr16: I<0xBF, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002367 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002368 [(set GR32:$dst, (sext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002369def MOVSX32rm16: I<0xBF, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002370 "movs{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002371 [(set GR32:$dst, (sextloadi32i16 addr:$src))]>, TB;
2372
Evan Chengb783fa32007-07-19 01:14:50 +00002373def MOVZX16rr8 : I<0xB6, MRMSrcReg, (outs GR16:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002374 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002375 [(set GR16:$dst, (zext GR8:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002376def MOVZX16rm8 : I<0xB6, MRMSrcMem, (outs GR16:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002377 "movz{bw|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002378 [(set GR16:$dst, (zextloadi16i8 addr:$src))]>, TB, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002379def MOVZX32rr8 : I<0xB6, MRMSrcReg, (outs GR32:$dst), (ins GR8 :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002380 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002381 [(set GR32:$dst, (zext GR8:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002382def MOVZX32rm8 : I<0xB6, MRMSrcMem, (outs GR32:$dst), (ins i8mem :$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002383 "movz{bl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002384 [(set GR32:$dst, (zextloadi32i8 addr:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002385def MOVZX32rr16: I<0xB7, MRMSrcReg, (outs GR32:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002386 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002387 [(set GR32:$dst, (zext GR16:$src))]>, TB;
Evan Chengb783fa32007-07-19 01:14:50 +00002388def MOVZX32rm16: I<0xB7, MRMSrcMem, (outs GR32:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002389 "movz{wl|x}\t{$src, $dst|$dst, $src}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002390 [(set GR32:$dst, (zextloadi32i16 addr:$src))]>, TB;
2391
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002392let Defs = [AX], Uses = [AL] in
Evan Chengb783fa32007-07-19 01:14:50 +00002393def CBW : I<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002394 "{cbtw|cbw}", []>, OpSize; // AX = signext(AL)
2395let Defs = [EAX], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002396def CWDE : I<0x98, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002397 "{cwtl|cwde}", []>; // EAX = signext(AX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002398
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002399let Defs = [AX,DX], Uses = [AX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002400def CWD : I<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002401 "{cwtd|cwd}", []>, OpSize; // DX:AX = signext(AX)
2402let Defs = [EAX,EDX], Uses = [EAX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002403def CDQ : I<0x99, RawFrm, (outs), (ins),
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002404 "{cltd|cdq}", []>; // EDX:EAX = signext(EAX)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002405
2406
2407//===----------------------------------------------------------------------===//
2408// Alias Instructions
2409//===----------------------------------------------------------------------===//
2410
2411// Alias instructions that map movr0 to xor.
2412// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Evan Cheng55687072007-09-14 21:48:26 +00002413let Defs = [EFLAGS], isReMaterializable = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002414def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002415 "xor{b}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002416 [(set GR8:$dst, 0)]>;
Evan Chengb783fa32007-07-19 01:14:50 +00002417def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002418 "xor{w}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002419 [(set GR16:$dst, 0)]>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002420def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002421 "xor{l}\t$dst, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002422 [(set GR32:$dst, 0)]>;
Dan Gohman8aef09b2007-09-07 21:32:51 +00002423}
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002424
2425// Basic operations on GR16 / GR32 subclasses GR16_ and GR32_ which contains only
2426// those registers that have GR8 sub-registers (i.e. AX - DX, EAX - EDX).
Evan Chengb783fa32007-07-19 01:14:50 +00002427def MOV16to16_ : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002428 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002429def MOV32to32_ : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002430 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002431
Evan Chengb783fa32007-07-19 01:14:50 +00002432def MOV16_rr : I<0x89, MRMDestReg, (outs GR16_:$dst), (ins GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002433 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002434def MOV32_rr : I<0x89, MRMDestReg, (outs GR32_:$dst), (ins GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002435 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002436let isLoad = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002437def MOV16_rm : I<0x8B, MRMSrcMem, (outs GR16_:$dst), (ins i16mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002438 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002439def MOV32_rm : I<0x8B, MRMSrcMem, (outs GR32_:$dst), (ins i32mem:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002440 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Evan Cheng4e84e452007-08-30 05:49:43 +00002441}
Evan Chengb783fa32007-07-19 01:14:50 +00002442def MOV16_mr : I<0x89, MRMDestMem, (outs), (ins i16mem:$dst, GR16_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002443 "mov{w}\t{$src, $dst|$dst, $src}", []>, OpSize;
Evan Chengb783fa32007-07-19 01:14:50 +00002444def MOV32_mr : I<0x89, MRMDestMem, (outs), (ins i32mem:$dst, GR32_:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002445 "mov{l}\t{$src, $dst|$dst, $src}", []>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002446
2447//===----------------------------------------------------------------------===//
2448// Thread Local Storage Instructions
2449//
2450
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002451let Uses = [EBX] in
Evan Chengb783fa32007-07-19 01:14:50 +00002452def TLS_addr : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$sym),
Dan Gohman91888f02007-07-31 20:11:57 +00002453 "leal\t${sym:mem}(,%ebx,1), $dst",
Evan Cheng6e4d1d92007-09-11 19:55:27 +00002454 [(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>;
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002455
2456let AddedComplexity = 10 in
Evan Chengb783fa32007-07-19 01:14:50 +00002457def TLS_gs_rr : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002458 "movl\t%gs:($src), $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002459 [(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
2460
2461let AddedComplexity = 15 in
Evan Chengb783fa32007-07-19 01:14:50 +00002462def TLS_gs_ri : I<0, Pseudo, (outs GR32:$dst), (ins i32imm:$src),
Dan Gohman91888f02007-07-31 20:11:57 +00002463 "movl\t%gs:${src:mem}, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002464 [(set GR32:$dst,
2465 (load (add X86TLStp, (X86Wrapper tglobaltlsaddr:$src))))]>;
2466
Evan Chengb783fa32007-07-19 01:14:50 +00002467def TLS_tp : I<0, Pseudo, (outs GR32:$dst), (ins),
Dan Gohman91888f02007-07-31 20:11:57 +00002468 "movl\t%gs:0, $dst",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002469 [(set GR32:$dst, X86TLStp)]>;
2470
2471//===----------------------------------------------------------------------===//
2472// DWARF Pseudo Instructions
2473//
2474
Evan Chengb783fa32007-07-19 01:14:50 +00002475def DWARF_LOC : I<0, Pseudo, (outs),
2476 (ins i32imm:$line, i32imm:$col, i32imm:$file),
Dan Gohman77af4a82007-09-24 19:25:06 +00002477 ".loc\t${file:debug} ${line:debug} ${col:debug}",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002478 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
2479 (i32 imm:$file))]>;
2480
2481//===----------------------------------------------------------------------===//
2482// EH Pseudo Instructions
2483//
2484let isTerminator = 1, isReturn = 1, isBarrier = 1,
Evan Cheng37e7c752007-07-21 00:34:19 +00002485 hasCtrlDep = 1 in {
Evan Chengb783fa32007-07-19 01:14:50 +00002486def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr),
Dan Gohman91888f02007-07-31 20:11:57 +00002487 "ret\t#eh_return, addr: $addr",
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002488 [(X86ehret GR32:$addr)]>;
2489
2490}
2491
2492//===----------------------------------------------------------------------===//
2493// Non-Instruction Patterns
2494//===----------------------------------------------------------------------===//
2495
2496// ConstantPool GlobalAddress, ExternalSymbol, and JumpTable
2497def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>;
2498def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>;
2499def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)), (MOV32ri tglobaltlsaddr:$dst)>;
2500def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>;
2501def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>;
2502
2503def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)),
2504 (ADD32ri GR32:$src1, tconstpool:$src2)>;
2505def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)),
2506 (ADD32ri GR32:$src1, tjumptable:$src2)>;
2507def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)),
2508 (ADD32ri GR32:$src1, tglobaladdr:$src2)>;
2509def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)),
2510 (ADD32ri GR32:$src1, texternalsym:$src2)>;
2511
2512def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst),
2513 (MOV32mi addr:$dst, tglobaladdr:$src)>;
2514def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst),
2515 (MOV32mi addr:$dst, texternalsym:$src)>;
2516
2517// Calls
2518def : Pat<(X86tailcall GR32:$dst),
2519 (CALL32r GR32:$dst)>;
2520
2521def : Pat<(X86tailcall (i32 tglobaladdr:$dst)),
2522 (CALLpcrel32 tglobaladdr:$dst)>;
2523def : Pat<(X86tailcall (i32 texternalsym:$dst)),
2524 (CALLpcrel32 texternalsym:$dst)>;
2525
2526def : Pat<(X86call (i32 tglobaladdr:$dst)),
2527 (CALLpcrel32 tglobaladdr:$dst)>;
2528def : Pat<(X86call (i32 texternalsym:$dst)),
2529 (CALLpcrel32 texternalsym:$dst)>;
2530
2531// X86 specific add which produces a flag.
2532def : Pat<(addc GR32:$src1, GR32:$src2),
2533 (ADD32rr GR32:$src1, GR32:$src2)>;
2534def : Pat<(addc GR32:$src1, (load addr:$src2)),
2535 (ADD32rm GR32:$src1, addr:$src2)>;
2536def : Pat<(addc GR32:$src1, imm:$src2),
2537 (ADD32ri GR32:$src1, imm:$src2)>;
2538def : Pat<(addc GR32:$src1, i32immSExt8:$src2),
2539 (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>;
2540
2541def : Pat<(subc GR32:$src1, GR32:$src2),
2542 (SUB32rr GR32:$src1, GR32:$src2)>;
2543def : Pat<(subc GR32:$src1, (load addr:$src2)),
2544 (SUB32rm GR32:$src1, addr:$src2)>;
2545def : Pat<(subc GR32:$src1, imm:$src2),
2546 (SUB32ri GR32:$src1, imm:$src2)>;
2547def : Pat<(subc GR32:$src1, i32immSExt8:$src2),
2548 (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>;
2549
2550def : Pat<(truncstorei1 (i8 imm:$src), addr:$dst),
2551 (MOV8mi addr:$dst, imm:$src)>;
2552def : Pat<(truncstorei1 GR8:$src, addr:$dst),
2553 (MOV8mr addr:$dst, GR8:$src)>;
2554
2555// Comparisons.
2556
2557// TEST R,R is smaller than CMP R,0
Evan Cheng621216e2007-09-29 00:00:36 +00002558def : Pat<(parallel (X86cmp GR8:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002559 (TEST8rr GR8:$src1, GR8:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002560def : Pat<(parallel (X86cmp GR16:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002561 (TEST16rr GR16:$src1, GR16:$src1)>;
Evan Cheng621216e2007-09-29 00:00:36 +00002562def : Pat<(parallel (X86cmp GR32:$src1, 0), (implicit EFLAGS)),
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002563 (TEST32rr GR32:$src1, GR32:$src1)>;
2564
2565// {s|z}extload bool -> {s|z}extload byte
2566def : Pat<(sextloadi16i1 addr:$src), (MOVSX16rm8 addr:$src)>;
2567def : Pat<(sextloadi32i1 addr:$src), (MOVSX32rm8 addr:$src)>;
2568def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2569def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2570def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2571
2572// extload bool -> extload byte
2573def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>;
2574def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>;
2575def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>;
2576def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
2577def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>;
2578def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>;
2579
2580// anyext -> zext
2581def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>;
2582def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>;
2583def : Pat<(i32 (anyext GR16:$src)), (MOVZX32rr16 GR16:$src)>;
2584def : Pat<(i16 (anyext (loadi8 addr:$src))), (MOVZX16rm8 addr:$src)>;
2585def : Pat<(i32 (anyext (loadi8 addr:$src))), (MOVZX32rm8 addr:$src)>;
2586def : Pat<(i32 (anyext (loadi16 addr:$src))), (MOVZX32rm16 addr:$src)>;
2587
2588//===----------------------------------------------------------------------===//
2589// Some peepholes
2590//===----------------------------------------------------------------------===//
2591
2592// (shl x, 1) ==> (add x, x)
2593def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>;
2594def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>;
2595def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>;
2596
2597// (or (x >> c) | (y << (32 - c))) ==> (shrd32 x, y, c)
2598def : Pat<(or (srl GR32:$src1, CL:$amt),
2599 (shl GR32:$src2, (sub 32, CL:$amt))),
2600 (SHRD32rrCL GR32:$src1, GR32:$src2)>;
2601
2602def : Pat<(store (or (srl (loadi32 addr:$dst), CL:$amt),
2603 (shl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2604 (SHRD32mrCL addr:$dst, GR32:$src2)>;
2605
2606// (or (x << c) | (y >> (32 - c))) ==> (shld32 x, y, c)
2607def : Pat<(or (shl GR32:$src1, CL:$amt),
2608 (srl GR32:$src2, (sub 32, CL:$amt))),
2609 (SHLD32rrCL GR32:$src1, GR32:$src2)>;
2610
2611def : Pat<(store (or (shl (loadi32 addr:$dst), CL:$amt),
2612 (srl GR32:$src2, (sub 32, CL:$amt))), addr:$dst),
2613 (SHLD32mrCL addr:$dst, GR32:$src2)>;
2614
2615// (or (x >> c) | (y << (16 - c))) ==> (shrd16 x, y, c)
2616def : Pat<(or (srl GR16:$src1, CL:$amt),
2617 (shl GR16:$src2, (sub 16, CL:$amt))),
2618 (SHRD16rrCL GR16:$src1, GR16:$src2)>;
2619
2620def : Pat<(store (or (srl (loadi16 addr:$dst), CL:$amt),
2621 (shl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2622 (SHRD16mrCL addr:$dst, GR16:$src2)>;
2623
2624// (or (x << c) | (y >> (16 - c))) ==> (shld16 x, y, c)
2625def : Pat<(or (shl GR16:$src1, CL:$amt),
2626 (srl GR16:$src2, (sub 16, CL:$amt))),
2627 (SHLD16rrCL GR16:$src1, GR16:$src2)>;
2628
2629def : Pat<(store (or (shl (loadi16 addr:$dst), CL:$amt),
2630 (srl GR16:$src2, (sub 16, CL:$amt))), addr:$dst),
2631 (SHLD16mrCL addr:$dst, GR16:$src2)>;
2632
2633
2634//===----------------------------------------------------------------------===//
2635// Floating Point Stack Support
2636//===----------------------------------------------------------------------===//
2637
2638include "X86InstrFPStack.td"
2639
2640//===----------------------------------------------------------------------===//
Evan Cheng86ab7d32007-07-31 08:04:03 +00002641// X86-64 Support
2642//===----------------------------------------------------------------------===//
2643
2644include "X86InstrX86-64.td"
2645
2646//===----------------------------------------------------------------------===//
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002647// MMX and XMM Packed Integer support (requires MMX, SSE, and SSE2)
2648//===----------------------------------------------------------------------===//
2649
2650include "X86InstrMMX.td"
2651
2652//===----------------------------------------------------------------------===//
2653// XMM Floating point support (requires SSE / SSE2)
2654//===----------------------------------------------------------------------===//
2655
2656include "X86InstrSSE.td"