blob: 21475284cbca2174172ba77a0b2585a842880ae6 [file] [log] [blame]
Chris Lattner1cca5e32003-08-03 21:54:21 +00001//===- X86InstrInfo.td - Describe the X86 Instruction Set -------*- C++ -*-===//
John Criswell856ba762003-10-21 15:17:13 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +00009//
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
Chris Lattner66fa1dc2004-08-11 02:25:00 +000016// *mem - Operand definitions for the funky X86 addressing mode operands.
17//
Nate Begeman391c5d22005-11-30 18:54:35 +000018class X86MemOperand<ValueType Ty, string printMethod> : Operand<Ty> {
19 let PrintMethod = printMethod;
Chris Lattner6adaf792005-11-19 07:01:30 +000020 let NumMIOperands = 4;
21 let MIOperandInfo = (ops R32, i8imm, R32, i32imm);
Chris Lattner66fa1dc2004-08-11 02:25:00 +000022}
Nate Begeman391c5d22005-11-30 18:54:35 +000023
Evan Chengec693f72005-12-08 02:01:35 +000024def i8mem : X86MemOperand<i32, "printi8mem">;
25def i16mem : X86MemOperand<i32, "printi16mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +000026def i32mem : X86MemOperand<i32, "printi32mem">;
Evan Chengec693f72005-12-08 02:01:35 +000027def i64mem : X86MemOperand<i32, "printi64mem">;
28def f32mem : X86MemOperand<i32, "printf32mem">;
29def f64mem : X86MemOperand<i32, "printf64mem">;
30def f80mem : X86MemOperand<i32, "printf80mem">;
Nate Begeman391c5d22005-11-30 18:54:35 +000031
Nate Begeman16b04f32005-07-15 00:38:55 +000032def SSECC : Operand<i8> {
33 let PrintMethod = "printSSECC";
34}
Chris Lattner66fa1dc2004-08-11 02:25:00 +000035
Chris Lattnerf124d5e2005-11-18 01:04:42 +000036// A couple of more descriptive operand definitions.
37// 16-bits but only 8 bits are significant.
38def i16i8imm : Operand<i16>;
39// 32-bits but only 8 bits are significant.
40def i32i8imm : Operand<i32>;
41
Chris Lattnere4ead0c2004-08-11 06:59:12 +000042// PCRelative calls need special operand formatting.
43let PrintMethod = "printCallOperand" in
44 def calltarget : Operand<i32>;
45
Evan Chengd35b8c12005-12-04 08:19:43 +000046// Branch targets have OtherVT type.
47def brtarget : Operand<OtherVT>;
48
Evan Chengec693f72005-12-08 02:01:35 +000049// Define X86 specific addressing mode.
Evan Cheng670fd8f2005-12-08 02:15:07 +000050def addr : ComplexPattern<i32, 4, "SelectAddr", []>;
51def leaaddr : ComplexPattern<i32, 4, "SelectLEAAddr", [add]>;
Evan Chengec693f72005-12-08 02:01:35 +000052
Chris Lattner1cca5e32003-08-03 21:54:21 +000053// Format specifies the encoding used by the instruction. This is part of the
54// ad-hoc solution used to emit machine instruction encodings by our machine
55// code emitter.
56class Format<bits<5> val> {
57 bits<5> Value = val;
58}
59
60def Pseudo : Format<0>; def RawFrm : Format<1>;
61def AddRegFrm : Format<2>; def MRMDestReg : Format<3>;
62def MRMDestMem : Format<4>; def MRMSrcReg : Format<5>;
63def MRMSrcMem : Format<6>;
Alkis Evlogimenos169584e2004-02-27 18:55:12 +000064def MRM0r : Format<16>; def MRM1r : Format<17>; def MRM2r : Format<18>;
65def MRM3r : Format<19>; def MRM4r : Format<20>; def MRM5r : Format<21>;
66def MRM6r : Format<22>; def MRM7r : Format<23>;
67def MRM0m : Format<24>; def MRM1m : Format<25>; def MRM2m : Format<26>;
68def MRM3m : Format<27>; def MRM4m : Format<28>; def MRM5m : Format<29>;
69def MRM6m : Format<30>; def MRM7m : Format<31>;
Chris Lattner1cca5e32003-08-03 21:54:21 +000070
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +000071// ImmType - This specifies the immediate type used by an instruction. This is
Chris Lattner1cca5e32003-08-03 21:54:21 +000072// part of the ad-hoc solution used to emit machine instruction encodings by our
73// machine code emitter.
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +000074class ImmType<bits<2> val> {
75 bits<2> Value = val;
76}
77def NoImm : ImmType<0>;
78def Imm8 : ImmType<1>;
79def Imm16 : ImmType<2>;
80def Imm32 : ImmType<3>;
81
Chris Lattner1cca5e32003-08-03 21:54:21 +000082// FPFormat - This specifies what form this FP instruction has. This is used by
83// the Floating-Point stackifier pass.
84class FPFormat<bits<3> val> {
85 bits<3> Value = val;
86}
87def NotFP : FPFormat<0>;
88def ZeroArgFP : FPFormat<1>;
89def OneArgFP : FPFormat<2>;
90def OneArgFPRW : FPFormat<3>;
91def TwoArgFP : FPFormat<4>;
Chris Lattnerab8decc2004-06-11 04:41:24 +000092def CompareFP : FPFormat<5>;
93def CondMovFP : FPFormat<6>;
94def SpecialFP : FPFormat<7>;
Chris Lattner1cca5e32003-08-03 21:54:21 +000095
96
Chris Lattner3a173df2004-10-03 20:35:00 +000097class X86Inst<bits<8> opcod, Format f, ImmType i, dag ops, string AsmStr>
98 : Instruction {
Chris Lattnerc8f45872003-08-04 04:59:56 +000099 let Namespace = "X86";
Chris Lattner1cca5e32003-08-03 21:54:21 +0000100
Chris Lattner1cca5e32003-08-03 21:54:21 +0000101 bits<8> Opcode = opcod;
102 Format Form = f;
103 bits<5> FormBits = Form.Value;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000104 ImmType ImmT = i;
105 bits<2> ImmTypeBits = ImmT.Value;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000106
Chris Lattnerc96bb812004-08-11 07:12:04 +0000107 dag OperandList = ops;
108 string AsmString = AsmStr;
109
John Criswell4ffff9e2004-04-08 20:31:47 +0000110 //
Chris Lattner1cca5e32003-08-03 21:54:21 +0000111 // Attributes specific to X86 instructions...
John Criswell4ffff9e2004-04-08 20:31:47 +0000112 //
Chris Lattner1cca5e32003-08-03 21:54:21 +0000113 bit hasOpSizePrefix = 0; // Does this inst have a 0x66 prefix?
John Criswell4ffff9e2004-04-08 20:31:47 +0000114
Chris Lattner1cca5e32003-08-03 21:54:21 +0000115 bits<4> Prefix = 0; // Which prefix byte does this inst have?
116 FPFormat FPForm; // What flavor of FP instruction is this?
117 bits<3> FPFormBits = 0;
118}
119
120class Imp<list<Register> uses, list<Register> defs> {
121 list<Register> Uses = uses;
122 list<Register> Defs = defs;
123}
124
125
126// Prefix byte classes which are used to indicate to the ad-hoc machine code
127// emitter that various prefix bytes are required.
128class OpSize { bit hasOpSizePrefix = 1; }
129class TB { bits<4> Prefix = 1; }
Chris Lattner915e5e52004-02-12 17:53:22 +0000130class REP { bits<4> Prefix = 2; }
131class D8 { bits<4> Prefix = 3; }
132class D9 { bits<4> Prefix = 4; }
133class DA { bits<4> Prefix = 5; }
134class DB { bits<4> Prefix = 6; }
135class DC { bits<4> Prefix = 7; }
136class DD { bits<4> Prefix = 8; }
137class DE { bits<4> Prefix = 9; }
138class DF { bits<4> Prefix = 10; }
Nate Begemanf1702ac2005-06-27 21:20:31 +0000139class XD { bits<4> Prefix = 11; }
140class XS { bits<4> Prefix = 12; }
Chris Lattner1cca5e32003-08-03 21:54:21 +0000141
142
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000143//===----------------------------------------------------------------------===//
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000144// Pattern fragments...
145//
Evan Cheng9b6b6422005-12-13 00:14:11 +0000146def i16immSExt8 : PatLeaf<(i16 imm), [{
147 // i16immSExt8 predicate - True if the 16-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000148 // sign extended field.
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000149 return (int)N->getValue() == (signed char)N->getValue();
150}]>;
151
Evan Cheng9b6b6422005-12-13 00:14:11 +0000152def i32immSExt8 : PatLeaf<(i32 imm), [{
153 // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit
Evan Chengb3558542005-12-13 00:01:09 +0000154 // sign extended field.
155 return (int)N->getValue() == (signed char)N->getValue();
156}]>;
157
Evan Cheng9b6b6422005-12-13 00:14:11 +0000158def i16immZExt8 : PatLeaf<(i16 imm), [{
159 // i16immZExt8 predicate - True if the 16-bit immediate fits in a 8-bit zero
Evan Chengb3558542005-12-13 00:01:09 +0000160 // extended field.
Chris Lattner3d36a9f2005-12-05 02:40:25 +0000161 return (unsigned)N->getValue() == (unsigned char)N->getValue();
162}]>;
163
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000164//===----------------------------------------------------------------------===//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000165// Instruction templates...
166
Evan Chengf0701842005-11-29 19:38:52 +0000167class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
168 : X86Inst<o, f, NoImm, ops, asm> {
169 let Pattern = pattern;
170}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000171class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
172 : X86Inst<o, f, Imm8 , ops, asm> {
173 let Pattern = pattern;
174}
Chris Lattner78432fe2005-11-17 02:01:55 +0000175class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
176 : X86Inst<o, f, Imm16, ops, asm> {
177 let Pattern = pattern;
178}
Chris Lattner7a125372005-11-16 22:59:19 +0000179class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
180 : X86Inst<o, f, Imm32, ops, asm> {
181 let Pattern = pattern;
182}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000183
Chris Lattner1cca5e32003-08-03 21:54:21 +0000184//===----------------------------------------------------------------------===//
185// Instruction list...
186//
187
Evan Chengf0701842005-11-29 19:38:52 +0000188def PHI : I<0, Pseudo, (ops variable_ops), "PHINODE", []>; // PHI node.
189def NOOP : I<0x90, RawFrm, (ops), "nop", []>; // nop
Chris Lattner1cca5e32003-08-03 21:54:21 +0000190
Evan Chengf0701842005-11-29 19:38:52 +0000191def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN", []>;
Chris Lattner43ef1312005-09-14 21:10:24 +0000192def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
Evan Chengf0701842005-11-29 19:38:52 +0000193 "#ADJCALLSTACKUP", []>;
194def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
195def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
Alkis Evlogimenose0bb3e72003-12-20 16:22:59 +0000196let isTerminator = 1 in
197 let Defs = [FP0, FP1, FP2, FP3, FP4, FP5, FP6] in
Evan Chengf0701842005-11-29 19:38:52 +0000198 def FP_REG_KILL : I<0, Pseudo, (ops), "#FP_REG_KILL", []>;
Chris Lattner62cce392004-07-31 02:10:53 +0000199
Chris Lattner1cca5e32003-08-03 21:54:21 +0000200//===----------------------------------------------------------------------===//
201// Control Flow Instructions...
202//
203
Chris Lattner1be48112005-05-13 17:56:48 +0000204// Return instructions.
Evan Cheng8d202232005-12-05 23:09:43 +0000205let isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000206 def RET : I<0xC3, RawFrm, (ops), "ret", [(ret)]>;
Evan Cheng8d202232005-12-05 23:09:43 +0000207let isTerminator = 1, isReturn = 1, isBarrier = 1 in
Chris Lattner78432fe2005-11-17 02:01:55 +0000208 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000209
210// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng8d202232005-12-05 23:09:43 +0000211let isBranch = 1, isTerminator = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000212 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
213 I<opcode, RawFrm, ops, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000214
Chris Lattner62cce392004-07-31 02:10:53 +0000215let isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000216 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
217def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
218 []>, TB;
219def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst", []>, TB;
220def JE : IBr<0x84, (ops brtarget:$dst), "je $dst", []>, TB;
221def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst", []>, TB;
222def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst", []>, TB;
223def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst", []>, TB;
224def JS : IBr<0x88, (ops brtarget:$dst), "js $dst", []>, TB;
225def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst", []>, TB;
226def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst", []>, TB;
227def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst", []>, TB;
228def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst", []>, TB;
229def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst", []>, TB;
230def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst", []>, TB;
231def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst", []>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000232
233//===----------------------------------------------------------------------===//
234// Call Instructions...
235//
Chris Lattnerc8f45872003-08-04 04:59:56 +0000236let isCall = 1 in
Chris Lattner1cca5e32003-08-03 21:54:21 +0000237 // All calls clobber the non-callee saved registers...
Nate Begemanf63be7d2005-07-06 18:59:04 +0000238 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Nate Begeman16b04f32005-07-15 00:38:55 +0000239 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengf0701842005-11-29 19:38:52 +0000240 def CALLpcrel32 : I<0xE8, RawFrm, (ops calltarget:$dst), "call $dst", []>;
241 def CALL32r : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst", []>;
242 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst), "call {*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000243 }
244
Chris Lattner1e9448b2005-05-15 03:10:37 +0000245// Tail call stuff.
Chris Lattner2b3d56e2005-05-14 23:35:21 +0000246let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000247 def TAILJMPd : IBr<0xE9, (ops calltarget:$dst), "jmp $dst # TAIL CALL", []>;
Chris Lattner2b3d56e2005-05-14 23:35:21 +0000248let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000249 def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst # TAIL CALL", []>;
Chris Lattner2b3d56e2005-05-14 23:35:21 +0000250let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000251 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
252 "jmp {*}$dst # TAIL CALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000253
254// ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
255// way, except that it is marked as being a terminator. This causes the epilog
256// inserter to insert reloads of callee saved registers BEFORE this. We need
257// this until we have a more accurate way of tracking where the stack pointer is
258// within a function.
259let isTerminator = 1, isTwoAddress = 1 in
260 def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000261 "add{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000262
Chris Lattner1cca5e32003-08-03 21:54:21 +0000263//===----------------------------------------------------------------------===//
264// Miscellaneous Instructions...
265//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000266def LEAVE : I<0xC9, RawFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000267 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000268def POP32r : I<0x58, AddRegFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000269 (ops R32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000270
Chris Lattner3a173df2004-10-03 20:35:00 +0000271let isTwoAddress = 1 in // R32 = bswap R32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000272 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000273 (ops R32:$dst, R32:$src), "bswap{l} $dst", []>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000274
Chris Lattner30bf2d82004-08-10 20:17:41 +0000275def XCHG8rr : I<0x86, MRMDestReg, // xchg R8, R8
Chris Lattner3a173df2004-10-03 20:35:00 +0000276 (ops R8:$src1, R8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000277 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000278def XCHG16rr : I<0x87, MRMDestReg, // xchg R16, R16
Chris Lattner3a173df2004-10-03 20:35:00 +0000279 (ops R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000280 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000281def XCHG32rr : I<0x87, MRMDestReg, // xchg R32, R32
Chris Lattner3a173df2004-10-03 20:35:00 +0000282 (ops R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000283 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattnerfc752712004-08-01 09:52:59 +0000284
Chris Lattner3a173df2004-10-03 20:35:00 +0000285def XCHG8mr : I<0x86, MRMDestMem,
286 (ops i8mem:$src1, R8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000287 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000288def XCHG16mr : I<0x87, MRMDestMem,
289 (ops i16mem:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000290 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000291def XCHG32mr : I<0x87, MRMDestMem,
292 (ops i32mem:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000293 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000294def XCHG8rm : I<0x86, MRMSrcMem,
295 (ops R8:$src1, i8mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000296 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000297def XCHG16rm : I<0x87, MRMSrcMem,
298 (ops R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000299 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000300def XCHG32rm : I<0x87, MRMSrcMem,
301 (ops R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000302 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000303
Chris Lattner3a173df2004-10-03 20:35:00 +0000304def LEA16r : I<0x8D, MRMSrcMem,
305 (ops R16:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000306 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000307def LEA32r : I<0x8D, MRMSrcMem,
308 (ops R32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000309 "lea{l} {$src|$dst}, {$dst|$src}",
310 [(set R32:$dst, leaaddr:$src)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000311
Chris Lattner915e5e52004-02-12 17:53:22 +0000312
Evan Chengf0701842005-11-29 19:38:52 +0000313def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000314 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Chengf0701842005-11-29 19:38:52 +0000315def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000316 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Chengf0701842005-11-29 19:38:52 +0000317def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsd|rep movsd}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000318 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Chris Lattner915e5e52004-02-12 17:53:22 +0000319
Evan Chengf0701842005-11-29 19:38:52 +0000320def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000321 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Chengf0701842005-11-29 19:38:52 +0000322def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000323 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Chengf0701842005-11-29 19:38:52 +0000324def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000325 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
326
Chris Lattnerb89abef2004-02-14 04:45:37 +0000327
Chris Lattner1cca5e32003-08-03 21:54:21 +0000328//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000329// Input/Output Instructions...
330//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000331def IN8rr : I<0xEC, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000332 "in{b} {%dx, %al|%AL, %DX}", []>, Imp<[DX], [AL]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000333def IN16rr : I<0xED, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000334 "in{w} {%dx, %ax|%AX, %DX}", []>, Imp<[DX], [AX]>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000335def IN32rr : I<0xED, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000336 "in{l} {%dx, %eax|%EAX, %DX}", []>, Imp<[DX],[EAX]>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000337
Evan Chengd35b8c12005-12-04 08:19:43 +0000338def IN8ri : Ii8<0xE4, RawFrm, (ops i8imm:$port),
Chris Lattner78432fe2005-11-17 02:01:55 +0000339 "in{b} {$port, %al|%AL, $port}", []>, Imp<[], [AL]>;
Evan Chengd35b8c12005-12-04 08:19:43 +0000340def IN16ri : Ii8<0xE5, RawFrm, (ops i8imm:$port),
Chris Lattner78432fe2005-11-17 02:01:55 +0000341 "in{w} {$port, %ax|%AX, $port}", []>, Imp<[], [AX]>, OpSize;
Evan Chengd35b8c12005-12-04 08:19:43 +0000342def IN32ri : Ii8<0xE5, RawFrm, (ops i8imm:$port),
Chris Lattner78432fe2005-11-17 02:01:55 +0000343 "in{l} {$port, %eax|%EAX, $port}", []>, Imp<[],[EAX]>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000344
Evan Cheng8d202232005-12-05 23:09:43 +0000345def OUT8rr : I<0xEE, RawFrm, (ops),
346 "out{b} {%al, %dx|%DX, %AL}",
347 [(writeport AL, DX)]>, Imp<[DX, AL], []>;
348def OUT16rr : I<0xEF, RawFrm, (ops),
349 "out{w} {%ax, %dx|%DX, %AX}",
350 [(writeport AX, DX)]>, Imp<[DX, AX], []>, OpSize;
351def OUT32rr : I<0xEF, RawFrm, (ops),
352 "out{l} {%eax, %dx|%DX, %EAX}",
353 [(writeport EAX, DX)]>, Imp<[DX, EAX], []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000354
Evan Cheng8d202232005-12-05 23:09:43 +0000355def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
356 "out{b} {%al, $port|$port, %AL}",
Evan Cheng5a38e022005-12-13 00:25:07 +0000357 [(writeport AL, i16immZExt8:$port)]>,
Evan Cheng8d202232005-12-05 23:09:43 +0000358 Imp<[AL], []>;
359def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
360 "out{w} {%ax, $port|$port, %AX}",
Evan Cheng5a38e022005-12-13 00:25:07 +0000361 [(writeport AX, i16immZExt8:$port)]>,
Evan Cheng8d202232005-12-05 23:09:43 +0000362 Imp<[AX], []>, OpSize;
363def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
364 "out{l} {%eax, $port|$port, %EAX}",
Evan Cheng5a38e022005-12-13 00:25:07 +0000365 [(writeport EAX, i16immZExt8:$port)]>,
Evan Cheng8d202232005-12-05 23:09:43 +0000366 Imp<[EAX], []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000367
368//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000369// Move Instructions...
370//
Chris Lattner3a173df2004-10-03 20:35:00 +0000371def MOV8rr : I<0x88, MRMDestReg, (ops R8 :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000372 "mov{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000373def MOV16rr : I<0x89, MRMDestReg, (ops R16:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000374 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000375def MOV32rr : I<0x89, MRMDestReg, (ops R32:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000376 "mov{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000377def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops R8 :$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000378 "mov{b} {$src, $dst|$dst, $src}",
379 [(set R8:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000380def MOV16ri : Ii16<0xB8, AddRegFrm, (ops R16:$dst, i16imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000381 "mov{w} {$src, $dst|$dst, $src}",
382 [(set R16:$dst, imm:$src)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000383def MOV32ri : Ii32<0xB8, AddRegFrm, (ops R32:$dst, i32imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000384 "mov{l} {$src, $dst|$dst, $src}",
385 [(set R32:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000386def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000387 "mov{b} {$src, $dst|$dst, $src}",
388 [(store (i8 imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000389def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000390 "mov{w} {$src, $dst|$dst, $src}",
391 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000392def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000393 "mov{l} {$src, $dst|$dst, $src}",
394 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000395
Chris Lattner3a173df2004-10-03 20:35:00 +0000396def MOV8rm : I<0x8A, MRMSrcMem, (ops R8 :$dst, i8mem :$src),
Evan Chengec693f72005-12-08 02:01:35 +0000397 "mov{b} {$src, $dst|$dst, $src}",
398 [(set R8:$dst, (load addr:$src))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000399def MOV16rm : I<0x8B, MRMSrcMem, (ops R16:$dst, i16mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000400 "mov{w} {$src, $dst|$dst, $src}",
401 [(set R16:$dst, (load addr:$src))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000402def MOV32rm : I<0x8B, MRMSrcMem, (ops R32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000403 "mov{l} {$src, $dst|$dst, $src}",
404 [(set R32:$dst, (load addr:$src))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000405
Chris Lattner3a173df2004-10-03 20:35:00 +0000406def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, R8 :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000407 "mov{b} {$src, $dst|$dst, $src}",
408 [(store R8:$src, addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000409def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, R16:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000410 "mov{w} {$src, $dst|$dst, $src}",
411 [(store R16:$src, addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000412def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, R32:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000413 "mov{l} {$src, $dst|$dst, $src}",
414 [(store R32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000415
Chris Lattner1cca5e32003-08-03 21:54:21 +0000416//===----------------------------------------------------------------------===//
417// Fixed-Register Multiplication and Division Instructions...
418//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000419
Chris Lattnerc8f45872003-08-04 04:59:56 +0000420// Extra precision multiplication
Evan Chengf0701842005-11-29 19:38:52 +0000421def MUL8r : I<0xF6, MRM4r, (ops R8:$src), "mul{b} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000422 Imp<[AL],[AX]>; // AL,AH = AL*R8
Evan Chengf0701842005-11-29 19:38:52 +0000423def MUL16r : I<0xF7, MRM4r, (ops R16:$src), "mul{w} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000424 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
Evan Chengf0701842005-11-29 19:38:52 +0000425def MUL32r : I<0xF7, MRM4r, (ops R32:$src), "mul{l} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000426 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
Chris Lattner57a02302004-08-11 04:31:00 +0000427def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000428 "mul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner57a02302004-08-11 04:31:00 +0000429def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000430 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
431 OpSize; // AX,DX = AX*[mem16]
Chris Lattner57a02302004-08-11 04:31:00 +0000432def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000433 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000434
Evan Chengf0701842005-11-29 19:38:52 +0000435def IMUL8r : I<0xF6, MRM5r, (ops R8:$src), "imul{b} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000436 Imp<[AL],[AX]>; // AL,AH = AL*R8
Evan Chengf0701842005-11-29 19:38:52 +0000437def IMUL16r : I<0xF7, MRM5r, (ops R16:$src), "imul{w} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000438 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
Evan Chengf0701842005-11-29 19:38:52 +0000439def IMUL32r : I<0xF7, MRM5r, (ops R32:$src), "imul{l} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000440 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
441def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000442 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000443def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000444 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
445 OpSize; // AX,DX = AX*[mem16]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000446def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000447 "imul{l} $src", []>,
448 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000449
Chris Lattnerc8f45872003-08-04 04:59:56 +0000450// unsigned division/remainder
Chris Lattner3a173df2004-10-03 20:35:00 +0000451def DIV8r : I<0xF6, MRM6r, (ops R8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000452 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000453def DIV16r : I<0xF7, MRM6r, (ops R16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000454 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000455def DIV32r : I<0xF7, MRM6r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000456 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000457def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000458 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000459def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000460 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000461def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000462 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000463
Chris Lattnerfc752712004-08-01 09:52:59 +0000464// Signed division/remainder.
Chris Lattner3a173df2004-10-03 20:35:00 +0000465def IDIV8r : I<0xF6, MRM7r, (ops R8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000466 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000467def IDIV16r: I<0xF7, MRM7r, (ops R16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000468 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000469def IDIV32r: I<0xF7, MRM7r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000470 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000471def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000472 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000473def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000474 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000475def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000476 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattnerc8f45872003-08-04 04:59:56 +0000477
Chris Lattnerfc752712004-08-01 09:52:59 +0000478// Sign-extenders for division.
Chris Lattner3a173df2004-10-03 20:35:00 +0000479def CBW : I<0x98, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000480 "{cbtw|cbw}", []>, Imp<[AL],[AH]>; // AX = signext(AL)
Chris Lattner3a173df2004-10-03 20:35:00 +0000481def CWD : I<0x99, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000482 "{cwtd|cwd}", []>, Imp<[AX],[DX]>; // DX:AX = signext(AX)
Chris Lattner3a173df2004-10-03 20:35:00 +0000483def CDQ : I<0x99, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000484 "{cltd|cdq}", []>, Imp<[EAX],[EDX]>; // EDX:EAX = signext(EAX)
Chris Lattnerfc752712004-08-01 09:52:59 +0000485
Chris Lattner1cca5e32003-08-03 21:54:21 +0000486
Chris Lattner1cca5e32003-08-03 21:54:21 +0000487//===----------------------------------------------------------------------===//
488// Two address Instructions...
489//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000490let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000491
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000492// Conditional moves
Chris Lattner3a173df2004-10-03 20:35:00 +0000493def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, R16 = R16
494 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000495 "cmovb {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000496def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, R16 = [mem16]
497 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000498 "cmovb {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000499def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, R32 = R32
500 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000501 "cmovb {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000502def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, R32 = [mem32]
503 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000504 "cmovb {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000505
Chris Lattner3a173df2004-10-03 20:35:00 +0000506def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, R16 = R16
507 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000508 "cmovae {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000509def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, R16 = [mem16]
510 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000511 "cmovae {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000512def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, R32 = R32
513 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000514 "cmovae {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000515def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, R32 = [mem32]
516 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000517 "cmovae {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000518
Chris Lattner3a173df2004-10-03 20:35:00 +0000519def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, R16 = R16
520 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000521 "cmove {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000522def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, R16 = [mem16]
523 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000524 "cmove {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000525def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, R32 = R32
526 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000527 "cmove {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000528def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, R32 = [mem32]
529 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000530 "cmove {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000531
Chris Lattner3a173df2004-10-03 20:35:00 +0000532def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, R16 = R16
533 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000534 "cmovne {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000535def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, R16 = [mem16]
536 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000537 "cmovne {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000538def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, R32 = R32
539 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000540 "cmovne {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000541def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, R32 = [mem32]
542 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000543 "cmovne {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000544
Chris Lattner3a173df2004-10-03 20:35:00 +0000545def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, R16 = R16
546 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000547 "cmovbe {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000548def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, R16 = [mem16]
549 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000550 "cmovbe {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000551def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, R32 = R32
552 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000553 "cmovbe {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000554def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, R32 = [mem32]
555 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000556 "cmovbe {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000557
Chris Lattner3a173df2004-10-03 20:35:00 +0000558def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, R16 = R16
559 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000560 "cmova {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000561def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, R16 = [mem16]
562 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000563 "cmova {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000564def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, R32 = R32
565 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000566 "cmova {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000567def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, R32 = [mem32]
568 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000569 "cmova {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000570
Chris Lattner3a173df2004-10-03 20:35:00 +0000571def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, R16 = R16
572 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000573 "cmovs {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000574def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, R16 = [mem16]
575 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000576 "cmovs {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000577def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, R32 = R32
578 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000579 "cmovs {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000580def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, R32 = [mem32]
581 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000582 "cmovs {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000583
Chris Lattner3a173df2004-10-03 20:35:00 +0000584def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, R16 = R16
585 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000586 "cmovns {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000587def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, R16 = [mem16]
588 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000589 "cmovns {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000590def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, R32 = R32
591 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000592 "cmovns {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000593def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, R32 = [mem32]
594 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000595 "cmovns {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000596
Chris Lattner57fbfb52005-01-10 22:09:33 +0000597def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, R16 = R16
598 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000599 "cmovp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000600def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, R16 = [mem16]
601 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000602 "cmovp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000603def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, R32 = R32
604 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000605 "cmovp {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000606def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, R32 = [mem32]
607 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000608 "cmovp {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000609
610
611def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, R16 = R16
612 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000613 "cmovnp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000614def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, R16 = [mem16]
615 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000616 "cmovnp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000617def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, R32 = R32
618 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000619 "cmovnp {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000620def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, R32 = [mem32]
621 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000622 "cmovnp {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000623
624
Chris Lattner3a173df2004-10-03 20:35:00 +0000625def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, R16 = R16
626 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000627 "cmovl {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000628def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, R16 = [mem16]
629 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000630 "cmovl {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000631def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, R32 = R32
632 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000633 "cmovl {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000634def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, R32 = [mem32]
635 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000636 "cmovl {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000637
Chris Lattner3a173df2004-10-03 20:35:00 +0000638def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, R16 = R16
639 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000640 "cmovge {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000641def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, R16 = [mem16]
642 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000643 "cmovge {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000644def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, R32 = R32
645 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000646 "cmovge {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000647def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, R32 = [mem32]
648 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000649 "cmovge {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000650
Chris Lattner3a173df2004-10-03 20:35:00 +0000651def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, R16 = R16
652 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000653 "cmovle {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000654def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, R16 = [mem16]
655 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000656 "cmovle {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000657def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, R32 = R32
658 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000659 "cmovle {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000660def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, R32 = [mem32]
661 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000662 "cmovle {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000663
Chris Lattner3a173df2004-10-03 20:35:00 +0000664def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, R16 = R16
665 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000666 "cmovg {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000667def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, R16 = [mem16]
668 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000669 "cmovg {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000670def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, R32 = R32
671 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000672 "cmovg {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000673def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, R32 = [mem32]
674 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000675 "cmovg {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000676
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000677// unary instructions
Evan Chengf0701842005-11-29 19:38:52 +0000678def NEG8r : I<0xF6, MRM3r, (ops R8 :$dst, R8 :$src), "neg{b} $dst",
679 [(set R8:$dst, (ineg R8:$src))]>;
680def NEG16r : I<0xF7, MRM3r, (ops R16:$dst, R16:$src), "neg{w} $dst",
681 [(set R16:$dst, (ineg R16:$src))]>, OpSize;
682def NEG32r : I<0xF7, MRM3r, (ops R32:$dst, R32:$src), "neg{l} $dst",
683 [(set R32:$dst, (ineg R32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000684let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +0000685 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
686 [(store (ineg (i8 (load addr:$dst))), addr:$dst)]>;
687 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
688 [(store (ineg (i16 (load addr:$dst))), addr:$dst)]>, OpSize;
689 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
690 [(store (ineg (i32 (load addr:$dst))), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000691}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000692
Evan Chengf0701842005-11-29 19:38:52 +0000693def NOT8r : I<0xF6, MRM2r, (ops R8 :$dst, R8 :$src), "not{b} $dst",
694 [(set R8:$dst, (not R8:$src))]>;
695def NOT16r : I<0xF7, MRM2r, (ops R16:$dst, R16:$src), "not{w} $dst",
696 [(set R16:$dst, (not R16:$src))]>, OpSize;
697def NOT32r : I<0xF7, MRM2r, (ops R32:$dst, R32:$src), "not{l} $dst",
698 [(set R32:$dst, (not R32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000699let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +0000700 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
701 [(store (not (i8 (load addr:$dst))), addr:$dst)]>;
702 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
703 [(store (not (i16 (load addr:$dst))), addr:$dst)]>, OpSize;
704 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
705 [(store (not (i32 (load addr:$dst))), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000706}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000707
Evan Chengb51a0592005-12-10 00:48:20 +0000708// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Chengf0701842005-11-29 19:38:52 +0000709def INC8r : I<0xFE, MRM0r, (ops R8 :$dst, R8 :$src), "inc{b} $dst",
710 [(set R8:$dst, (add R8:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000711let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengf0701842005-11-29 19:38:52 +0000712def INC16r : I<0xFF, MRM0r, (ops R16:$dst, R16:$src), "inc{w} $dst",
713 [(set R16:$dst, (add R16:$src, 1))]>, OpSize;
714def INC32r : I<0xFF, MRM0r, (ops R32:$dst, R32:$src), "inc{l} $dst",
715 [(set R32:$dst, (add R32:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000716}
Chris Lattner57a02302004-08-11 04:31:00 +0000717let isTwoAddress = 0 in {
Evan Cheng6cad2762005-12-13 01:02:47 +0000718 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
719 [(store (add (i8 (load addr:$dst)), 1), addr:$dst)]>;
720 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
721 [(store (add (i16 (load addr:$dst)), 1), addr:$dst)]>, OpSize;
722 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
723 [(store (add (i32 (load addr:$dst)), 1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000724}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000725
Evan Chengb51a0592005-12-10 00:48:20 +0000726def DEC8r : I<0xFE, MRM1r, (ops R8 :$dst, R8 :$src), "dec{b} $dst",
727 [(set R8:$dst, (add R8:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000728let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb51a0592005-12-10 00:48:20 +0000729def DEC16r : I<0xFF, MRM1r, (ops R16:$dst, R16:$src), "dec{w} $dst",
730 [(set R16:$dst, (add R16:$src, -1))]>, OpSize;
731def DEC32r : I<0xFF, MRM1r, (ops R32:$dst, R32:$src), "dec{l} $dst",
732 [(set R32:$dst, (add R32:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000733}
Chris Lattner57a02302004-08-11 04:31:00 +0000734
735let isTwoAddress = 0 in {
Evan Cheng6cad2762005-12-13 01:02:47 +0000736 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
737 [(store (add (i8 (load addr:$dst)), -1), addr:$dst)]>;
738 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
739 [(store (add (i16 (load addr:$dst)), -1), addr:$dst)]>, OpSize;
740 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
741 [(store (add (i32 (load addr:$dst)), -1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000742}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000743
744// Logical operators...
Chris Lattnercc65bee2005-01-02 02:35:46 +0000745let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +0000746def AND8rr : I<0x20, MRMDestReg,
747 (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000748 "and{b} {$src2, $dst|$dst, $src2}",
749 [(set R8:$dst, (and R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000750def AND16rr : I<0x21, MRMDestReg,
751 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000752 "and{w} {$src2, $dst|$dst, $src2}",
753 [(set R16:$dst, (and R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000754def AND32rr : I<0x21, MRMDestReg,
755 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000756 "and{l} {$src2, $dst|$dst, $src2}",
757 [(set R32:$dst, (and R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000758}
Chris Lattner57a02302004-08-11 04:31:00 +0000759
Chris Lattner3a173df2004-10-03 20:35:00 +0000760def AND8rm : I<0x22, MRMSrcMem,
761 (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000762 "and{b} {$src2, $dst|$dst, $src2}",[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000763def AND16rm : I<0x23, MRMSrcMem,
764 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000765 "and{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000766def AND32rm : I<0x23, MRMSrcMem,
767 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000768 "and{l} {$src2, $dst|$dst, $src2}", []>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000769
Chris Lattner3a173df2004-10-03 20:35:00 +0000770def AND8ri : Ii8<0x80, MRM4r,
771 (ops R8 :$dst, R8 :$src1, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000772 "and{b} {$src2, $dst|$dst, $src2}",
773 [(set R8:$dst, (and R8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000774def AND16ri : Ii16<0x81, MRM4r,
775 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +0000776 "and{w} {$src2, $dst|$dst, $src2}",
777 [(set R16:$dst, (and R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000778def AND32ri : Ii32<0x81, MRM4r,
779 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000780 "and{l} {$src2, $dst|$dst, $src2}",
781 [(set R32:$dst, (and R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000782def AND16ri8 : Ii8<0x83, MRM4r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000783 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
784 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +0000785 [(set R16:$dst, (and R16:$src1, i16immSExt8:$src2))]>,
786 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000787def AND32ri8 : Ii8<0x83, MRM4r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000788 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
789 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +0000790 [(set R32:$dst, (and R32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +0000791
792let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +0000793 def AND8mr : I<0x20, MRMDestMem,
794 (ops i8mem :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000795 "and{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000796 def AND16mr : I<0x21, MRMDestMem,
797 (ops i16mem:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000798 "and{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000799 def AND32mr : I<0x21, MRMDestMem,
800 (ops i32mem:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000801 "and{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000802 def AND8mi : Ii8<0x80, MRM4m,
803 (ops i8mem :$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000804 "and{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000805 def AND16mi : Ii16<0x81, MRM4m,
806 (ops i16mem:$dst, i16imm:$src),
Chris Lattner78432fe2005-11-17 02:01:55 +0000807 "and{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000808 def AND32mi : Ii32<0x81, MRM4m,
809 (ops i32mem:$dst, i32imm:$src),
Chris Lattner7a125372005-11-16 22:59:19 +0000810 "and{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000811 def AND16mi8 : Ii8<0x83, MRM4m,
812 (ops i16mem:$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000813 "and{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000814 def AND32mi8 : Ii8<0x83, MRM4m,
815 (ops i32mem:$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000816 "and{l} {$src, $dst|$dst, $src}", []>;
Chris Lattnerf29ed092004-08-11 05:07:25 +0000817}
818
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000819
Chris Lattnercc65bee2005-01-02 02:35:46 +0000820let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Chris Lattner36b68902004-08-10 21:21:30 +0000821def OR8rr : I<0x08, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000822 "or{b} {$src2, $dst|$dst, $src2}",
823 [(set R8:$dst, (or R8:$src1, R8:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +0000824def OR16rr : I<0x09, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000825 "or{w} {$src2, $dst|$dst, $src2}",
826 [(set R16:$dst, (or R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +0000827def OR32rr : I<0x09, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000828 "or{l} {$src2, $dst|$dst, $src2}",
829 [(set R32:$dst, (or R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000830}
Chris Lattner57a02302004-08-11 04:31:00 +0000831def OR8rm : I<0x0A, MRMSrcMem , (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000832 "or{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +0000833def OR16rm : I<0x0B, MRMSrcMem , (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000834 "or{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +0000835def OR32rm : I<0x0B, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000836 "or{l} {$src2, $dst|$dst, $src2}", []>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000837
Chris Lattner36b68902004-08-10 21:21:30 +0000838def OR8ri : Ii8 <0x80, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000839 "or{b} {$src2, $dst|$dst, $src2}",
840 [(set R8:$dst, (or R8:$src1, imm:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +0000841def OR16ri : Ii16<0x81, MRM1r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +0000842 "or{w} {$src2, $dst|$dst, $src2}",
843 [(set R16:$dst, (or R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +0000844def OR32ri : Ii32<0x81, MRM1r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000845 "or{l} {$src2, $dst|$dst, $src2}",
846 [(set R32:$dst, (or R32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000847
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000848def OR16ri8 : Ii8<0x83, MRM1r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
849 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +0000850 [(set R16:$dst, (or R16:$src1, i16immSExt8:$src2))]>, OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000851def OR32ri8 : Ii8<0x83, MRM1r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
852 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +0000853 [(set R32:$dst, (or R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000854let isTwoAddress = 0 in {
Chris Lattnerf29ed092004-08-11 05:07:25 +0000855 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, R8:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000856 "or{b} {$src, $dst|$dst, $src}", []>;
Chris Lattnerf29ed092004-08-11 05:07:25 +0000857 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000858 "or{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattnerf29ed092004-08-11 05:07:25 +0000859 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000860 "or{l} {$src, $dst|$dst, $src}", []>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +0000861 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000862 "or{b} {$src, $dst|$dst, $src}", []>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +0000863 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
Chris Lattner78432fe2005-11-17 02:01:55 +0000864 "or{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattnerf5d3a832004-08-11 05:31:07 +0000865 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
Chris Lattner7a125372005-11-16 22:59:19 +0000866 "or{l} {$src, $dst|$dst, $src}", []>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +0000867 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000868 "or{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattnerf5d3a832004-08-11 05:31:07 +0000869 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000870 "or{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +0000871}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000872
873
Chris Lattnercc65bee2005-01-02 02:35:46 +0000874let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +0000875def XOR8rr : I<0x30, MRMDestReg,
876 (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000877 "xor{b} {$src2, $dst|$dst, $src2}",
878 [(set R8:$dst, (xor R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000879def XOR16rr : I<0x31, MRMDestReg,
880 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000881 "xor{w} {$src2, $dst|$dst, $src2}",
882 [(set R16:$dst, (xor R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000883def XOR32rr : I<0x31, MRMDestReg,
884 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000885 "xor{l} {$src2, $dst|$dst, $src2}",
886 [(set R32:$dst, (xor R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000887}
888
Chris Lattner3a173df2004-10-03 20:35:00 +0000889def XOR8rm : I<0x32, MRMSrcMem ,
890 (ops R8 :$dst, R8:$src1, i8mem :$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000891 "xor{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000892def XOR16rm : I<0x33, MRMSrcMem ,
893 (ops R16:$dst, R8:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000894 "xor{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000895def XOR32rm : I<0x33, MRMSrcMem ,
896 (ops R32:$dst, R8:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000897 "xor{l} {$src2, $dst|$dst, $src2}", []>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000898
Chris Lattner3a173df2004-10-03 20:35:00 +0000899def XOR8ri : Ii8<0x80, MRM6r,
900 (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000901 "xor{b} {$src2, $dst|$dst, $src2}",
902 [(set R8:$dst, (xor R8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000903def XOR16ri : Ii16<0x81, MRM6r,
904 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +0000905 "xor{w} {$src2, $dst|$dst, $src2}",
906 [(set R16:$dst, (xor R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000907def XOR32ri : Ii32<0x81, MRM6r,
908 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000909 "xor{l} {$src2, $dst|$dst, $src2}",
910 [(set R32:$dst, (xor R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000911def XOR16ri8 : Ii8<0x83, MRM6r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000912 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
913 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +0000914 [(set R16:$dst, (xor R16:$src1, i16immSExt8:$src2))]>,
915 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000916def XOR32ri8 : Ii8<0x83, MRM6r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000917 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
918 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +0000919 [(set R32:$dst, (xor R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000920let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +0000921 def XOR8mr : I<0x30, MRMDestMem,
922 (ops i8mem :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000923 "xor{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000924 def XOR16mr : I<0x31, MRMDestMem,
925 (ops i16mem:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000926 "xor{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000927 def XOR32mr : I<0x31, MRMDestMem,
928 (ops i32mem:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000929 "xor{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000930 def XOR8mi : Ii8<0x80, MRM6m,
931 (ops i8mem :$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000932 "xor{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000933 def XOR16mi : Ii16<0x81, MRM6m,
934 (ops i16mem:$dst, i16imm:$src),
Chris Lattner78432fe2005-11-17 02:01:55 +0000935 "xor{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000936 def XOR32mi : Ii32<0x81, MRM6m,
937 (ops i32mem:$dst, i32imm:$src),
Chris Lattner7a125372005-11-16 22:59:19 +0000938 "xor{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000939 def XOR16mi8 : Ii8<0x83, MRM6m,
940 (ops i16mem:$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000941 "xor{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000942 def XOR32mi8 : Ii8<0x83, MRM6m,
943 (ops i32mem:$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000944 "xor{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +0000945}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000946
947// Shift instructions
Alkis Evlogimenos13d362f2004-03-07 03:19:11 +0000948// FIXME: provide shorter instructions when imm8 == 1
Chris Lattner3a173df2004-10-03 20:35:00 +0000949def SHL8rCL : I<0xD2, MRM4r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +0000950 "shl{b} {%cl, $dst|$dst, %CL}",
951 [(set R8:$dst, (shl R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000952def SHL16rCL : I<0xD3, MRM4r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +0000953 "shl{w} {%cl, $dst|$dst, %CL}",
954 [(set R16:$dst, (shl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000955def SHL32rCL : I<0xD3, MRM4r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +0000956 "shl{l} {%cl, $dst|$dst, %CL}",
957 [(set R32:$dst, (shl R32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000958
Chris Lattner36b68902004-08-10 21:21:30 +0000959def SHL8ri : Ii8<0xC0, MRM4r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000960 "shl{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +0000961 [(set R8:$dst, (shl R8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000962let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3d36a9f2005-12-05 02:40:25 +0000963def SHL16ri : Ii8<0xC1, MRM4r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000964 "shl{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +0000965 [(set R16:$dst, (shl R16:$src1, (i8 imm:$src2)))]>, OpSize;
966def SHL32ri : Ii8<0xC1, MRM4r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000967 "shl{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +0000968 [(set R32:$dst, (shl R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000969}
Chris Lattnerf29ed092004-08-11 05:07:25 +0000970
971let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +0000972 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
Evan Chengf0701842005-11-29 19:38:52 +0000973 "shl{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000974 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +0000975 "shl{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000976 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +0000977 "shl{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000978 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
Chris Lattner5b9bbc82005-11-30 05:11:18 +0000979 "shl{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000980 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
Chris Lattner5b9bbc82005-11-30 05:11:18 +0000981 "shl{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000982 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
Chris Lattner5b9bbc82005-11-30 05:11:18 +0000983 "shl{l} {$src, $dst|$dst, $src}", []>;
Chris Lattnerf29ed092004-08-11 05:07:25 +0000984}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000985
Chris Lattner3a173df2004-10-03 20:35:00 +0000986def SHR8rCL : I<0xD2, MRM5r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +0000987 "shr{b} {%cl, $dst|$dst, %CL}",
988 [(set R8:$dst, (srl R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000989def SHR16rCL : I<0xD3, MRM5r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +0000990 "shr{w} {%cl, $dst|$dst, %CL}",
991 [(set R16:$dst, (srl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000992def SHR32rCL : I<0xD3, MRM5r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +0000993 "shr{l} {%cl, $dst|$dst, %CL}",
994 [(set R32:$dst, (srl R32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000995
Chris Lattner3a173df2004-10-03 20:35:00 +0000996def SHR8ri : Ii8<0xC0, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000997 "shr{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +0000998 [(set R8:$dst, (srl R8:$src1, (i8 imm:$src2)))]>;
999def SHR16ri : Ii8<0xC1, MRM5r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001000 "shr{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001001 [(set R16:$dst, (srl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1002def SHR32ri : Ii8<0xC1, MRM5r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001003 "shr{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001004 [(set R32:$dst, (srl R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001005
Chris Lattner57a02302004-08-11 04:31:00 +00001006let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001007 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001008 "shr{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001009 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001010 "shr{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001011 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001012 "shr{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001013 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001014 "shr{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001015 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001016 "shr{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001017 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001018 "shr{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001019}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001020
Chris Lattner3a173df2004-10-03 20:35:00 +00001021def SAR8rCL : I<0xD2, MRM7r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001022 "sar{b} {%cl, $dst|$dst, %CL}",
1023 [(set R8:$dst, (sra R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001024def SAR16rCL : I<0xD3, MRM7r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001025 "sar{w} {%cl, $dst|$dst, %CL}",
1026 [(set R16:$dst, (sra R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001027def SAR32rCL : I<0xD3, MRM7r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001028 "sar{l} {%cl, $dst|$dst, %CL}",
1029 [(set R32:$dst, (sra R32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001030
Chris Lattner36b68902004-08-10 21:21:30 +00001031def SAR8ri : Ii8<0xC0, MRM7r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001032 "sar{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001033 [(set R8:$dst, (sra R8:$src1, (i8 imm:$src2)))]>;
1034def SAR16ri : Ii8<0xC1, MRM7r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001035 "sar{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001036 [(set R16:$dst, (sra R16:$src1, (i8 imm:$src2)))]>,
1037 OpSize;
1038def SAR32ri : Ii8<0xC1, MRM7r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001039 "sar{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001040 [(set R32:$dst, (sra R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001041let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001042 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001043 "sar{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001044 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001045 "sar{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001046 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001047 "sar{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001048 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001049 "sar{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001050 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001051 "sar{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001052 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001053 "sar{l} {$src, $dst|$dst, $src}", []>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001054}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001055
Chris Lattner40ff6332005-01-19 07:50:03 +00001056// Rotate instructions
1057// FIXME: provide shorter instructions when imm8 == 1
1058def ROL8rCL : I<0xD2, MRM0r, (ops R8 :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001059 "rol{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001060def ROL16rCL : I<0xD3, MRM0r, (ops R16:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001061 "rol{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001062def ROL32rCL : I<0xD3, MRM0r, (ops R32:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001063 "rol{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001064
1065def ROL8ri : Ii8<0xC0, MRM0r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001066 "rol{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001067def ROL16ri : Ii8<0xC1, MRM0r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001068 "rol{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001069def ROL32ri : Ii8<0xC1, MRM0r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001070 "rol{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001071
1072let isTwoAddress = 0 in {
1073 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001074 "rol{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001075 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001076 "rol{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001077 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001078 "rol{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001079 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001080 "rol{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001081 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001082 "rol{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001083 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001084 "rol{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001085}
1086
1087def ROR8rCL : I<0xD2, MRM1r, (ops R8 :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001088 "ror{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001089def ROR16rCL : I<0xD3, MRM1r, (ops R16:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001090 "ror{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001091def ROR32rCL : I<0xD3, MRM1r, (ops R32:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001092 "ror{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001093
1094def ROR8ri : Ii8<0xC0, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001095 "ror{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001096def ROR16ri : Ii8<0xC1, MRM1r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001097 "ror{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001098def ROR32ri : Ii8<0xC1, MRM1r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001099 "ror{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001100let isTwoAddress = 0 in {
1101 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001102 "ror{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001103 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001104 "ror{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001105 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001106 "ror{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001107 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001108 "ror{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001109 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001110 "ror{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001111 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001112 "ror{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001113}
1114
1115
1116
1117// Double shift instructions (generalizations of rotate)
1118
Chris Lattner57a02302004-08-11 04:31:00 +00001119def SHLD32rrCL : I<0xA5, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001120 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001121 Imp<[CL],[]>, TB;
Chris Lattner57a02302004-08-11 04:31:00 +00001122def SHRD32rrCL : I<0xAD, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001123 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001124 Imp<[CL],[]>, TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001125def SHLD16rrCL : I<0xA5, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001126 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001127 Imp<[CL],[]>, TB, OpSize;
1128def SHRD16rrCL : I<0xAD, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001129 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001130 Imp<[CL],[]>, TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001131
1132let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001133def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1134 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001135 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001136def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1137 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001138 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>, TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001139def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1140 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001141 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001142 TB, OpSize;
1143def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1144 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001145 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001146 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001147}
Chris Lattner0e967d42004-08-01 08:13:11 +00001148
Chris Lattner57a02302004-08-11 04:31:00 +00001149let isTwoAddress = 0 in {
1150 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001151 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001152 Imp<[CL],[]>, TB;
Chris Lattner57a02302004-08-11 04:31:00 +00001153 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001154 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001155 Imp<[CL],[]>, TB;
1156 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1157 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001158 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1159 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001160 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1161 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001162 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1163 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001164
1165 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001166 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001167 Imp<[CL],[]>, TB, OpSize;
1168 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001169 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001170 Imp<[CL],[]>, TB, OpSize;
1171 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1172 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001173 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001174 TB, OpSize;
1175 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1176 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001177 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001178 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001179}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001180
1181
Chris Lattnercc65bee2005-01-02 02:35:46 +00001182// Arithmetic.
1183let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001184def ADD8rr : I<0x00, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001185 "add{b} {$src2, $dst|$dst, $src2}",
1186 [(set R8:$dst, (add R8:$src1, R8:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001187let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3a173df2004-10-03 20:35:00 +00001188def ADD16rr : I<0x01, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001189 "add{w} {$src2, $dst|$dst, $src2}",
1190 [(set R16:$dst, (add R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001191def ADD32rr : I<0x01, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001192 "add{l} {$src2, $dst|$dst, $src2}",
1193 [(set R32:$dst, (add R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001194} // end isConvertibleToThreeAddress
1195} // end isCommutable
Chris Lattner3a173df2004-10-03 20:35:00 +00001196def ADD8rm : I<0x02, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001197 "add{b} {$src2, $dst|$dst, $src2}",
1198 [(set R8:$dst, (add R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001199def ADD16rm : I<0x03, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001200 "add{w} {$src2, $dst|$dst, $src2}",
1201 [(set R16:$dst, (add R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001202def ADD32rm : I<0x03, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001203 "add{l} {$src2, $dst|$dst, $src2}",
1204 [(set R32:$dst, (add R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001205
Chris Lattner3a173df2004-10-03 20:35:00 +00001206def ADD8ri : Ii8<0x80, MRM0r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001207 "add{b} {$src2, $dst|$dst, $src2}",
1208 [(set R8:$dst, (add R8:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001209
1210let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3a173df2004-10-03 20:35:00 +00001211def ADD16ri : Ii16<0x81, MRM0r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001212 "add{w} {$src2, $dst|$dst, $src2}",
1213 [(set R16:$dst, (add R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001214def ADD32ri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001215 "add{l} {$src2, $dst|$dst, $src2}",
1216 [(set R32:$dst, (add R32:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001217}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001218
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001219// FIXME: move ADD16ri8 above ADD16ri to optimize for space.
1220def ADD16ri8 : Ii8<0x83, MRM0r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1221 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001222 [(set R16:$dst, (add R16:$src1, i16immSExt8:$src2))]>,
1223 OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001224def ADD32ri8 : Ii8<0x83, MRM0r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1225 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001226 [(set R32:$dst, (add R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001227
1228let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001229 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001230 "add{b} {$src2, $dst|$dst, $src2}",
1231 [(store (add (load addr:$dst), R8:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001232 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001233 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001234 [(store (add (load addr:$dst), R16:$src2), addr:$dst)]>,
1235 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001236 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001237 "add{l} {$src2, $dst|$dst, $src2}",
1238 [(store (add (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001239 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001240 "add{b} {$src2, $dst|$dst, $src2}",
1241 [(store (add (load addr:$dst), (i8 imm:$src2)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001242 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001243 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001244 [(store (add (load addr:$dst), (i16 imm:$src2)), addr:$dst)]>,
1245 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001246 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001247 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001248 [(store (add (load addr:$dst), (i32 imm:$src2)), addr:$dst)]>;
Evan Chengee93f9d2005-12-12 19:45:23 +00001249 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1250 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001251 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1252 OpSize;
Evan Chengee93f9d2005-12-12 19:45:23 +00001253 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1254 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001255 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001256}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001257
Chris Lattner10197ff2005-01-03 01:27:59 +00001258let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001259def ADC32rr : I<0x11, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001260 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner10197ff2005-01-03 01:27:59 +00001261}
Chris Lattner3a173df2004-10-03 20:35:00 +00001262def ADC32rm : I<0x13, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001263 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001264def ADC32ri : Ii32<0x81, MRM2r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001265 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001266def ADC32ri8 : Ii8<0x83, MRM2r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001267 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001268
1269let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001270 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001271 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001272 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001273 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001274 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001275 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001276}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001277
Chris Lattner3a173df2004-10-03 20:35:00 +00001278def SUB8rr : I<0x28, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001279 "sub{b} {$src2, $dst|$dst, $src2}",
1280 [(set R8:$dst, (sub R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001281def SUB16rr : I<0x29, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001282 "sub{w} {$src2, $dst|$dst, $src2}",
1283 [(set R16:$dst, (sub R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001284def SUB32rr : I<0x29, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001285 "sub{l} {$src2, $dst|$dst, $src2}",
1286 [(set R32:$dst, (sub R32:$src1, R32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001287def SUB8rm : I<0x2A, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001288 "sub{b} {$src2, $dst|$dst, $src2}",
1289 [(set R8:$dst, (sub R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001290def SUB16rm : I<0x2B, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001291 "sub{w} {$src2, $dst|$dst, $src2}",
1292 [(set R16:$dst, (sub R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001293def SUB32rm : I<0x2B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001294 "sub{l} {$src2, $dst|$dst, $src2}",
1295 [(set R32:$dst, (sub R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001296
Chris Lattner36b68902004-08-10 21:21:30 +00001297def SUB8ri : Ii8 <0x80, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001298 "sub{b} {$src2, $dst|$dst, $src2}",
1299 [(set R8:$dst, (sub R8:$src1, imm:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001300def SUB16ri : Ii16<0x81, MRM5r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001301 "sub{w} {$src2, $dst|$dst, $src2}",
1302 [(set R16:$dst, (sub R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001303def SUB32ri : Ii32<0x81, MRM5r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001304 "sub{l} {$src2, $dst|$dst, $src2}",
1305 [(set R32:$dst, (sub R32:$src1, imm:$src2))]>;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001306def SUB16ri8 : Ii8<0x83, MRM5r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1307 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001308 [(set R16:$dst, (sub R16:$src1, i16immSExt8:$src2))]>,
1309 OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001310def SUB32ri8 : Ii8<0x83, MRM5r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1311 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001312 [(set R32:$dst, (sub R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001313let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001314 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001315 "sub{b} {$src2, $dst|$dst, $src2}",
1316 [(store (sub (load addr:$dst), R8:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001317 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001318 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001319 [(store (sub (load addr:$dst), R16:$src2), addr:$dst)]>,
1320 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001321 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001322 "sub{l} {$src2, $dst|$dst, $src2}",
1323 [(store (sub (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001324 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001325 "sub{b} {$src2, $dst|$dst, $src2}",
1326 [(store (sub (load addr:$dst), (i8 imm:$src2)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001327 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001328 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001329 [(store (sub (load addr:$dst), (i16 imm:$src2)), addr:$dst)]>,
1330 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001331 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001332 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001333 [(store (sub (load addr:$dst), (i32 imm:$src2)), addr:$dst)]>;
Evan Chengd160d482005-12-12 21:54:05 +00001334 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1335 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001336 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1337 OpSize;
Evan Chengd160d482005-12-12 21:54:05 +00001338 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1339 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001340 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001341}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001342
Chris Lattner3a173df2004-10-03 20:35:00 +00001343def SBB32rr : I<0x19, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001344 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001345
Chris Lattner57a02302004-08-11 04:31:00 +00001346let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001347 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001348 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001349 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001350 "sbb{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001351 def SBB16mi : Ii32<0x81, MRM3m, (ops i16mem:$dst, i16imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001352 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001353 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001354 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001355 def SBB16mi8 : Ii8<0x83, MRM3m, (ops i16mem:$dst, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001356 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001357 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001358 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001359}
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001360def SBB8ri : Ii8<0x80, MRM3r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001361 "sbb{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001362def SBB16ri : Ii16<0x81, MRM3r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001363 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001364
Chris Lattner57a02302004-08-11 04:31:00 +00001365def SBB32rm : I<0x1B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001366 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner36b68902004-08-10 21:21:30 +00001367def SBB32ri : Ii32<0x81, MRM3r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001368 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001369
Chris Lattner09c750f2004-10-06 14:31:50 +00001370def SBB16ri8 : Ii8<0x83, MRM3r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001371 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001372def SBB32ri8 : Ii8<0x83, MRM3r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001373 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001374
Chris Lattner10197ff2005-01-03 01:27:59 +00001375let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001376def IMUL16rr : I<0xAF, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001377 "imul{w} {$src2, $dst|$dst, $src2}",
1378 [(set R16:$dst, (mul R16:$src1, R16:$src2))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001379def IMUL32rr : I<0xAF, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001380 "imul{l} {$src2, $dst|$dst, $src2}",
1381 [(set R32:$dst, (mul R32:$src1, R32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00001382}
Chris Lattner3a173df2004-10-03 20:35:00 +00001383def IMUL16rm : I<0xAF, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001384 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001385 [(set R16:$dst, (mul R16:$src1, (load addr:$src2)))]>,
1386 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001387def IMUL32rm : I<0xAF, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001388 "imul{l} {$src2, $dst|$dst, $src2}",
1389 [(set R32:$dst, (mul R32:$src1, (load addr:$src2)))]>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001390
1391} // end Two Address instructions
1392
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001393// Suprisingly enough, these are not two address instructions!
Chris Lattner3a173df2004-10-03 20:35:00 +00001394def IMUL16rri : Ii16<0x69, MRMSrcReg, // R16 = R16*I16
1395 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001396 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Chengf281e022005-12-12 23:47:46 +00001397 [(set R16:$dst, (mul R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001398def IMUL32rri : Ii32<0x69, MRMSrcReg, // R32 = R32*I32
1399 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001400 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1401 [(set R32:$dst, (mul R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001402def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // R16 = R16*I8
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001403 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1404 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001405 [(set R16:$dst, (mul R16:$src1, i16immSExt8:$src2))]>,
1406 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001407def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // R32 = R32*I8
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001408 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1409 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001410 [(set R32:$dst, (mul R32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001411
Chris Lattner3a173df2004-10-03 20:35:00 +00001412def IMUL16rmi : Ii16<0x69, MRMSrcMem, // R16 = [mem16]*I16
Evan Chengf281e022005-12-12 23:47:46 +00001413 (ops R16:$dst, i16mem:$src1, i16imm:$src2),
1414 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1415 [(set R16:$dst, (mul (load addr:$src1), imm:$src2))]>,
1416 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001417def IMUL32rmi : Ii32<0x69, MRMSrcMem, // R32 = [mem32]*I32
1418 (ops R32:$dst, i32mem:$src1, i32imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001419 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1420 [(set R32:$dst, (mul (load addr:$src1), imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001421def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // R16 = [mem16]*I8
Evan Chengf281e022005-12-12 23:47:46 +00001422 (ops R16:$dst, i16mem:$src1, i16i8imm :$src2),
1423 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001424 [(set R16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
1425 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001426def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // R32 = [mem32]*I8
Evan Chengf281e022005-12-12 23:47:46 +00001427 (ops R32:$dst, i32mem:$src1, i32i8imm: $src2),
1428 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001429 [(set R32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001430
1431//===----------------------------------------------------------------------===//
1432// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00001433//
Chris Lattnercc65bee2005-01-02 02:35:46 +00001434let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Chris Lattner36b68902004-08-10 21:21:30 +00001435def TEST8rr : I<0x84, MRMDestReg, (ops R8:$src1, R8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001436 "test{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner36b68902004-08-10 21:21:30 +00001437def TEST16rr : I<0x85, MRMDestReg, (ops R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001438 "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001439def TEST32rr : I<0x85, MRMDestReg, (ops R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001440 "test{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001441}
Chris Lattner57a02302004-08-11 04:31:00 +00001442def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001443 "test{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001444def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001445 "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001446def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001447 "test{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001448def TEST8rm : I<0x84, MRMSrcMem, (ops R8 :$src1, i8mem :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001449 "test{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001450def TEST16rm : I<0x85, MRMSrcMem, (ops R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001451 "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001452def TEST32rm : I<0x85, MRMSrcMem, (ops R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001453 "test{l} {$src2, $src1|$src1, $src2}", []>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001454
Chris Lattner707c6fe2004-10-04 01:38:10 +00001455def TEST8ri : Ii8 <0xF6, MRM0r, // flags = R8 & imm8
1456 (ops R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001457 "test{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001458def TEST16ri : Ii16<0xF7, MRM0r, // flags = R16 & imm16
1459 (ops R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001460 "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001461def TEST32ri : Ii32<0xF7, MRM0r, // flags = R32 & imm32
1462 (ops R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001463 "test{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001464def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
1465 (ops i32mem:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001466 "test{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001467def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
1468 (ops i16mem:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001469 "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001470def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
1471 (ops i32mem:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001472 "test{l} {$src2, $src1|$src1, $src2}", []>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001473
1474
1475
1476// Condition code ops, incl. set if equal/not equal/...
Evan Chengf0701842005-11-29 19:38:52 +00001477def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
1478def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001479
Chris Lattner3a173df2004-10-03 20:35:00 +00001480def SETBr : I<0x92, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001481 (ops R8 :$dst), "setb $dst", []>, TB; // R8 = < unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00001482def SETBm : I<0x92, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001483 (ops i8mem:$dst), "setb $dst", []>, TB; // [mem8] = < unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00001484def SETAEr : I<0x93, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001485 (ops R8 :$dst), "setae $dst", []>, TB; // R8 = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00001486def SETAEm : I<0x93, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001487 (ops i8mem:$dst), "setae $dst", []>, TB; // [mem8] = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00001488def SETEr : I<0x94, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001489 (ops R8 :$dst), "sete $dst", []>, TB; // R8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00001490def SETEm : I<0x94, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001491 (ops i8mem:$dst), "sete $dst", []>, TB; // [mem8] = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00001492def SETNEr : I<0x95, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001493 (ops R8 :$dst), "setne $dst", []>, TB; // R8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00001494def SETNEm : I<0x95, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001495 (ops i8mem:$dst), "setne $dst", []>, TB; // [mem8] = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00001496def SETBEr : I<0x96, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001497 (ops R8 :$dst), "setbe $dst", []>, TB; // R8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00001498def SETBEm : I<0x96, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001499 (ops i8mem:$dst), "setbe $dst", []>, TB; // [mem8] = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00001500def SETAr : I<0x97, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001501 (ops R8 :$dst), "seta $dst", []>, TB; // R8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001502def SETAm : I<0x97, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001503 (ops i8mem:$dst), "seta $dst", []>, TB; // [mem8] = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001504def SETSr : I<0x98, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001505 (ops R8 :$dst), "sets $dst", []>, TB; // R8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00001506def SETSm : I<0x98, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001507 (ops i8mem:$dst), "sets $dst", []>, TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00001508def SETNSr : I<0x99, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001509 (ops R8 :$dst), "setns $dst", []>, TB; // R8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00001510def SETNSm : I<0x99, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001511 (ops i8mem:$dst), "setns $dst", []>, TB; // [mem8] = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00001512def SETPr : I<0x9A, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001513 (ops R8 :$dst), "setp $dst", []>, TB; // R8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00001514def SETPm : I<0x9A, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001515 (ops i8mem:$dst), "setp $dst", []>, TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00001516def SETNPr : I<0x9B, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001517 (ops R8 :$dst), "setnp $dst", []>, TB; // R8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00001518def SETNPm : I<0x9B, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001519 (ops i8mem:$dst), "setnp $dst", []>, TB; // [mem8] = not parity
Chris Lattner3a173df2004-10-03 20:35:00 +00001520def SETLr : I<0x9C, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001521 (ops R8 :$dst), "setl $dst", []>, TB; // R8 = < signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001522def SETLm : I<0x9C, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001523 (ops i8mem:$dst), "setl $dst", []>, TB; // [mem8] = < signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001524def SETGEr : I<0x9D, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001525 (ops R8 :$dst), "setge $dst", []>, TB; // R8 = >= signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001526def SETGEm : I<0x9D, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001527 (ops i8mem:$dst), "setge $dst", []>, TB; // [mem8] = >= signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001528def SETLEr : I<0x9E, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001529 (ops R8 :$dst), "setle $dst", []>, TB; // R8 = <= signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001530def SETLEm : I<0x9E, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001531 (ops i8mem:$dst), "setle $dst", []>, TB; // [mem8] = <= signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001532def SETGr : I<0x9F, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001533 (ops R8 :$dst), "setg $dst", []>, TB; // R8 = < signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001534def SETGm : I<0x9F, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001535 (ops i8mem:$dst), "setg $dst", []>, TB; // [mem8] = < signed
Chris Lattner1cca5e32003-08-03 21:54:21 +00001536
1537// Integer comparisons
Chris Lattner3a173df2004-10-03 20:35:00 +00001538def CMP8rr : I<0x38, MRMDestReg,
1539 (ops R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001540 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001541def CMP16rr : I<0x39, MRMDestReg,
1542 (ops R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001543 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001544def CMP32rr : I<0x39, MRMDestReg,
1545 (ops R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001546 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001547def CMP8mr : I<0x38, MRMDestMem,
1548 (ops i8mem :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001549 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001550def CMP16mr : I<0x39, MRMDestMem,
1551 (ops i16mem:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001552 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001553def CMP32mr : I<0x39, MRMDestMem,
1554 (ops i32mem:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001555 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001556def CMP8rm : I<0x3A, MRMSrcMem,
1557 (ops R8 :$src1, i8mem :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001558 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001559def CMP16rm : I<0x3B, MRMSrcMem,
1560 (ops R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001561 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001562def CMP32rm : I<0x3B, MRMSrcMem,
1563 (ops R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001564 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001565def CMP8ri : Ii8<0x80, MRM7r,
1566 (ops R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001567 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001568def CMP16ri : Ii16<0x81, MRM7r,
1569 (ops R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001570 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001571def CMP32ri : Ii32<0x81, MRM7r,
1572 (ops R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001573 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001574def CMP8mi : Ii8 <0x80, MRM7m,
1575 (ops i8mem :$src1, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001576 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001577def CMP16mi : Ii16<0x81, MRM7m,
1578 (ops i16mem:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001579 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001580def CMP32mi : Ii32<0x81, MRM7m,
1581 (ops i32mem:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001582 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00001583
1584// Sign/Zero extenders
Chris Lattner3a173df2004-10-03 20:35:00 +00001585def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops R16:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001586 "movs{bw|x} {$src, $dst|$dst, $src}",
1587 [(set R16:$dst, (sext R8:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001588def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops R16:$dst, i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001589 "movs{bw|x} {$src, $dst|$dst, $src}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001590def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops R32:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001591 "movs{bl|x} {$src, $dst|$dst, $src}",
1592 [(set R32:$dst, (sext R8:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001593def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops R32:$dst, i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001594 "movs{bl|x} {$src, $dst|$dst, $src}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001595def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops R32:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001596 "movs{wl|x} {$src, $dst|$dst, $src}",
1597 [(set R32:$dst, (sext R16:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001598def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops R32:$dst, i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001599 "movs{wl|x} {$src, $dst|$dst, $src}", []>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00001600
Chris Lattner3a173df2004-10-03 20:35:00 +00001601def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops R16:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001602 "movz{bw|x} {$src, $dst|$dst, $src}",
1603 [(set R16:$dst, (zext R8:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001604def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops R16:$dst, i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001605 "movz{bw|x} {$src, $dst|$dst, $src}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001606def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops R32:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001607 "movz{bl|x} {$src, $dst|$dst, $src}",
1608 [(set R32:$dst, (zext R8:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001609def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops R32:$dst, i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001610 "movz{bl|x} {$src, $dst|$dst, $src}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001611def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops R32:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001612 "movz{wl|x} {$src, $dst|$dst, $src}",
1613 [(set R32:$dst, (zext R16:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001614def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops R32:$dst, i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001615 "movz{wl|x} {$src, $dst|$dst, $src}", []>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +00001616
Nate Begemanf1702ac2005-06-27 21:20:31 +00001617//===----------------------------------------------------------------------===//
1618// XMM Floating point support (requires SSE2)
1619//===----------------------------------------------------------------------===//
1620
Nate Begeman14e2cf62005-10-14 22:06:00 +00001621def MOVSSrr : I<0x10, MRMSrcReg, (ops V4F4:$dst, V4F4:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001622 "movss {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001623def MOVSSrm : I<0x10, MRMSrcMem, (ops V4F4:$dst, f32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001624 "movss {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001625def MOVSSmr : I<0x11, MRMDestMem, (ops f32mem:$dst, V4F4:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001626 "movss {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001627def MOVSDrr : I<0x10, MRMSrcReg, (ops V2F8:$dst, V2F8:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001628 "movsd {$src, $dst|$dst, $src}", []>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001629def MOVSDrm : I<0x10, MRMSrcMem, (ops V2F8:$dst, f64mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001630 "movsd {$src, $dst|$dst, $src}", []>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001631def MOVSDmr : I<0x11, MRMDestMem, (ops f64mem:$dst, V2F8:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001632 "movsd {$src, $dst|$dst, $src}", []>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001633
Nate Begeman14e2cf62005-10-14 22:06:00 +00001634def CVTTSD2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, V2F8:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001635 "cvttsd2si {$src, $dst|$dst, $src}",
1636 [(set R32:$dst, (fp_to_sint V2F8:$src))]>, XD;
Nate Begeman16b04f32005-07-15 00:38:55 +00001637def CVTTSD2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f64mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001638 "cvttsd2si {$src, $dst|$dst, $src}", []>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001639def CVTTSS2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, V4F4:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001640 "cvttss2si {$src, $dst|$dst, $src}",
1641 [(set R32:$dst, (fp_to_sint V4F4:$src))]>, XS;
Nate Begeman16b04f32005-07-15 00:38:55 +00001642def CVTTSS2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001643 "cvttss2si {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001644def CVTSD2SSrr: I<0x5A, MRMSrcReg, (ops V4F4:$dst, V2F8:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001645 "cvtsd2ss {$src, $dst|$dst, $src}",
1646 [(set V4F4:$dst, (fround V2F8:$src))]>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001647def CVTSD2SSrm: I<0x5A, MRMSrcMem, (ops V4F4:$dst, f64mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001648 "cvtsd2ss {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001649def CVTSS2SDrr: I<0x5A, MRMSrcReg, (ops V2F8:$dst, V4F4:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001650 "cvtss2sd {$src, $dst|$dst, $src}",
1651 [(set V2F8:$dst, (fextend V4F4:$src))]>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001652def CVTSS2SDrm: I<0x5A, MRMSrcMem, (ops V2F8:$dst, f32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001653 "cvtss2sd {$src, $dst|$dst, $src}", []>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001654def CVTSI2SSrr: I<0x2A, MRMSrcReg, (ops V4F4:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001655 "cvtsi2ss {$src, $dst|$dst, $src}",
1656 [(set V4F4:$dst, (sint_to_fp R32:$src))]>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001657def CVTSI2SSrm: I<0x2A, MRMSrcMem, (ops V4F4:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001658 "cvtsi2ss {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001659def CVTSI2SDrr: I<0x2A, MRMSrcReg, (ops V2F8:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001660 "cvtsi2sd {$src, $dst|$dst, $src}",
1661 [(set V2F8:$dst, (sint_to_fp R32:$src))]>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001662def CVTSI2SDrm: I<0x2A, MRMSrcMem, (ops V2F8:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001663 "cvtsi2sd {$src, $dst|$dst, $src}", []>, XD;
Nate Begemanf63be7d2005-07-06 18:59:04 +00001664
Nate Begeman14e2cf62005-10-14 22:06:00 +00001665def SQRTSSrm : I<0x51, MRMSrcMem, (ops V4F4:$dst, f32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001666 "sqrtss {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001667def SQRTSSrr : I<0x51, MRMSrcReg, (ops V4F4:$dst, V4F4:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001668 "sqrtss {$src, $dst|$dst, $src}",
1669 [(set V4F4:$dst, (fsqrt V4F4:$src))]>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001670def SQRTSDrm : I<0x51, MRMSrcMem, (ops V2F8:$dst, f64mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001671 "sqrtsd {$src, $dst|$dst, $src}", []>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001672def SQRTSDrr : I<0x51, MRMSrcReg, (ops V2F8:$dst, V2F8:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001673 "sqrtsd {$src, $dst|$dst, $src}",
1674 [(set V2F8:$dst, (fsqrt V2F8:$src))]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001675
Nate Begeman14e2cf62005-10-14 22:06:00 +00001676def UCOMISDrr: I<0x2E, MRMSrcReg, (ops V2F8:$dst, V2F8:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001677 "ucomisd {$src, $dst|$dst, $src}", []>, TB, OpSize;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001678def UCOMISDrm: I<0x2E, MRMSrcMem, (ops V2F8:$dst, f64mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001679 "ucomisd {$src, $dst|$dst, $src}", []>, TB, OpSize;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001680def UCOMISSrr: I<0x2E, MRMSrcReg, (ops V4F4:$dst, V4F4:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001681 "ucomiss {$src, $dst|$dst, $src}", []>, TB;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001682def UCOMISSrm: I<0x2E, MRMSrcMem, (ops V4F4:$dst, f32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001683 "ucomiss {$src, $dst|$dst, $src}", []>, TB;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001684
Evan Chengf0701842005-11-29 19:38:52 +00001685// Pseudo-instructions that map fld0 to xorps/xorpd for sse.
Nate Begeman1c73c7b2005-08-03 23:26:28 +00001686// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Nate Begeman14e2cf62005-10-14 22:06:00 +00001687def FLD0SS : I<0x57, MRMSrcReg, (ops V4F4:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001688 "xorps $dst, $dst", []>, TB;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001689def FLD0SD : I<0x57, MRMSrcReg, (ops V2F8:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001690 "xorpd $dst, $dst", []>, TB, OpSize;
Nate Begeman1c73c7b2005-08-03 23:26:28 +00001691
Nate Begemanf1702ac2005-06-27 21:20:31 +00001692let isTwoAddress = 1 in {
1693let isCommutable = 1 in {
Evan Chengf0701842005-11-29 19:38:52 +00001694def ADDSSrr : I<0x58, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1695 "addss {$src2, $dst|$dst, $src2}",
1696 [(set V4F4:$dst, (fadd V4F4:$src1, V4F4:$src2))]>, XS;
1697def ADDSDrr : I<0x58, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1698 "addsd {$src2, $dst|$dst, $src2}",
1699 [(set V2F8:$dst, (fadd V2F8:$src1, V2F8:$src2))]>, XD;
1700def ANDPSrr : I<0x54, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1701 "andps {$src2, $dst|$dst, $src2}", []>, TB;
1702def ANDPDrr : I<0x54, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1703 "andpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
1704def MULSSrr : I<0x59, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1705 "mulss {$src2, $dst|$dst, $src2}",
1706 [(set V4F4:$dst, (fmul V4F4:$src1, V4F4:$src2))]>, XS;
1707def MULSDrr : I<0x59, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1708 "mulsd {$src2, $dst|$dst, $src2}",
1709 [(set V2F8:$dst, (fmul V2F8:$src1, V2F8:$src2))]>, XD;
1710def ORPSrr : I<0x56, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1711 "orps {$src2, $dst|$dst, $src2}", []>, TB;
1712def ORPDrr : I<0x56, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1713 "orpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
1714def XORPSrr : I<0x57, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1715 "xorps {$src2, $dst|$dst, $src2}", []>, TB;
1716def XORPDrr : I<0x57, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1717 "xorpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001718}
Evan Chengf0701842005-11-29 19:38:52 +00001719def ANDNPSrr : I<0x55, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1720 "andnps {$src2, $dst|$dst, $src2}", []>, TB;
1721def ANDNPDrr : I<0x55, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1722 "andnpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
1723def ADDSSrm : I<0x58, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
1724 "addss {$src2, $dst|$dst, $src2}", []>, XS;
1725def ADDSDrm : I<0x58, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
1726 "addsd {$src2, $dst|$dst, $src2}", []>, XD;
1727def MULSSrm : I<0x59, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
1728 "mulss {$src2, $dst|$dst, $src2}", []>, XS;
1729def MULSDrm : I<0x59, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
1730 "mulsd {$src2, $dst|$dst, $src2}", []>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001731
Evan Chengf0701842005-11-29 19:38:52 +00001732def DIVSSrm : I<0x5E, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
1733 "divss {$src2, $dst|$dst, $src2}", []>, XS;
1734def DIVSSrr : I<0x5E, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1735 "divss {$src2, $dst|$dst, $src2}",
1736 [(set V4F4:$dst, (fdiv V4F4:$src1, V4F4:$src2))]>, XS;
1737def DIVSDrm : I<0x5E, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
1738 "divsd {$src2, $dst|$dst, $src2}", []>, XD;
1739def DIVSDrr : I<0x5E, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1740 "divsd {$src2, $dst|$dst, $src2}",
1741 [(set V2F8:$dst, (fdiv V2F8:$src1, V2F8:$src2))]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001742
Evan Chengf0701842005-11-29 19:38:52 +00001743def SUBSSrm : I<0x5C, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
1744 "subss {$src2, $dst|$dst, $src2}", []>, XS;
1745def SUBSSrr : I<0x5C, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1746 "subss {$src2, $dst|$dst, $src2}",
1747 [(set V4F4:$dst, (fsub V4F4:$src1, V4F4:$src2))]>, XS;
1748def SUBSDrm : I<0x5C, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
1749 "subsd {$src2, $dst|$dst, $src2}", []>, XD;
1750def SUBSDrr : I<0x5C, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1751 "subsd {$src2, $dst|$dst, $src2}",
1752 [(set V2F8:$dst, (fsub V2F8:$src1, V2F8:$src2))]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001753
1754def CMPSSrr : I<0xC2, MRMSrcReg,
Nate Begeman14e2cf62005-10-14 22:06:00 +00001755 (ops V4F4:$dst, V4F4:$src1, V4F4:$src, SSECC:$cc),
Evan Chengf0701842005-11-29 19:38:52 +00001756 "cmp${cc}ss {$src, $dst|$dst, $src}", []>, XS;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001757def CMPSSrm : I<0xC2, MRMSrcMem,
Nate Begeman14e2cf62005-10-14 22:06:00 +00001758 (ops V4F4:$dst, V4F4:$src1, f32mem:$src, SSECC:$cc),
Evan Chengf0701842005-11-29 19:38:52 +00001759 "cmp${cc}ss {$src, $dst|$dst, $src}", []>, XS;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001760def CMPSDrr : I<0xC2, MRMSrcReg,
Nate Begeman14e2cf62005-10-14 22:06:00 +00001761 (ops V2F8:$dst, V2F8:$src1, V2F8:$src, SSECC:$cc),
Evan Chengf0701842005-11-29 19:38:52 +00001762 "cmp${cc}sd {$src, $dst|$dst, $src}", []>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001763def CMPSDrm : I<0xC2, MRMSrcMem,
Nate Begeman14e2cf62005-10-14 22:06:00 +00001764 (ops V2F8:$dst, V2F8:$src1, f64mem:$src, SSECC:$cc),
Evan Chengf0701842005-11-29 19:38:52 +00001765 "cmp${cc}sd {$src, $dst|$dst, $src}", []>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001766}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001767
1768//===----------------------------------------------------------------------===//
Chris Lattner441b2232005-11-20 22:13:18 +00001769// Miscellaneous Instructions
1770//===----------------------------------------------------------------------===//
1771
Evan Chengf0701842005-11-29 19:38:52 +00001772def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", []>, TB, Imp<[],[EAX,EDX]>;
Chris Lattner441b2232005-11-20 22:13:18 +00001773
1774
1775//===----------------------------------------------------------------------===//
Nate Begemanf1702ac2005-06-27 21:20:31 +00001776// Stack-based Floating point support
Chris Lattner1cca5e32003-08-03 21:54:21 +00001777//===----------------------------------------------------------------------===//
1778
1779// FIXME: These need to indicate mod/ref sets for FP regs... & FP 'TOP'
1780
Chris Lattner9795b3a2004-08-11 06:50:10 +00001781// Floating point instruction template
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001782class FPI<bits<8> o, Format F, FPFormat fp, dag ops, string asm>
Chris Lattnerc96bb812004-08-11 07:12:04 +00001783 : X86Inst<o, F, NoImm, ops, asm> {
Chris Lattner9795b3a2004-08-11 06:50:10 +00001784 let FPForm = fp; let FPFormBits = FPForm.Value;
1785}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001786
Chris Lattner9f8fd6d2004-02-02 19:31:38 +00001787// Pseudo instructions for floating point. We use these pseudo instructions
1788// because they can be expanded by the fp spackifier into one of many different
1789// forms of instructions for doing these operations. Until the stackifier runs,
1790// we prefer to be abstract.
Chris Lattner3a173df2004-10-03 20:35:00 +00001791def FpMOV : FPI<0, Pseudo, SpecialFP,
Chris Lattner43ef1312005-09-14 21:10:24 +00001792 (ops RFP:$dst, RFP:$src), "">; // f1 = fmov f2
Chris Lattner3a173df2004-10-03 20:35:00 +00001793def FpADD : FPI<0, Pseudo, TwoArgFP ,
Chris Lattner43ef1312005-09-14 21:10:24 +00001794 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fadd f2, f3
Chris Lattner3a173df2004-10-03 20:35:00 +00001795def FpSUB : FPI<0, Pseudo, TwoArgFP ,
Chris Lattner43ef1312005-09-14 21:10:24 +00001796 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fsub f2, f3
Chris Lattner3a173df2004-10-03 20:35:00 +00001797def FpMUL : FPI<0, Pseudo, TwoArgFP ,
Chris Lattner43ef1312005-09-14 21:10:24 +00001798 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fmul f2, f3
Chris Lattner3a173df2004-10-03 20:35:00 +00001799def FpDIV : FPI<0, Pseudo, TwoArgFP ,
Chris Lattner43ef1312005-09-14 21:10:24 +00001800 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fdiv f2, f3
Chris Lattner1cca5e32003-08-03 21:54:21 +00001801
Chris Lattner43ef1312005-09-14 21:10:24 +00001802def FpGETRESULT : FPI<0, Pseudo, SpecialFP, (ops RFP:$dst), "">,
Alkis Evlogimenos93c1ab22004-09-08 18:29:31 +00001803 Imp<[ST0], []>; // FPR = ST(0)
Alkis Evlogimenos978f6292004-09-08 16:54:54 +00001804
Chris Lattner43ef1312005-09-14 21:10:24 +00001805def FpSETRESULT : FPI<0, Pseudo, SpecialFP, (ops RFP:$src), "">,
Alkis Evlogimenos93c1ab22004-09-08 18:29:31 +00001806 Imp<[], [ST0]>; // ST(0) = FPR
Chris Lattner1cca5e32003-08-03 21:54:21 +00001807
Chris Lattner3a173df2004-10-03 20:35:00 +00001808// FADD reg, mem: Before stackification, these are represented by:
1809// R1 = FADD* R2, [mem]
1810def FADD32m : FPI<0xD8, MRM0m, OneArgFPRW, // ST(0) = ST(0) + [mem32real]
Chris Lattnerb822aba2005-08-19 00:38:22 +00001811 (ops f32mem:$src, variable_ops),
1812 "fadd{s} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001813def FADD64m : FPI<0xDC, MRM0m, OneArgFPRW, // ST(0) = ST(0) + [mem64real]
Chris Lattnerb822aba2005-08-19 00:38:22 +00001814 (ops f64mem:$src, variable_ops),
1815 "fadd{l} $src">;
Chris Lattner60c715c2004-10-04 00:43:31 +00001816//def FIADD16m : FPI<0xDE, MRM0m, OneArgFPRW>; // ST(0) = ST(0) + [mem16int]
1817//def FIADD32m : FPI<0xDA, MRM0m, OneArgFPRW>; // ST(0) = ST(0) + [mem32int]
Chris Lattner490e86f2004-04-11 20:24:15 +00001818
Chris Lattner3a173df2004-10-03 20:35:00 +00001819// FMUL reg, mem: Before stackification, these are represented by:
1820// R1 = FMUL* R2, [mem]
1821def FMUL32m : FPI<0xD8, MRM1m, OneArgFPRW, // ST(0) = ST(0) * [mem32real]
Chris Lattnerb822aba2005-08-19 00:38:22 +00001822 (ops f32mem:$src, variable_ops),
1823 "fmul{s} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001824def FMUL64m : FPI<0xDC, MRM1m, OneArgFPRW, // ST(0) = ST(0) * [mem64real]
Chris Lattnerb822aba2005-08-19 00:38:22 +00001825 (ops f64mem:$src, variable_ops),
1826 "fmul{l} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001827// ST(0) = ST(0) * [mem16int]
1828//def FIMUL16m : FPI16m<"fimul", 0xDE, MRM1m, OneArgFPRW>;
1829// ST(0) = ST(0) * [mem32int]
1830//def FIMUL32m : FPI32m<"fimul", 0xDA, MRM1m, OneArgFPRW>;
Chris Lattner490e86f2004-04-11 20:24:15 +00001831
Chris Lattner3a173df2004-10-03 20:35:00 +00001832// FSUB reg, mem: Before stackification, these are represented by:
1833// R1 = FSUB* R2, [mem]
1834def FSUB32m : FPI<0xD8, MRM4m, OneArgFPRW, // ST(0) = ST(0) - [mem32real]
Chris Lattner9d9dc812005-08-19 00:41:29 +00001835 (ops f32mem:$src, variable_ops),
1836 "fsub{s} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001837def FSUB64m : FPI<0xDC, MRM4m, OneArgFPRW, // ST(0) = ST(0) - [mem64real]
Chris Lattner9d9dc812005-08-19 00:41:29 +00001838 (ops f64mem:$src, variable_ops),
1839 "fsub{l} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001840// ST(0) = ST(0) - [mem16int]
1841//def FISUB16m : FPI16m<"fisub", 0xDE, MRM4m, OneArgFPRW>;
1842// ST(0) = ST(0) - [mem32int]
1843//def FISUB32m : FPI32m<"fisub", 0xDA, MRM4m, OneArgFPRW>;
Chris Lattner490e86f2004-04-11 20:24:15 +00001844
Chris Lattner3a173df2004-10-03 20:35:00 +00001845// FSUBR reg, mem: Before stackification, these are represented by:
1846// R1 = FSUBR* R2, [mem]
Chris Lattner490e86f2004-04-11 20:24:15 +00001847
Chris Lattner3a173df2004-10-03 20:35:00 +00001848// Note that the order of operands does not reflect the operation being
1849// performed.
1850def FSUBR32m : FPI<0xD8, MRM5m, OneArgFPRW, // ST(0) = [mem32real] - ST(0)
Chris Lattnerb822aba2005-08-19 00:38:22 +00001851 (ops f32mem:$src, variable_ops),
1852 "fsubr{s} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001853def FSUBR64m : FPI<0xDC, MRM5m, OneArgFPRW, // ST(0) = [mem64real] - ST(0)
Chris Lattnerb822aba2005-08-19 00:38:22 +00001854 (ops f64mem:$src, variable_ops),
1855 "fsubr{l} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001856// ST(0) = [mem16int] - ST(0)
1857//def FISUBR16m : FPI16m<"fisubr", 0xDE, MRM5m, OneArgFPRW>;
1858// ST(0) = [mem32int] - ST(0)
1859//def FISUBR32m : FPI32m<"fisubr", 0xDA, MRM5m, OneArgFPRW>;
Chris Lattner490e86f2004-04-11 20:24:15 +00001860
Chris Lattner3a173df2004-10-03 20:35:00 +00001861// FDIV reg, mem: Before stackification, these are represented by:
1862// R1 = FDIV* R2, [mem]
1863def FDIV32m : FPI<0xD8, MRM6m, OneArgFPRW, // ST(0) = ST(0) / [mem32real]
Chris Lattnerb822aba2005-08-19 00:38:22 +00001864 (ops f32mem:$src, variable_ops),
1865 "fdiv{s} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001866def FDIV64m : FPI<0xDC, MRM6m, OneArgFPRW, // ST(0) = ST(0) / [mem64real]
Chris Lattnerb822aba2005-08-19 00:38:22 +00001867 (ops f64mem:$src, variable_ops),
1868 "fdiv{l} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001869// ST(0) = ST(0) / [mem16int]
1870//def FIDIV16m : FPI16m<"fidiv", 0xDE, MRM6m, OneArgFPRW>;
1871// ST(0) = ST(0) / [mem32int]
1872//def FIDIV32m : FPI32m<"fidiv", 0xDA, MRM6m, OneArgFPRW>;
1873
1874// FDIVR reg, mem: Before stackification, these are represented by:
1875// R1 = FDIVR* R2, [mem]
1876// Note that the order of operands does not reflect the operation being
1877// performed.
1878def FDIVR32m : FPI<0xD8, MRM7m, OneArgFPRW, // ST(0) = [mem32real] / ST(0)
Chris Lattner9d9dc812005-08-19 00:41:29 +00001879 (ops f32mem:$src, variable_ops),
1880 "fdivr{s} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001881def FDIVR64m : FPI<0xDC, MRM7m, OneArgFPRW, // ST(0) = [mem64real] / ST(0)
Chris Lattner9d9dc812005-08-19 00:41:29 +00001882 (ops f64mem:$src, variable_ops),
1883 "fdivr{l} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001884// ST(0) = [mem16int] / ST(0)
1885//def FIDIVR16m : FPI16m<"fidivr", 0xDE, MRM7m, OneArgFPRW>;
1886// ST(0) = [mem32int] / ST(0)
1887//def FIDIVR32m : FPI32m<"fidivr", 0xDA, MRM7m, OneArgFPRW>;
Chris Lattner490e86f2004-04-11 20:24:15 +00001888
Chris Lattner1c54a852004-03-31 22:02:13 +00001889
1890// Floating point cmovs...
Chris Lattner0e967d42004-08-01 08:13:11 +00001891let isTwoAddress = 1, Uses = [ST0], Defs = [ST0] in {
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001892 def FCMOVB : FPI<0xC0, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001893 (ops RST:$op, variable_ops),
1894 "fcmovb {$op, %ST(0)|%ST(0), $op}">, DA;
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001895 def FCMOVBE : FPI<0xD0, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001896 (ops RST:$op, variable_ops),
1897 "fcmovbe {$op, %ST(0)|%ST(0), $op}">, DA;
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001898 def FCMOVE : FPI<0xC8, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001899 (ops RST:$op, variable_ops),
1900 "fcmove {$op, %ST(0)|%ST(0), $op}">, DA;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001901 def FCMOVP : FPI<0xD8, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001902 (ops RST:$op, variable_ops),
1903 "fcmovu {$op, %ST(0)|%ST(0), $op}">, DA;
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001904 def FCMOVAE : FPI<0xC0, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001905 (ops RST:$op, variable_ops),
1906 "fcmovae {$op, %ST(0)|%ST(0), $op}">, DB;
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001907 def FCMOVA : FPI<0xD0, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001908 (ops RST:$op, variable_ops),
1909 "fcmova {$op, %ST(0)|%ST(0), $op}">, DB;
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001910 def FCMOVNE : FPI<0xC8, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001911 (ops RST:$op, variable_ops),
1912 "fcmovne {$op, %ST(0)|%ST(0), $op}">, DB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001913 def FCMOVNP : FPI<0xD8, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001914 (ops RST:$op, variable_ops),
1915 "fcmovnu {$op, %ST(0)|%ST(0), $op}">, DB;
Chris Lattner1c54a852004-03-31 22:02:13 +00001916}
1917
Chris Lattner1cca5e32003-08-03 21:54:21 +00001918// Floating point loads & stores...
Chris Lattnerb822aba2005-08-19 00:38:22 +00001919// FIXME: these are all marked variable_ops because they have an implicit
1920// destination. Instructions like FILD* that are generated by the instruction
1921// selector (not the fp stackifier) need more accurate operand accounting.
1922def FLDrr : FPI<0xC0, AddRegFrm, NotFP,
1923 (ops RST:$src, variable_ops),
1924 "fld $src">, D9;
1925def FLD32m : FPI<0xD9, MRM0m, ZeroArgFP,
1926 (ops f32mem:$src, variable_ops),
1927 "fld{s} $src">;
1928def FLD64m : FPI<0xDD, MRM0m, ZeroArgFP,
1929 (ops f64mem:$src, variable_ops),
1930 "fld{l} $src">;
1931def FLD80m : FPI<0xDB, MRM5m, ZeroArgFP,
1932 (ops f80mem:$src, variable_ops),
1933 "fld{t} $src">;
1934def FILD16m : FPI<0xDF, MRM0m, ZeroArgFP,
1935 (ops i16mem:$src, variable_ops),
1936 "fild{s} $src">;
1937def FILD32m : FPI<0xDB, MRM0m, ZeroArgFP,
1938 (ops i32mem:$src, variable_ops),
1939 "fild{l} $src">;
1940def FILD64m : FPI<0xDF, MRM5m, ZeroArgFP,
1941 (ops i64mem:$src, variable_ops),
1942 "fild{ll} $src">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00001943
Chris Lattnerb822aba2005-08-19 00:38:22 +00001944def FSTrr : FPI<0xD0, AddRegFrm, NotFP,
1945 (ops RST:$op, variable_ops),
1946 "fst $op">, DD;
1947def FSTPrr : FPI<0xD8, AddRegFrm, NotFP,
1948 (ops RST:$op, variable_ops),
1949 "fstp $op">, DD;
1950def FST32m : FPI<0xD9, MRM2m, OneArgFP,
1951 (ops f32mem:$op, variable_ops),
1952 "fst{s} $op">;
1953def FST64m : FPI<0xDD, MRM2m, OneArgFP,
1954 (ops f64mem:$op, variable_ops),
1955 "fst{l} $op">;
1956def FSTP32m : FPI<0xD9, MRM3m, OneArgFP,
1957 (ops f32mem:$op, variable_ops),
1958 "fstp{s} $op">;
1959def FSTP64m : FPI<0xDD, MRM3m, OneArgFP,
1960 (ops f64mem:$op, variable_ops),
1961 "fstp{l} $op">;
1962def FSTP80m : FPI<0xDB, MRM7m, OneArgFP,
1963 (ops f80mem:$op, variable_ops),
1964 "fstp{t} $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00001965
Chris Lattnerb822aba2005-08-19 00:38:22 +00001966def FIST16m : FPI<0xDF, MRM2m , OneArgFP,
1967 (ops i16mem:$op, variable_ops),
1968 "fist{s} $op">;
1969def FIST32m : FPI<0xDB, MRM2m , OneArgFP,
1970 (ops i32mem:$op, variable_ops),
1971 "fist{l} $op">;
1972def FISTP16m : FPI<0xDF, MRM3m , NotFP ,
1973 (ops i16mem:$op, variable_ops),
1974 "fistp{s} $op">;
1975def FISTP32m : FPI<0xDB, MRM3m , NotFP ,
1976 (ops i32mem:$op, variable_ops),
1977 "fistp{l} $op">;
1978def FISTP64m : FPI<0xDF, MRM7m , OneArgFP,
1979 (ops i64mem:$op, variable_ops),
1980 "fistp{ll} $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00001981
Chris Lattner3a173df2004-10-03 20:35:00 +00001982def FXCH : FPI<0xC8, AddRegFrm, NotFP,
1983 (ops RST:$op), "fxch $op">, D9; // fxch ST(i), ST(0)
Chris Lattner1cca5e32003-08-03 21:54:21 +00001984
1985// Floating point constant loads...
Chris Lattnerb822aba2005-08-19 00:38:22 +00001986def FLD0 : FPI<0xEE, RawFrm, ZeroArgFP, (ops variable_ops), "fldz">, D9;
1987def FLD1 : FPI<0xE8, RawFrm, ZeroArgFP, (ops variable_ops), "fld1">, D9;
Chris Lattner1cca5e32003-08-03 21:54:21 +00001988
Chris Lattner9f8fd6d2004-02-02 19:31:38 +00001989
Chris Lattner3b904eb2004-02-03 07:27:50 +00001990// Unary operations...
Chris Lattnerb822aba2005-08-19 00:38:22 +00001991def FCHS : FPI<0xE0, RawFrm, OneArgFPRW, // f1 = fchs f2
1992 (ops variable_ops),
1993 "fchs">, D9;
1994def FABS : FPI<0xE1, RawFrm, OneArgFPRW, // f1 = fabs f2
1995 (ops variable_ops),
1996 "fabs">, D9;
1997def FSQRT : FPI<0xFA, RawFrm, OneArgFPRW, // fsqrt ST(0)
1998 (ops variable_ops),
1999 "fsqrt">, D9;
2000def FSIN : FPI<0xFE, RawFrm, OneArgFPRW, // fsin ST(0)
2001 (ops variable_ops),
2002 "fsin">, D9;
2003def FCOS : FPI<0xFF, RawFrm, OneArgFPRW, // fcos ST(0)
2004 (ops variable_ops),
2005 "fcos">, D9;
2006def FTST : FPI<0xE4, RawFrm, OneArgFP , // ftst ST(0)
2007 (ops variable_ops),
2008 "ftst">, D9;
Chris Lattner3b904eb2004-02-03 07:27:50 +00002009
Chris Lattner1cca5e32003-08-03 21:54:21 +00002010// Binary arithmetic operations...
Chris Lattner3a173df2004-10-03 20:35:00 +00002011class FPST0rInst<bits<8> o, dag ops, string asm>
Evan Chengf0701842005-11-29 19:38:52 +00002012 : I<o, AddRegFrm, ops, asm, []>, D8 {
Chris Lattner1cca5e32003-08-03 21:54:21 +00002013 list<Register> Uses = [ST0];
2014 list<Register> Defs = [ST0];
2015}
Chris Lattner3a173df2004-10-03 20:35:00 +00002016class FPrST0Inst<bits<8> o, dag ops, string asm>
Evan Chengf0701842005-11-29 19:38:52 +00002017 : I<o, AddRegFrm, ops, asm, []>, DC {
Chris Lattner1cca5e32003-08-03 21:54:21 +00002018 list<Register> Uses = [ST0];
2019}
Chris Lattner3a173df2004-10-03 20:35:00 +00002020class FPrST0PInst<bits<8> o, dag ops, string asm>
Evan Chengf0701842005-11-29 19:38:52 +00002021 : I<o, AddRegFrm, ops, asm, []>, DE {
Chris Lattner1cca5e32003-08-03 21:54:21 +00002022 list<Register> Uses = [ST0];
2023}
2024
Chris Lattner3a173df2004-10-03 20:35:00 +00002025def FADDST0r : FPST0rInst <0xC0, (ops RST:$op),
2026 "fadd $op">;
2027def FADDrST0 : FPrST0Inst <0xC0, (ops RST:$op),
2028 "fadd {%ST(0), $op|$op, %ST(0)}">;
2029def FADDPrST0 : FPrST0PInst<0xC0, (ops RST:$op),
2030 "faddp $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002031
Chris Lattner10f873b2004-10-04 07:08:46 +00002032// NOTE: GAS and apparently all other AT&T style assemblers have a broken notion
2033// of some of the 'reverse' forms of the fsub and fdiv instructions. As such,
Chris Lattnerda895d62005-02-27 06:18:25 +00002034// we have to put some 'r's in and take them out of weird places.
Chris Lattner3a173df2004-10-03 20:35:00 +00002035def FSUBRST0r : FPST0rInst <0xE8, (ops RST:$op),
2036 "fsubr $op">;
2037def FSUBrST0 : FPrST0Inst <0xE8, (ops RST:$op),
Chris Lattner10f873b2004-10-04 07:08:46 +00002038 "fsub{r} {%ST(0), $op|$op, %ST(0)}">;
Chris Lattner3a173df2004-10-03 20:35:00 +00002039def FSUBPrST0 : FPrST0PInst<0xE8, (ops RST:$op),
Chris Lattner10f873b2004-10-04 07:08:46 +00002040 "fsub{r}p $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002041
Chris Lattner3a173df2004-10-03 20:35:00 +00002042def FSUBST0r : FPST0rInst <0xE0, (ops RST:$op),
2043 "fsub $op">;
2044def FSUBRrST0 : FPrST0Inst <0xE0, (ops RST:$op),
Chris Lattner10f873b2004-10-04 07:08:46 +00002045 "fsub{|r} {%ST(0), $op|$op, %ST(0)}">;
Chris Lattner3a173df2004-10-03 20:35:00 +00002046def FSUBRPrST0 : FPrST0PInst<0xE0, (ops RST:$op),
Chris Lattner10f873b2004-10-04 07:08:46 +00002047 "fsub{|r}p $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002048
Chris Lattner3a173df2004-10-03 20:35:00 +00002049def FMULST0r : FPST0rInst <0xC8, (ops RST:$op),
2050 "fmul $op">;
2051def FMULrST0 : FPrST0Inst <0xC8, (ops RST:$op),
2052 "fmul {%ST(0), $op|$op, %ST(0)}">;
2053def FMULPrST0 : FPrST0PInst<0xC8, (ops RST:$op),
2054 "fmulp $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002055
Chris Lattner3a173df2004-10-03 20:35:00 +00002056def FDIVRST0r : FPST0rInst <0xF8, (ops RST:$op),
2057 "fdivr $op">;
2058def FDIVrST0 : FPrST0Inst <0xF8, (ops RST:$op),
Chris Lattner10f873b2004-10-04 07:08:46 +00002059 "fdiv{r} {%ST(0), $op|$op, %ST(0)}">;
Chris Lattner3a173df2004-10-03 20:35:00 +00002060def FDIVPrST0 : FPrST0PInst<0xF8, (ops RST:$op),
Chris Lattner10f873b2004-10-04 07:08:46 +00002061 "fdiv{r}p $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002062
Chris Lattner3a173df2004-10-03 20:35:00 +00002063def FDIVST0r : FPST0rInst <0xF0, (ops RST:$op), // ST(0) = ST(0) / ST(i)
2064 "fdiv $op">;
2065def FDIVRrST0 : FPrST0Inst <0xF0, (ops RST:$op), // ST(i) = ST(0) / ST(i)
Chris Lattner10f873b2004-10-04 07:08:46 +00002066 "fdiv{|r} {%ST(0), $op|$op, %ST(0)}">;
Chris Lattner3a173df2004-10-03 20:35:00 +00002067def FDIVRPrST0 : FPrST0PInst<0xF0, (ops RST:$op), // ST(i) = ST(0) / ST(i), pop
Chris Lattner10f873b2004-10-04 07:08:46 +00002068 "fdiv{|r}p $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002069
2070// Floating point compares
Chris Lattner3a173df2004-10-03 20:35:00 +00002071def FUCOMr : FPI<0xE0, AddRegFrm, CompareFP, // FPSW = cmp ST(0) with ST(i)
Chris Lattnerb822aba2005-08-19 00:38:22 +00002072 (ops RST:$reg, variable_ops),
Chris Lattner3a173df2004-10-03 20:35:00 +00002073 "fucom $reg">, DD, Imp<[ST0],[]>;
Chris Lattnerb822aba2005-08-19 00:38:22 +00002074def FUCOMPr : I<0xE8, AddRegFrm, // FPSW = cmp ST(0) with ST(i), pop
2075 (ops RST:$reg, variable_ops),
Evan Chengf0701842005-11-29 19:38:52 +00002076 "fucomp $reg", []>, DD, Imp<[ST0],[]>;
Chris Lattnerb822aba2005-08-19 00:38:22 +00002077def FUCOMPPr : I<0xE9, RawFrm, // cmp ST(0) with ST(1), pop, pop
2078 (ops variable_ops),
Evan Chengf0701842005-11-29 19:38:52 +00002079 "fucompp", []>, DA, Imp<[ST0],[]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002080
Chris Lattner3a173df2004-10-03 20:35:00 +00002081def FUCOMIr : FPI<0xE8, AddRegFrm, CompareFP, // CC = cmp ST(0) with ST(i)
Chris Lattnerb822aba2005-08-19 00:38:22 +00002082 (ops RST:$reg, variable_ops),
Chris Lattner3a173df2004-10-03 20:35:00 +00002083 "fucomi {$reg, %ST(0)|%ST(0), $reg}">, DB, Imp<[ST0],[]>;
2084def FUCOMIPr : I<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i), pop
Chris Lattnerb822aba2005-08-19 00:38:22 +00002085 (ops RST:$reg, variable_ops),
Evan Chengf0701842005-11-29 19:38:52 +00002086 "fucomip {$reg, %ST(0)|%ST(0), $reg}", []>, DF, Imp<[ST0],[]>;
Chris Lattner0e967d42004-08-01 08:13:11 +00002087
Chris Lattnera1b5e162004-04-12 01:38:55 +00002088
Chris Lattnerc8f45872003-08-04 04:59:56 +00002089// Floating point flag ops
Chris Lattner3a173df2004-10-03 20:35:00 +00002090def FNSTSW8r : I<0xE0, RawFrm, // AX = fp flags
Evan Chengf0701842005-11-29 19:38:52 +00002091 (ops), "fnstsw", []>, DF, Imp<[],[AX]>;
Chris Lattner96563df2004-08-01 06:01:00 +00002092
Chris Lattner3a173df2004-10-03 20:35:00 +00002093def FNSTCW16m : I<0xD9, MRM7m, // [mem16] = X87 control world
Evan Chengf0701842005-11-29 19:38:52 +00002094 (ops i16mem:$dst), "fnstcw $dst", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002095def FLDCW16m : I<0xD9, MRM5m, // X87 control world = [mem16]
Evan Chengf0701842005-11-29 19:38:52 +00002096 (ops i16mem:$dst), "fldcw $dst", []>;