blob: 303a41c9cdb3170e7908346a38071a7fd4483706 [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
Evan Cheng605c4152005-12-13 01:57:51 +0000164// Helper fragments for loads.
165def loadi8 : PatFrag<(ops node:$in), (i8 (load node:$in))>;
166def loadi16 : PatFrag<(ops node:$in), (i16 (load node:$in))>;
167def loadi32 : PatFrag<(ops node:$in), (i32 (load node:$in))>;
168
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000169//===----------------------------------------------------------------------===//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000170// Instruction templates...
171
Evan Chengf0701842005-11-29 19:38:52 +0000172class I<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
173 : X86Inst<o, f, NoImm, ops, asm> {
174 let Pattern = pattern;
175}
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000176class Ii8 <bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
177 : X86Inst<o, f, Imm8 , ops, asm> {
178 let Pattern = pattern;
179}
Chris Lattner78432fe2005-11-17 02:01:55 +0000180class Ii16<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
181 : X86Inst<o, f, Imm16, ops, asm> {
182 let Pattern = pattern;
183}
Chris Lattner7a125372005-11-16 22:59:19 +0000184class Ii32<bits<8> o, Format f, dag ops, string asm, list<dag> pattern>
185 : X86Inst<o, f, Imm32, ops, asm> {
186 let Pattern = pattern;
187}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000188
Chris Lattner1cca5e32003-08-03 21:54:21 +0000189//===----------------------------------------------------------------------===//
190// Instruction list...
191//
192
Evan Chengf0701842005-11-29 19:38:52 +0000193def PHI : I<0, Pseudo, (ops variable_ops), "PHINODE", []>; // PHI node.
194def NOOP : I<0x90, RawFrm, (ops), "nop", []>; // nop
Chris Lattner1cca5e32003-08-03 21:54:21 +0000195
Evan Chengf0701842005-11-29 19:38:52 +0000196def ADJCALLSTACKDOWN : I<0, Pseudo, (ops i32imm:$amt), "#ADJCALLSTACKDOWN", []>;
Chris Lattner43ef1312005-09-14 21:10:24 +0000197def ADJCALLSTACKUP : I<0, Pseudo, (ops i32imm:$amt1, i32imm:$amt2),
Evan Chengf0701842005-11-29 19:38:52 +0000198 "#ADJCALLSTACKUP", []>;
199def IMPLICIT_USE : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_USE", []>;
200def IMPLICIT_DEF : I<0, Pseudo, (ops variable_ops), "#IMPLICIT_DEF", []>;
Alkis Evlogimenose0bb3e72003-12-20 16:22:59 +0000201let isTerminator = 1 in
202 let Defs = [FP0, FP1, FP2, FP3, FP4, FP5, FP6] in
Evan Chengf0701842005-11-29 19:38:52 +0000203 def FP_REG_KILL : I<0, Pseudo, (ops), "#FP_REG_KILL", []>;
Chris Lattner62cce392004-07-31 02:10:53 +0000204
Chris Lattner1cca5e32003-08-03 21:54:21 +0000205//===----------------------------------------------------------------------===//
206// Control Flow Instructions...
207//
208
Chris Lattner1be48112005-05-13 17:56:48 +0000209// Return instructions.
Evan Cheng8d202232005-12-05 23:09:43 +0000210let isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000211 def RET : I<0xC3, RawFrm, (ops), "ret", [(ret)]>;
Evan Cheng8d202232005-12-05 23:09:43 +0000212let isTerminator = 1, isReturn = 1, isBarrier = 1 in
Chris Lattner78432fe2005-11-17 02:01:55 +0000213 def RETI : Ii16<0xC2, RawFrm, (ops i16imm:$amt), "ret $amt", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000214
215// All branches are RawFrm, Void, Branch, and Terminators
Evan Cheng8d202232005-12-05 23:09:43 +0000216let isBranch = 1, isTerminator = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000217 class IBr<bits<8> opcode, dag ops, string asm, list<dag> pattern> :
218 I<opcode, RawFrm, ops, asm, pattern>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000219
Chris Lattner62cce392004-07-31 02:10:53 +0000220let isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000221 def JMP : IBr<0xE9, (ops brtarget:$dst), "jmp $dst", [(br bb:$dst)]>;
222def JB : IBr<0x82, (ops brtarget:$dst), "jb $dst",
223 []>, TB;
224def JAE : IBr<0x83, (ops brtarget:$dst), "jae $dst", []>, TB;
225def JE : IBr<0x84, (ops brtarget:$dst), "je $dst", []>, TB;
226def JNE : IBr<0x85, (ops brtarget:$dst), "jne $dst", []>, TB;
227def JBE : IBr<0x86, (ops brtarget:$dst), "jbe $dst", []>, TB;
228def JA : IBr<0x87, (ops brtarget:$dst), "ja $dst", []>, TB;
229def JS : IBr<0x88, (ops brtarget:$dst), "js $dst", []>, TB;
230def JNS : IBr<0x89, (ops brtarget:$dst), "jns $dst", []>, TB;
231def JP : IBr<0x8A, (ops brtarget:$dst), "jp $dst", []>, TB;
232def JNP : IBr<0x8B, (ops brtarget:$dst), "jnp $dst", []>, TB;
233def JL : IBr<0x8C, (ops brtarget:$dst), "jl $dst", []>, TB;
234def JGE : IBr<0x8D, (ops brtarget:$dst), "jge $dst", []>, TB;
235def JLE : IBr<0x8E, (ops brtarget:$dst), "jle $dst", []>, TB;
236def JG : IBr<0x8F, (ops brtarget:$dst), "jg $dst", []>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000237
238//===----------------------------------------------------------------------===//
239// Call Instructions...
240//
Chris Lattnerc8f45872003-08-04 04:59:56 +0000241let isCall = 1 in
Chris Lattner1cca5e32003-08-03 21:54:21 +0000242 // All calls clobber the non-callee saved registers...
Nate Begemanf63be7d2005-07-06 18:59:04 +0000243 let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0,
Nate Begeman16b04f32005-07-15 00:38:55 +0000244 XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7] in {
Evan Chengf0701842005-11-29 19:38:52 +0000245 def CALLpcrel32 : I<0xE8, RawFrm, (ops calltarget:$dst), "call $dst", []>;
246 def CALL32r : I<0xFF, MRM2r, (ops R32:$dst), "call {*}$dst", []>;
247 def CALL32m : I<0xFF, MRM2m, (ops i32mem:$dst), "call {*}$dst", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000248 }
249
Chris Lattner1e9448b2005-05-15 03:10:37 +0000250// Tail call stuff.
Chris Lattner2b3d56e2005-05-14 23:35:21 +0000251let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengd35b8c12005-12-04 08:19:43 +0000252 def TAILJMPd : IBr<0xE9, (ops calltarget:$dst), "jmp $dst # TAIL CALL", []>;
Chris Lattner2b3d56e2005-05-14 23:35:21 +0000253let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000254 def TAILJMPr : I<0xFF, MRM4r, (ops R32:$dst), "jmp {*}$dst # TAIL CALL", []>;
Chris Lattner2b3d56e2005-05-14 23:35:21 +0000255let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in
Evan Chengf0701842005-11-29 19:38:52 +0000256 def TAILJMPm : I<0xFF, MRM4m, (ops i32mem:$dst),
257 "jmp {*}$dst # TAIL CALL", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000258
259// ADJSTACKPTRri - This is a standard ADD32ri instruction, identical in every
260// way, except that it is marked as being a terminator. This causes the epilog
261// inserter to insert reloads of callee saved registers BEFORE this. We need
262// this until we have a more accurate way of tracking where the stack pointer is
263// within a function.
264let isTerminator = 1, isTwoAddress = 1 in
265 def ADJSTACKPTRri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000266 "add{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner1e9448b2005-05-15 03:10:37 +0000267
Chris Lattner1cca5e32003-08-03 21:54:21 +0000268//===----------------------------------------------------------------------===//
269// Miscellaneous Instructions...
270//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000271def LEAVE : I<0xC9, RawFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000272 (ops), "leave", []>, Imp<[EBP,ESP],[EBP,ESP]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000273def POP32r : I<0x58, AddRegFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000274 (ops R32:$reg), "pop{l} $reg", []>, Imp<[ESP],[ESP]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000275
Chris Lattner3a173df2004-10-03 20:35:00 +0000276let isTwoAddress = 1 in // R32 = bswap R32
Chris Lattner30bf2d82004-08-10 20:17:41 +0000277 def BSWAP32r : I<0xC8, AddRegFrm,
Evan Chengf0701842005-11-29 19:38:52 +0000278 (ops R32:$dst, R32:$src), "bswap{l} $dst", []>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000279
Chris Lattner30bf2d82004-08-10 20:17:41 +0000280def XCHG8rr : I<0x86, MRMDestReg, // xchg R8, R8
Chris Lattner3a173df2004-10-03 20:35:00 +0000281 (ops R8:$src1, R8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000282 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000283def XCHG16rr : I<0x87, MRMDestReg, // xchg R16, R16
Chris Lattner3a173df2004-10-03 20:35:00 +0000284 (ops R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000285 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000286def XCHG32rr : I<0x87, MRMDestReg, // xchg R32, R32
Chris Lattner3a173df2004-10-03 20:35:00 +0000287 (ops R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000288 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattnerfc752712004-08-01 09:52:59 +0000289
Chris Lattner3a173df2004-10-03 20:35:00 +0000290def XCHG8mr : I<0x86, MRMDestMem,
291 (ops i8mem:$src1, R8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000292 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000293def XCHG16mr : I<0x87, MRMDestMem,
294 (ops i16mem:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000295 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000296def XCHG32mr : I<0x87, MRMDestMem,
297 (ops i32mem:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000298 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000299def XCHG8rm : I<0x86, MRMSrcMem,
300 (ops R8:$src1, i8mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000301 "xchg{b} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000302def XCHG16rm : I<0x87, MRMSrcMem,
303 (ops R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000304 "xchg{w} {$src2|$src1}, {$src1|$src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000305def XCHG32rm : I<0x87, MRMSrcMem,
306 (ops R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000307 "xchg{l} {$src2|$src1}, {$src1|$src2}", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000308
Chris Lattner3a173df2004-10-03 20:35:00 +0000309def LEA16r : I<0x8D, MRMSrcMem,
310 (ops R16:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000311 "lea{w} {$src|$dst}, {$dst|$src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000312def LEA32r : I<0x8D, MRMSrcMem,
313 (ops R32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000314 "lea{l} {$src|$dst}, {$dst|$src}",
315 [(set R32:$dst, leaaddr:$src)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000316
Chris Lattner915e5e52004-02-12 17:53:22 +0000317
Evan Chengf0701842005-11-29 19:38:52 +0000318def REP_MOVSB : I<0xA4, RawFrm, (ops), "{rep;movsb|rep movsb}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000319 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Evan Chengf0701842005-11-29 19:38:52 +0000320def REP_MOVSW : I<0xA5, RawFrm, (ops), "{rep;movsw|rep movsw}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000321 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP, OpSize;
Evan Chengf0701842005-11-29 19:38:52 +0000322def REP_MOVSD : I<0xA5, RawFrm, (ops), "{rep;movsd|rep movsd}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000323 Imp<[ECX,EDI,ESI], [ECX,EDI,ESI]>, REP;
Chris Lattner915e5e52004-02-12 17:53:22 +0000324
Evan Chengf0701842005-11-29 19:38:52 +0000325def REP_STOSB : I<0xAA, RawFrm, (ops), "{rep;stosb|rep stosb}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000326 Imp<[AL,ECX,EDI], [ECX,EDI]>, REP;
Evan Chengf0701842005-11-29 19:38:52 +0000327def REP_STOSW : I<0xAB, RawFrm, (ops), "{rep;stosw|rep stosw}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000328 Imp<[AX,ECX,EDI], [ECX,EDI]>, REP, OpSize;
Evan Chengf0701842005-11-29 19:38:52 +0000329def REP_STOSD : I<0xAB, RawFrm, (ops), "{rep;stosl|rep stosd}", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000330 Imp<[EAX,ECX,EDI], [ECX,EDI]>, REP;
331
Chris Lattnerb89abef2004-02-14 04:45:37 +0000332
Chris Lattner1cca5e32003-08-03 21:54:21 +0000333//===----------------------------------------------------------------------===//
John Criswell4ffff9e2004-04-08 20:31:47 +0000334// Input/Output Instructions...
335//
Chris Lattner30bf2d82004-08-10 20:17:41 +0000336def IN8rr : I<0xEC, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000337 "in{b} {%dx, %al|%AL, %DX}", []>, Imp<[DX], [AL]>;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000338def IN16rr : I<0xED, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000339 "in{w} {%dx, %ax|%AX, %DX}", []>, Imp<[DX], [AX]>, OpSize;
Chris Lattner30bf2d82004-08-10 20:17:41 +0000340def IN32rr : I<0xED, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000341 "in{l} {%dx, %eax|%EAX, %DX}", []>, Imp<[DX],[EAX]>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000342
Evan Chengd35b8c12005-12-04 08:19:43 +0000343def IN8ri : Ii8<0xE4, RawFrm, (ops i8imm:$port),
Chris Lattner78432fe2005-11-17 02:01:55 +0000344 "in{b} {$port, %al|%AL, $port}", []>, Imp<[], [AL]>;
Evan Chengd35b8c12005-12-04 08:19:43 +0000345def IN16ri : Ii8<0xE5, RawFrm, (ops i8imm:$port),
Chris Lattner78432fe2005-11-17 02:01:55 +0000346 "in{w} {$port, %ax|%AX, $port}", []>, Imp<[], [AX]>, OpSize;
Evan Chengd35b8c12005-12-04 08:19:43 +0000347def IN32ri : Ii8<0xE5, RawFrm, (ops i8imm:$port),
Chris Lattner78432fe2005-11-17 02:01:55 +0000348 "in{l} {$port, %eax|%EAX, $port}", []>, Imp<[],[EAX]>;
Chris Lattner440bbc22004-04-13 17:19:31 +0000349
Evan Cheng8d202232005-12-05 23:09:43 +0000350def OUT8rr : I<0xEE, RawFrm, (ops),
351 "out{b} {%al, %dx|%DX, %AL}",
352 [(writeport AL, DX)]>, Imp<[DX, AL], []>;
353def OUT16rr : I<0xEF, RawFrm, (ops),
354 "out{w} {%ax, %dx|%DX, %AX}",
355 [(writeport AX, DX)]>, Imp<[DX, AX], []>, OpSize;
356def OUT32rr : I<0xEF, RawFrm, (ops),
357 "out{l} {%eax, %dx|%DX, %EAX}",
358 [(writeport EAX, DX)]>, Imp<[DX, EAX], []>;
Chris Lattnerffff7082004-08-01 07:44:35 +0000359
Evan Cheng8d202232005-12-05 23:09:43 +0000360def OUT8ir : Ii8<0xE6, RawFrm, (ops i16i8imm:$port),
361 "out{b} {%al, $port|$port, %AL}",
Evan Cheng5a38e022005-12-13 00:25:07 +0000362 [(writeport AL, i16immZExt8:$port)]>,
Evan Cheng8d202232005-12-05 23:09:43 +0000363 Imp<[AL], []>;
364def OUT16ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
365 "out{w} {%ax, $port|$port, %AX}",
Evan Cheng5a38e022005-12-13 00:25:07 +0000366 [(writeport AX, i16immZExt8:$port)]>,
Evan Cheng8d202232005-12-05 23:09:43 +0000367 Imp<[AX], []>, OpSize;
368def OUT32ir : Ii8<0xE7, RawFrm, (ops i16i8imm:$port),
369 "out{l} {%eax, $port|$port, %EAX}",
Evan Cheng5a38e022005-12-13 00:25:07 +0000370 [(writeport EAX, i16immZExt8:$port)]>,
Evan Cheng8d202232005-12-05 23:09:43 +0000371 Imp<[EAX], []>;
John Criswell4ffff9e2004-04-08 20:31:47 +0000372
373//===----------------------------------------------------------------------===//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000374// Move Instructions...
375//
Chris Lattner3a173df2004-10-03 20:35:00 +0000376def MOV8rr : I<0x88, MRMDestReg, (ops R8 :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000377 "mov{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000378def MOV16rr : I<0x89, MRMDestReg, (ops R16:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000379 "mov{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000380def MOV32rr : I<0x89, MRMDestReg, (ops R32:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000381 "mov{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000382def MOV8ri : Ii8 <0xB0, AddRegFrm, (ops R8 :$dst, i8imm :$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000383 "mov{b} {$src, $dst|$dst, $src}",
384 [(set R8:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000385def MOV16ri : Ii16<0xB8, AddRegFrm, (ops R16:$dst, i16imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000386 "mov{w} {$src, $dst|$dst, $src}",
387 [(set R16:$dst, imm:$src)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000388def MOV32ri : Ii32<0xB8, AddRegFrm, (ops R32:$dst, i32imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000389 "mov{l} {$src, $dst|$dst, $src}",
390 [(set R32:$dst, imm:$src)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000391def MOV8mi : Ii8 <0xC6, MRM0m, (ops i8mem :$dst, i8imm :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000392 "mov{b} {$src, $dst|$dst, $src}",
393 [(store (i8 imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000394def MOV16mi : Ii16<0xC7, MRM0m, (ops i16mem:$dst, i16imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000395 "mov{w} {$src, $dst|$dst, $src}",
396 [(store (i16 imm:$src), addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000397def MOV32mi : Ii32<0xC7, MRM0m, (ops i32mem:$dst, i32imm:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000398 "mov{l} {$src, $dst|$dst, $src}",
399 [(store (i32 imm:$src), addr:$dst)]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000400
Chris Lattner3a173df2004-10-03 20:35:00 +0000401def MOV8rm : I<0x8A, MRMSrcMem, (ops R8 :$dst, i8mem :$src),
Evan Chengec693f72005-12-08 02:01:35 +0000402 "mov{b} {$src, $dst|$dst, $src}",
403 [(set R8:$dst, (load addr:$src))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000404def MOV16rm : I<0x8B, MRMSrcMem, (ops R16:$dst, i16mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000405 "mov{w} {$src, $dst|$dst, $src}",
406 [(set R16:$dst, (load addr:$src))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000407def MOV32rm : I<0x8B, MRMSrcMem, (ops R32:$dst, i32mem:$src),
Evan Chengec693f72005-12-08 02:01:35 +0000408 "mov{l} {$src, $dst|$dst, $src}",
409 [(set R32:$dst, (load addr:$src))]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000410
Chris Lattner3a173df2004-10-03 20:35:00 +0000411def MOV8mr : I<0x88, MRMDestMem, (ops i8mem :$dst, R8 :$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000412 "mov{b} {$src, $dst|$dst, $src}",
413 [(store R8:$src, addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000414def MOV16mr : I<0x89, MRMDestMem, (ops i16mem:$dst, R16:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000415 "mov{w} {$src, $dst|$dst, $src}",
416 [(store R16:$src, addr:$dst)]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000417def MOV32mr : I<0x89, MRMDestMem, (ops i32mem:$dst, R32:$src),
Evan Chengb51a0592005-12-10 00:48:20 +0000418 "mov{l} {$src, $dst|$dst, $src}",
419 [(store R32:$src, addr:$dst)]>;
Nate Begemanf1702ac2005-06-27 21:20:31 +0000420
Chris Lattner1cca5e32003-08-03 21:54:21 +0000421//===----------------------------------------------------------------------===//
422// Fixed-Register Multiplication and Division Instructions...
423//
Chris Lattner1cca5e32003-08-03 21:54:21 +0000424
Chris Lattnerc8f45872003-08-04 04:59:56 +0000425// Extra precision multiplication
Evan Chengf0701842005-11-29 19:38:52 +0000426def MUL8r : I<0xF6, MRM4r, (ops R8:$src), "mul{b} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000427 Imp<[AL],[AX]>; // AL,AH = AL*R8
Evan Chengf0701842005-11-29 19:38:52 +0000428def MUL16r : I<0xF7, MRM4r, (ops R16:$src), "mul{w} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000429 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
Evan Chengf0701842005-11-29 19:38:52 +0000430def MUL32r : I<0xF7, MRM4r, (ops R32:$src), "mul{l} $src", []>,
Chris Lattner30bf2d82004-08-10 20:17:41 +0000431 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
Chris Lattner57a02302004-08-11 04:31:00 +0000432def MUL8m : I<0xF6, MRM4m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000433 "mul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner57a02302004-08-11 04:31:00 +0000434def MUL16m : I<0xF7, MRM4m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000435 "mul{w} $src", []>, Imp<[AX],[AX,DX]>,
436 OpSize; // AX,DX = AX*[mem16]
Chris Lattner57a02302004-08-11 04:31:00 +0000437def MUL32m : I<0xF7, MRM4m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000438 "mul{l} $src", []>, Imp<[EAX],[EAX,EDX]>;// EAX,EDX = EAX*[mem32]
Chris Lattner1cca5e32003-08-03 21:54:21 +0000439
Evan Chengf0701842005-11-29 19:38:52 +0000440def IMUL8r : I<0xF6, MRM5r, (ops R8:$src), "imul{b} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000441 Imp<[AL],[AX]>; // AL,AH = AL*R8
Evan Chengf0701842005-11-29 19:38:52 +0000442def IMUL16r : I<0xF7, MRM5r, (ops R16:$src), "imul{w} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000443 Imp<[AX],[AX,DX]>, OpSize; // AX,DX = AX*R16
Evan Chengf0701842005-11-29 19:38:52 +0000444def IMUL32r : I<0xF7, MRM5r, (ops R32:$src), "imul{l} $src", []>,
Chris Lattner1e6a7152005-04-06 04:19:22 +0000445 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*R32
446def IMUL8m : I<0xF6, MRM5m, (ops i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +0000447 "imul{b} $src", []>, Imp<[AL],[AX]>; // AL,AH = AL*[mem8]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000448def IMUL16m : I<0xF7, MRM5m, (ops i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000449 "imul{w} $src", []>, Imp<[AX],[AX,DX]>,
450 OpSize; // AX,DX = AX*[mem16]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000451def IMUL32m : I<0xF7, MRM5m, (ops i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +0000452 "imul{l} $src", []>,
453 Imp<[EAX],[EAX,EDX]>; // EAX,EDX = EAX*[mem32]
Chris Lattner1e6a7152005-04-06 04:19:22 +0000454
Chris Lattnerc8f45872003-08-04 04:59:56 +0000455// unsigned division/remainder
Chris Lattner3a173df2004-10-03 20:35:00 +0000456def DIV8r : I<0xF6, MRM6r, (ops R8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000457 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000458def DIV16r : I<0xF7, MRM6r, (ops R16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000459 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000460def DIV32r : I<0xF7, MRM6r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000461 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000462def DIV8m : I<0xF6, MRM6m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000463 "div{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000464def DIV16m : I<0xF7, MRM6m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000465 "div{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000466def DIV32m : I<0xF7, MRM6m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000467 "div{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +0000468
Chris Lattnerfc752712004-08-01 09:52:59 +0000469// Signed division/remainder.
Chris Lattner3a173df2004-10-03 20:35:00 +0000470def IDIV8r : I<0xF6, MRM7r, (ops R8:$src), // AX/r8 = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000471 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000472def IDIV16r: I<0xF7, MRM7r, (ops R16:$src), // DX:AX/r16 = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000473 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000474def IDIV32r: I<0xF7, MRM7r, (ops R32:$src), // EDX:EAX/r32 = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000475 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000476def IDIV8m : I<0xF6, MRM7m, (ops i8mem:$src), // AX/[mem8] = AL,AH
Evan Chengf0701842005-11-29 19:38:52 +0000477 "idiv{b} $src", []>, Imp<[AX],[AX]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000478def IDIV16m: I<0xF7, MRM7m, (ops i16mem:$src), // DX:AX/[mem16] = AX,DX
Evan Chengf0701842005-11-29 19:38:52 +0000479 "idiv{w} $src", []>, Imp<[AX,DX],[AX,DX]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000480def IDIV32m: I<0xF7, MRM7m, (ops i32mem:$src), // EDX:EAX/[mem32] = EAX,EDX
Evan Chengf0701842005-11-29 19:38:52 +0000481 "idiv{l} $src", []>, Imp<[EAX,EDX],[EAX,EDX]>;
Chris Lattnerc8f45872003-08-04 04:59:56 +0000482
Chris Lattnerfc752712004-08-01 09:52:59 +0000483// Sign-extenders for division.
Chris Lattner3a173df2004-10-03 20:35:00 +0000484def CBW : I<0x98, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000485 "{cbtw|cbw}", []>, Imp<[AL],[AH]>; // AX = signext(AL)
Chris Lattner3a173df2004-10-03 20:35:00 +0000486def CWD : I<0x99, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000487 "{cwtd|cwd}", []>, Imp<[AX],[DX]>; // DX:AX = signext(AX)
Chris Lattner3a173df2004-10-03 20:35:00 +0000488def CDQ : I<0x99, RawFrm, (ops),
Evan Chengf0701842005-11-29 19:38:52 +0000489 "{cltd|cdq}", []>, Imp<[EAX],[EDX]>; // EDX:EAX = signext(EAX)
Chris Lattnerfc752712004-08-01 09:52:59 +0000490
Chris Lattner1cca5e32003-08-03 21:54:21 +0000491
Chris Lattner1cca5e32003-08-03 21:54:21 +0000492//===----------------------------------------------------------------------===//
493// Two address Instructions...
494//
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000495let isTwoAddress = 1 in {
Chris Lattner1cca5e32003-08-03 21:54:21 +0000496
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000497// Conditional moves
Chris Lattner3a173df2004-10-03 20:35:00 +0000498def CMOVB16rr : I<0x42, MRMSrcReg, // if <u, R16 = R16
499 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000500 "cmovb {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000501def CMOVB16rm : I<0x42, MRMSrcMem, // if <u, R16 = [mem16]
502 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000503 "cmovb {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000504def CMOVB32rr : I<0x42, MRMSrcReg, // if <u, R32 = R32
505 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000506 "cmovb {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000507def CMOVB32rm : I<0x42, MRMSrcMem, // if <u, R32 = [mem32]
508 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000509 "cmovb {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000510
Chris Lattner3a173df2004-10-03 20:35:00 +0000511def CMOVAE16rr: I<0x43, MRMSrcReg, // if >=u, R16 = R16
512 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000513 "cmovae {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000514def CMOVAE16rm: I<0x43, MRMSrcMem, // if >=u, R16 = [mem16]
515 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000516 "cmovae {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000517def CMOVAE32rr: I<0x43, MRMSrcReg, // if >=u, R32 = R32
518 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000519 "cmovae {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000520def CMOVAE32rm: I<0x43, MRMSrcMem, // if >=u, R32 = [mem32]
521 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000522 "cmovae {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000523
Chris Lattner3a173df2004-10-03 20:35:00 +0000524def CMOVE16rr : I<0x44, MRMSrcReg, // if ==, R16 = R16
525 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000526 "cmove {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000527def CMOVE16rm : I<0x44, MRMSrcMem, // if ==, R16 = [mem16]
528 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000529 "cmove {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000530def CMOVE32rr : I<0x44, MRMSrcReg, // if ==, R32 = R32
531 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000532 "cmove {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000533def CMOVE32rm : I<0x44, MRMSrcMem, // if ==, R32 = [mem32]
534 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000535 "cmove {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000536
Chris Lattner3a173df2004-10-03 20:35:00 +0000537def CMOVNE16rr: I<0x45, MRMSrcReg, // if !=, R16 = R16
538 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000539 "cmovne {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000540def CMOVNE16rm: I<0x45, MRMSrcMem, // if !=, R16 = [mem16]
541 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000542 "cmovne {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000543def CMOVNE32rr: I<0x45, MRMSrcReg, // if !=, R32 = R32
544 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000545 "cmovne {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000546def CMOVNE32rm: I<0x45, MRMSrcMem, // if !=, R32 = [mem32]
547 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000548 "cmovne {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000549
Chris Lattner3a173df2004-10-03 20:35:00 +0000550def CMOVBE16rr: I<0x46, MRMSrcReg, // if <=u, R16 = R16
551 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000552 "cmovbe {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000553def CMOVBE16rm: I<0x46, MRMSrcMem, // if <=u, R16 = [mem16]
554 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000555 "cmovbe {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000556def CMOVBE32rr: I<0x46, MRMSrcReg, // if <=u, R32 = R32
557 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000558 "cmovbe {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000559def CMOVBE32rm: I<0x46, MRMSrcMem, // if <=u, R32 = [mem32]
560 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000561 "cmovbe {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000562
Chris Lattner3a173df2004-10-03 20:35:00 +0000563def CMOVA16rr : I<0x47, MRMSrcReg, // if >u, R16 = R16
564 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000565 "cmova {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000566def CMOVA16rm : I<0x47, MRMSrcMem, // if >u, R16 = [mem16]
567 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000568 "cmova {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000569def CMOVA32rr : I<0x47, MRMSrcReg, // if >u, R32 = R32
570 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000571 "cmova {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000572def CMOVA32rm : I<0x47, MRMSrcMem, // if >u, R32 = [mem32]
573 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000574 "cmova {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000575
Chris Lattner3a173df2004-10-03 20:35:00 +0000576def CMOVS16rr : I<0x48, MRMSrcReg, // if signed, R16 = R16
577 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000578 "cmovs {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000579def CMOVS16rm : I<0x48, MRMSrcMem, // if signed, R16 = [mem16]
580 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000581 "cmovs {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000582def CMOVS32rr : I<0x48, MRMSrcReg, // if signed, R32 = R32
583 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000584 "cmovs {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000585def CMOVS32rm : I<0x48, MRMSrcMem, // if signed, R32 = [mem32]
586 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000587 "cmovs {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000588
Chris Lattner3a173df2004-10-03 20:35:00 +0000589def CMOVNS16rr: I<0x49, MRMSrcReg, // if !signed, R16 = R16
590 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000591 "cmovns {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000592def CMOVNS16rm: I<0x49, MRMSrcMem, // if !signed, R16 = [mem16]
593 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000594 "cmovns {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000595def CMOVNS32rr: I<0x49, MRMSrcReg, // if !signed, R32 = R32
596 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000597 "cmovns {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000598def CMOVNS32rm: I<0x49, MRMSrcMem, // if !signed, R32 = [mem32]
599 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000600 "cmovns {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000601
Chris Lattner57fbfb52005-01-10 22:09:33 +0000602def CMOVP16rr : I<0x4A, MRMSrcReg, // if parity, R16 = R16
603 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000604 "cmovp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000605def CMOVP16rm : I<0x4A, MRMSrcMem, // if parity, R16 = [mem16]
606 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000607 "cmovp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000608def CMOVP32rr : I<0x4A, MRMSrcReg, // if parity, R32 = R32
609 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000610 "cmovp {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000611def CMOVP32rm : I<0x4A, MRMSrcMem, // if parity, R32 = [mem32]
612 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000613 "cmovp {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000614
615
616def CMOVNP16rr : I<0x4B, MRMSrcReg, // if !parity, R16 = R16
617 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000618 "cmovnp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000619def CMOVNP16rm : I<0x4B, MRMSrcMem, // if !parity, R16 = [mem16]
620 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000621 "cmovnp {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000622def CMOVNP32rr : I<0x4B, MRMSrcReg, // if !parity, R32 = R32
623 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000624 "cmovnp {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000625def CMOVNP32rm : I<0x4B, MRMSrcMem, // if !parity, R32 = [mem32]
626 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000627 "cmovnp {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner57fbfb52005-01-10 22:09:33 +0000628
629
Chris Lattner3a173df2004-10-03 20:35:00 +0000630def CMOVL16rr : I<0x4C, MRMSrcReg, // if <s, R16 = R16
631 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000632 "cmovl {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000633def CMOVL16rm : I<0x4C, MRMSrcMem, // if <s, R16 = [mem16]
634 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000635 "cmovl {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000636def CMOVL32rr : I<0x4C, MRMSrcReg, // if <s, R32 = R32
637 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000638 "cmovl {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000639def CMOVL32rm : I<0x4C, MRMSrcMem, // if <s, R32 = [mem32]
640 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000641 "cmovl {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000642
Chris Lattner3a173df2004-10-03 20:35:00 +0000643def CMOVGE16rr: I<0x4D, MRMSrcReg, // if >=s, R16 = R16
644 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000645 "cmovge {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000646def CMOVGE16rm: I<0x4D, MRMSrcMem, // if >=s, R16 = [mem16]
647 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000648 "cmovge {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000649def CMOVGE32rr: I<0x4D, MRMSrcReg, // if >=s, R32 = R32
650 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000651 "cmovge {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000652def CMOVGE32rm: I<0x4D, MRMSrcMem, // if >=s, R32 = [mem32]
653 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000654 "cmovge {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000655
Chris Lattner3a173df2004-10-03 20:35:00 +0000656def CMOVLE16rr: I<0x4E, MRMSrcReg, // if <=s, R16 = R16
657 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000658 "cmovle {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000659def CMOVLE16rm: I<0x4E, MRMSrcMem, // if <=s, R16 = [mem16]
660 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000661 "cmovle {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000662def CMOVLE32rr: I<0x4E, MRMSrcReg, // if <=s, R32 = R32
663 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000664 "cmovle {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000665def CMOVLE32rm: I<0x4E, MRMSrcMem, // if <=s, R32 = [mem32]
666 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000667 "cmovle {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000668
Chris Lattner3a173df2004-10-03 20:35:00 +0000669def CMOVG16rr : I<0x4F, MRMSrcReg, // if >s, R16 = R16
670 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000671 "cmovg {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000672def CMOVG16rm : I<0x4F, MRMSrcMem, // if >s, R16 = [mem16]
673 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000674 "cmovg {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000675def CMOVG32rr : I<0x4F, MRMSrcReg, // if >s, R32 = R32
676 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000677 "cmovg {$src2, $dst|$dst, $src2}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +0000678def CMOVG32rm : I<0x4F, MRMSrcMem, // if >s, R32 = [mem32]
679 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000680 "cmovg {$src2, $dst|$dst, $src2}", []>, TB;
Alkis Evlogimenosa3f66842004-03-12 17:59:56 +0000681
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000682// unary instructions
Evan Chengf0701842005-11-29 19:38:52 +0000683def NEG8r : I<0xF6, MRM3r, (ops R8 :$dst, R8 :$src), "neg{b} $dst",
684 [(set R8:$dst, (ineg R8:$src))]>;
685def NEG16r : I<0xF7, MRM3r, (ops R16:$dst, R16:$src), "neg{w} $dst",
686 [(set R16:$dst, (ineg R16:$src))]>, OpSize;
687def NEG32r : I<0xF7, MRM3r, (ops R32:$dst, R32:$src), "neg{l} $dst",
688 [(set R32:$dst, (ineg R32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000689let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +0000690 def NEG8m : I<0xF6, MRM3m, (ops i8mem :$dst), "neg{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000691 [(store (ineg (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +0000692 def NEG16m : I<0xF7, MRM3m, (ops i16mem:$dst), "neg{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000693 [(store (ineg (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +0000694 def NEG32m : I<0xF7, MRM3m, (ops i32mem:$dst), "neg{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000695 [(store (ineg (loadi32 addr:$dst)), addr:$dst)]>;
696
Chris Lattner57a02302004-08-11 04:31:00 +0000697}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000698
Evan Chengf0701842005-11-29 19:38:52 +0000699def NOT8r : I<0xF6, MRM2r, (ops R8 :$dst, R8 :$src), "not{b} $dst",
700 [(set R8:$dst, (not R8:$src))]>;
701def NOT16r : I<0xF7, MRM2r, (ops R16:$dst, R16:$src), "not{w} $dst",
702 [(set R16:$dst, (not R16:$src))]>, OpSize;
703def NOT32r : I<0xF7, MRM2r, (ops R32:$dst, R32:$src), "not{l} $dst",
704 [(set R32:$dst, (not R32:$src))]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000705let isTwoAddress = 0 in {
Evan Cheng5ce4edb2005-12-13 00:54:44 +0000706 def NOT8m : I<0xF6, MRM2m, (ops i8mem :$dst), "not{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000707 [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
Evan Cheng5ce4edb2005-12-13 00:54:44 +0000708 def NOT16m : I<0xF7, MRM2m, (ops i16mem:$dst), "not{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000709 [(store (not (loadi16 addr:$dst)), addr:$dst)]>, OpSize;
Evan Cheng5ce4edb2005-12-13 00:54:44 +0000710 def NOT32m : I<0xF7, MRM2m, (ops i32mem:$dst), "not{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000711 [(store (not (loadi32 addr:$dst)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000712}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000713
Evan Chengb51a0592005-12-10 00:48:20 +0000714// TODO: inc/dec is slow for P4, but fast for Pentium-M.
Evan Chengf0701842005-11-29 19:38:52 +0000715def INC8r : I<0xFE, MRM0r, (ops R8 :$dst, R8 :$src), "inc{b} $dst",
716 [(set R8:$dst, (add R8:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000717let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengf0701842005-11-29 19:38:52 +0000718def INC16r : I<0xFF, MRM0r, (ops R16:$dst, R16:$src), "inc{w} $dst",
719 [(set R16:$dst, (add R16:$src, 1))]>, OpSize;
720def INC32r : I<0xFF, MRM0r, (ops R32:$dst, R32:$src), "inc{l} $dst",
721 [(set R32:$dst, (add R32:$src, 1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000722}
Chris Lattner57a02302004-08-11 04:31:00 +0000723let isTwoAddress = 0 in {
Evan Cheng6cad2762005-12-13 01:02:47 +0000724 def INC8m : I<0xFE, MRM0m, (ops i8mem :$dst), "inc{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000725 [(store (add (loadi8 addr:$dst), 1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +0000726 def INC16m : I<0xFF, MRM0m, (ops i16mem:$dst), "inc{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000727 [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +0000728 def INC32m : I<0xFF, MRM0m, (ops i32mem:$dst), "inc{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000729 [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000730}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000731
Evan Chengb51a0592005-12-10 00:48:20 +0000732def DEC8r : I<0xFE, MRM1r, (ops R8 :$dst, R8 :$src), "dec{b} $dst",
733 [(set R8:$dst, (add R8:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000734let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Evan Chengb51a0592005-12-10 00:48:20 +0000735def DEC16r : I<0xFF, MRM1r, (ops R16:$dst, R16:$src), "dec{w} $dst",
736 [(set R16:$dst, (add R16:$src, -1))]>, OpSize;
737def DEC32r : I<0xFF, MRM1r, (ops R32:$dst, R32:$src), "dec{l} $dst",
738 [(set R32:$dst, (add R32:$src, -1))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000739}
Chris Lattner57a02302004-08-11 04:31:00 +0000740
741let isTwoAddress = 0 in {
Evan Cheng6cad2762005-12-13 01:02:47 +0000742 def DEC8m : I<0xFE, MRM1m, (ops i8mem :$dst), "dec{b} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000743 [(store (add (loadi8 addr:$dst), -1), addr:$dst)]>;
Evan Cheng6cad2762005-12-13 01:02:47 +0000744 def DEC16m : I<0xFF, MRM1m, (ops i16mem:$dst), "dec{w} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000745 [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, OpSize;
Evan Cheng6cad2762005-12-13 01:02:47 +0000746 def DEC32m : I<0xFF, MRM1m, (ops i32mem:$dst), "dec{l} $dst",
Evan Cheng605c4152005-12-13 01:57:51 +0000747 [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000748}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000749
750// Logical operators...
Chris Lattnercc65bee2005-01-02 02:35:46 +0000751let isCommutable = 1 in { // X = AND Y, Z --> X = AND Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +0000752def AND8rr : I<0x20, MRMDestReg,
753 (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000754 "and{b} {$src2, $dst|$dst, $src2}",
755 [(set R8:$dst, (and R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000756def AND16rr : I<0x21, MRMDestReg,
757 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000758 "and{w} {$src2, $dst|$dst, $src2}",
759 [(set R16:$dst, (and R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000760def AND32rr : I<0x21, MRMDestReg,
761 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000762 "and{l} {$src2, $dst|$dst, $src2}",
763 [(set R32:$dst, (and R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000764}
Chris Lattner57a02302004-08-11 04:31:00 +0000765
Chris Lattner3a173df2004-10-03 20:35:00 +0000766def AND8rm : I<0x22, MRMSrcMem,
767 (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000768 "and{b} {$src2, $dst|$dst, $src2}",
769 [(set R8:$dst, (and R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000770def AND16rm : I<0x23, MRMSrcMem,
771 (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000772 "and{w} {$src2, $dst|$dst, $src2}",
773 [(set R16:$dst, (and R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000774def AND32rm : I<0x23, MRMSrcMem,
775 (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000776 "and{l} {$src2, $dst|$dst, $src2}",
777 [(set R32:$dst, (and R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000778
Chris Lattner3a173df2004-10-03 20:35:00 +0000779def AND8ri : Ii8<0x80, MRM4r,
780 (ops R8 :$dst, R8 :$src1, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000781 "and{b} {$src2, $dst|$dst, $src2}",
782 [(set R8:$dst, (and R8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000783def AND16ri : Ii16<0x81, MRM4r,
784 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +0000785 "and{w} {$src2, $dst|$dst, $src2}",
786 [(set R16:$dst, (and R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000787def AND32ri : Ii32<0x81, MRM4r,
788 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000789 "and{l} {$src2, $dst|$dst, $src2}",
790 [(set R32:$dst, (and R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000791def AND16ri8 : Ii8<0x83, MRM4r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000792 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
793 "and{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +0000794 [(set R16:$dst, (and R16:$src1, i16immSExt8:$src2))]>,
795 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000796def AND32ri8 : Ii8<0x83, MRM4r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000797 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
798 "and{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +0000799 [(set R32:$dst, (and R32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +0000800
801let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +0000802 def AND8mr : I<0x20, MRMDestMem,
803 (ops i8mem :$dst, R8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000804 "and{b} {$src, $dst|$dst, $src}",
805 [(store (and (load addr:$dst), R8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000806 def AND16mr : I<0x21, MRMDestMem,
807 (ops i16mem:$dst, R16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000808 "and{w} {$src, $dst|$dst, $src}",
809 [(store (and (load addr:$dst), R16:$src), addr:$dst)]>,
810 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000811 def AND32mr : I<0x21, MRMDestMem,
812 (ops i32mem:$dst, R32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000813 "and{l} {$src, $dst|$dst, $src}",
814 [(store (and (load addr:$dst), R32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000815 def AND8mi : Ii8<0x80, MRM4m,
816 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000817 "and{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +0000818 [(store (and (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000819 def AND16mi : Ii16<0x81, MRM4m,
820 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000821 "and{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +0000822 [(store (and (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +0000823 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000824 def AND32mi : Ii32<0x81, MRM4m,
825 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000826 "and{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +0000827 [(store (and (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000828 def AND16mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +0000829 (ops i16mem:$dst, i16i8imm :$src),
830 "and{w} {$src, $dst|$dst, $src}",
831 [(store (and (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
832 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000833 def AND32mi8 : Ii8<0x83, MRM4m,
Evan Cheng0ef3a772005-12-13 01:41:36 +0000834 (ops i32mem:$dst, i32i8imm :$src),
835 "and{l} {$src, $dst|$dst, $src}",
836 [(store (add (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +0000837}
838
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000839
Chris Lattnercc65bee2005-01-02 02:35:46 +0000840let isCommutable = 1 in { // X = OR Y, Z --> X = OR Z, Y
Chris Lattner36b68902004-08-10 21:21:30 +0000841def OR8rr : I<0x08, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000842 "or{b} {$src2, $dst|$dst, $src2}",
843 [(set R8:$dst, (or R8:$src1, R8:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +0000844def OR16rr : I<0x09, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000845 "or{w} {$src2, $dst|$dst, $src2}",
846 [(set R16:$dst, (or R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +0000847def OR32rr : I<0x09, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000848 "or{l} {$src2, $dst|$dst, $src2}",
849 [(set R32:$dst, (or R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000850}
Chris Lattner57a02302004-08-11 04:31:00 +0000851def OR8rm : I<0x0A, MRMSrcMem , (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000852 "or{b} {$src2, $dst|$dst, $src2}",
853 [(set R8:$dst, (or R8:$src1, (load addr:$src2)))]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000854def OR16rm : I<0x0B, MRMSrcMem , (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000855 "or{w} {$src2, $dst|$dst, $src2}",
856 [(set R16:$dst, (or R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +0000857def OR32rm : I<0x0B, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000858 "or{l} {$src2, $dst|$dst, $src2}",
859 [(set R32:$dst, (or R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000860
Chris Lattner36b68902004-08-10 21:21:30 +0000861def OR8ri : Ii8 <0x80, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000862 "or{b} {$src2, $dst|$dst, $src2}",
863 [(set R8:$dst, (or R8:$src1, imm:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +0000864def OR16ri : Ii16<0x81, MRM1r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +0000865 "or{w} {$src2, $dst|$dst, $src2}",
866 [(set R16:$dst, (or R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +0000867def OR32ri : Ii32<0x81, MRM1r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000868 "or{l} {$src2, $dst|$dst, $src2}",
869 [(set R32:$dst, (or R32:$src1, imm:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000870
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000871def OR16ri8 : Ii8<0x83, MRM1r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
872 "or{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +0000873 [(set R16:$dst, (or R16:$src1, i16immSExt8:$src2))]>, OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000874def OR32ri8 : Ii8<0x83, MRM1r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
875 "or{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +0000876 [(set R32:$dst, (or R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000877let isTwoAddress = 0 in {
Chris Lattnerf29ed092004-08-11 05:07:25 +0000878 def OR8mr : I<0x08, MRMDestMem, (ops i8mem:$dst, R8:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000879 "or{b} {$src, $dst|$dst, $src}",
880 [(store (or (load addr:$dst), R8:$src), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +0000881 def OR16mr : I<0x09, MRMDestMem, (ops i16mem:$dst, R16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000882 "or{w} {$src, $dst|$dst, $src}",
883 [(store (or (load addr:$dst), R16:$src), addr:$dst)]>, OpSize;
Chris Lattnerf29ed092004-08-11 05:07:25 +0000884 def OR32mr : I<0x09, MRMDestMem, (ops i32mem:$dst, R32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000885 "or{l} {$src, $dst|$dst, $src}",
886 [(store (or (load addr:$dst), R32:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +0000887 def OR8mi : Ii8<0x80, MRM1m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000888 "or{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +0000889 [(store (or (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +0000890 def OR16mi : Ii16<0x81, MRM1m, (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000891 "or{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +0000892 [(store (or (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +0000893 OpSize;
Chris Lattnerf5d3a832004-08-11 05:31:07 +0000894 def OR32mi : Ii32<0x81, MRM1m, (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000895 "or{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +0000896 [(store (or (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Evan Cheng0ef3a772005-12-13 01:41:36 +0000897 def OR16mi8 : Ii8<0x83, MRM1m, (ops i16mem:$dst, i16i8imm:$src),
898 "or{w} {$src, $dst|$dst, $src}",
899 [(store (or (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
900 OpSize;
901 def OR32mi8 : Ii8<0x83, MRM1m, (ops i32mem:$dst, i32i8imm:$src),
902 "or{l} {$src, $dst|$dst, $src}",
903 [(store (or (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000904}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000905
906
Chris Lattnercc65bee2005-01-02 02:35:46 +0000907let isCommutable = 1 in { // X = XOR Y, Z --> X = XOR Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +0000908def XOR8rr : I<0x30, MRMDestReg,
909 (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000910 "xor{b} {$src2, $dst|$dst, $src2}",
911 [(set R8:$dst, (xor R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000912def XOR16rr : I<0x31, MRMDestReg,
913 (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000914 "xor{w} {$src2, $dst|$dst, $src2}",
915 [(set R16:$dst, (xor R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000916def XOR32rr : I<0x31, MRMDestReg,
917 (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +0000918 "xor{l} {$src2, $dst|$dst, $src2}",
919 [(set R32:$dst, (xor R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +0000920}
921
Chris Lattner3a173df2004-10-03 20:35:00 +0000922def XOR8rm : I<0x32, MRMSrcMem ,
923 (ops R8 :$dst, R8:$src1, i8mem :$src2),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000924 "xor{b} {$src2, $dst|$dst, $src2}",
925 [(set R8:$dst, (xor R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000926def XOR16rm : I<0x33, MRMSrcMem ,
Evan Cheng0ef3a772005-12-13 01:41:36 +0000927 (ops R16:$dst, R16:$src1, i16mem:$src2),
928 "xor{w} {$src2, $dst|$dst, $src2}",
929 [(set R16:$dst, (xor R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000930def XOR32rm : I<0x33, MRMSrcMem ,
Evan Cheng0ef3a772005-12-13 01:41:36 +0000931 (ops R32:$dst, R32:$src1, i32mem:$src2),
932 "xor{l} {$src2, $dst|$dst, $src2}",
933 [(set R32:$dst, (xor R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000934
Chris Lattner3a173df2004-10-03 20:35:00 +0000935def XOR8ri : Ii8<0x80, MRM6r,
936 (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000937 "xor{b} {$src2, $dst|$dst, $src2}",
938 [(set R8:$dst, (xor R8:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000939def XOR16ri : Ii16<0x81, MRM6r,
940 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +0000941 "xor{w} {$src2, $dst|$dst, $src2}",
942 [(set R16:$dst, (xor R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000943def XOR32ri : Ii32<0x81, MRM6r,
944 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +0000945 "xor{l} {$src2, $dst|$dst, $src2}",
946 [(set R32:$dst, (xor R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000947def XOR16ri8 : Ii8<0x83, MRM6r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000948 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
949 "xor{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +0000950 [(set R16:$dst, (xor R16:$src1, i16immSExt8:$src2))]>,
951 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000952def XOR32ri8 : Ii8<0x83, MRM6r,
Chris Lattnerf124d5e2005-11-18 01:04:42 +0000953 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
954 "xor{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +0000955 [(set R32:$dst, (xor R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000956let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +0000957 def XOR8mr : I<0x30, MRMDestMem,
958 (ops i8mem :$dst, R8 :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000959 "xor{b} {$src, $dst|$dst, $src}",
960 [(store (xor (load addr:$dst), R8:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000961 def XOR16mr : I<0x31, MRMDestMem,
962 (ops i16mem:$dst, R16:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000963 "xor{w} {$src, $dst|$dst, $src}",
964 [(store (xor (load addr:$dst), R16:$src), addr:$dst)]>,
965 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000966 def XOR32mr : I<0x31, MRMDestMem,
967 (ops i32mem:$dst, R32:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000968 "xor{l} {$src, $dst|$dst, $src}",
969 [(store (xor (load addr:$dst), R32:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000970 def XOR8mi : Ii8<0x80, MRM6m,
971 (ops i8mem :$dst, i8imm :$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000972 "xor{b} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +0000973 [(store (xor (loadi8 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000974 def XOR16mi : Ii16<0x81, MRM6m,
975 (ops i16mem:$dst, i16imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000976 "xor{w} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +0000977 [(store (xor (loadi16 addr:$dst), imm:$src), addr:$dst)]>,
Evan Cheng0ef3a772005-12-13 01:41:36 +0000978 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000979 def XOR32mi : Ii32<0x81, MRM6m,
980 (ops i32mem:$dst, i32imm:$src),
Evan Cheng0ef3a772005-12-13 01:41:36 +0000981 "xor{l} {$src, $dst|$dst, $src}",
Evan Chengc937ffa2005-12-13 02:40:18 +0000982 [(store (xor (loadi32 addr:$dst), imm:$src), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000983 def XOR16mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +0000984 (ops i16mem:$dst, i16i8imm :$src),
985 "xor{w} {$src, $dst|$dst, $src}",
986 [(store (xor (load addr:$dst), i16immSExt8:$src), addr:$dst)]>,
987 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +0000988 def XOR32mi8 : Ii8<0x83, MRM6m,
Evan Cheng0ef3a772005-12-13 01:41:36 +0000989 (ops i32mem:$dst, i32i8imm :$src),
990 "xor{l} {$src, $dst|$dst, $src}",
991 [(store (xor (load addr:$dst), i32immSExt8:$src), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +0000992}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +0000993
994// Shift instructions
Alkis Evlogimenos13d362f2004-03-07 03:19:11 +0000995// FIXME: provide shorter instructions when imm8 == 1
Chris Lattner3a173df2004-10-03 20:35:00 +0000996def SHL8rCL : I<0xD2, MRM4r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +0000997 "shl{b} {%cl, $dst|$dst, %CL}",
998 [(set R8:$dst, (shl R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +0000999def SHL16rCL : I<0xD3, MRM4r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001000 "shl{w} {%cl, $dst|$dst, %CL}",
1001 [(set R16:$dst, (shl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001002def SHL32rCL : I<0xD3, MRM4r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001003 "shl{l} {%cl, $dst|$dst, %CL}",
1004 [(set R32:$dst, (shl R32:$src, CL))]>, Imp<[CL],[]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001005
Chris Lattner36b68902004-08-10 21:21:30 +00001006def SHL8ri : Ii8<0xC0, MRM4r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001007 "shl{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001008 [(set R8:$dst, (shl R8:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001009let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001010def SHL16ri : Ii8<0xC1, MRM4r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001011 "shl{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001012 [(set R16:$dst, (shl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1013def SHL32ri : Ii8<0xC1, MRM4r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001014 "shl{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001015 [(set R32:$dst, (shl R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001016}
Chris Lattnerf29ed092004-08-11 05:07:25 +00001017
1018let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001019 def SHL8mCL : I<0xD2, MRM4m, (ops i8mem :$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001020 "shl{b} {%cl, $dst|$dst, %CL}",
1021 [(store (shl (loadi8 addr:$dst), CL), addr:$dst)]>,
1022 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001023 def SHL16mCL : I<0xD3, MRM4m, (ops i16mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001024 "shl{w} {%cl, $dst|$dst, %CL}",
1025 [(store (shl (loadi16 addr:$dst), CL), addr:$dst)]>,
1026 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001027 def SHL32mCL : I<0xD3, MRM4m, (ops i32mem:$dst),
Evan Cheng763b0292005-12-13 02:34:51 +00001028 "shl{l} {%cl, $dst|$dst, %CL}",
1029 [(store (shl (loadi32 addr:$dst), CL), addr:$dst)]>,
1030 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001031 def SHL8mi : Ii8<0xC0, MRM4m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001032 "shl{b} {$src, $dst|$dst, $src}",
1033 [(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001034 def SHL16mi : Ii8<0xC1, MRM4m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001035 "shl{w} {$src, $dst|$dst, $src}",
1036 [(store (shl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1037 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001038 def SHL32mi : Ii8<0xC1, MRM4m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng763b0292005-12-13 02:34:51 +00001039 "shl{l} {$src, $dst|$dst, $src}",
1040 [(store (shl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001041}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001042
Chris Lattner3a173df2004-10-03 20:35:00 +00001043def SHR8rCL : I<0xD2, MRM5r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001044 "shr{b} {%cl, $dst|$dst, %CL}",
1045 [(set R8:$dst, (srl R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001046def SHR16rCL : I<0xD3, MRM5r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001047 "shr{w} {%cl, $dst|$dst, %CL}",
1048 [(set R16:$dst, (srl R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001049def SHR32rCL : I<0xD3, MRM5r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001050 "shr{l} {%cl, $dst|$dst, %CL}",
1051 [(set R32:$dst, (srl R32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001052
Chris Lattner3a173df2004-10-03 20:35:00 +00001053def SHR8ri : Ii8<0xC0, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001054 "shr{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001055 [(set R8:$dst, (srl R8:$src1, (i8 imm:$src2)))]>;
1056def SHR16ri : Ii8<0xC1, MRM5r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001057 "shr{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001058 [(set R16:$dst, (srl R16:$src1, (i8 imm:$src2)))]>, OpSize;
1059def SHR32ri : Ii8<0xC1, MRM5r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001060 "shr{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001061 [(set R32:$dst, (srl R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001062
Chris Lattner57a02302004-08-11 04:31:00 +00001063let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001064 def SHR8mCL : I<0xD2, MRM5m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001065 "shr{b} {%cl, $dst|$dst, %CL}",
1066 [(store (srl (loadi8 addr:$dst), CL), addr:$dst)]>,
1067 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001068 def SHR16mCL : I<0xD3, MRM5m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001069 "shr{w} {%cl, $dst|$dst, %CL}",
1070 [(store (srl (loadi16 addr:$dst), CL), addr:$dst)]>,
1071 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001072 def SHR32mCL : I<0xD3, MRM5m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001073 "shr{l} {%cl, $dst|$dst, %CL}",
1074 [(store (srl (loadi32 addr:$dst), CL), addr:$dst)]>,
1075 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001076 def SHR8mi : Ii8<0xC0, MRM5m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001077 "shr{b} {$src, $dst|$dst, $src}",
1078 [(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001079 def SHR16mi : Ii8<0xC1, MRM5m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001080 "shr{w} {$src, $dst|$dst, $src}",
1081 [(store (srl (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1082 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001083 def SHR32mi : Ii8<0xC1, MRM5m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001084 "shr{l} {$src, $dst|$dst, $src}",
1085 [(store (srl (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001086}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001087
Chris Lattner3a173df2004-10-03 20:35:00 +00001088def SAR8rCL : I<0xD2, MRM7r, (ops R8 :$dst, R8 :$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001089 "sar{b} {%cl, $dst|$dst, %CL}",
1090 [(set R8:$dst, (sra R8:$src, CL))]>, Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001091def SAR16rCL : I<0xD3, MRM7r, (ops R16:$dst, R16:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001092 "sar{w} {%cl, $dst|$dst, %CL}",
1093 [(set R16:$dst, (sra R16:$src, CL))]>, Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001094def SAR32rCL : I<0xD3, MRM7r, (ops R32:$dst, R32:$src),
Evan Cheng640f2992005-12-01 00:43:55 +00001095 "sar{l} {%cl, $dst|$dst, %CL}",
1096 [(set R32:$dst, (sra R32:$src, CL))]>, Imp<[CL],[]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001097
Chris Lattner36b68902004-08-10 21:21:30 +00001098def SAR8ri : Ii8<0xC0, MRM7r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001099 "sar{b} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001100 [(set R8:$dst, (sra R8:$src1, (i8 imm:$src2)))]>;
1101def SAR16ri : Ii8<0xC1, MRM7r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001102 "sar{w} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001103 [(set R16:$dst, (sra R16:$src1, (i8 imm:$src2)))]>,
1104 OpSize;
1105def SAR32ri : Ii8<0xC1, MRM7r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001106 "sar{l} {$src2, $dst|$dst, $src2}",
Chris Lattner3d36a9f2005-12-05 02:40:25 +00001107 [(set R32:$dst, (sra R32:$src1, (i8 imm:$src2)))]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001108let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001109 def SAR8mCL : I<0xD2, MRM7m, (ops i8mem :$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001110 "sar{b} {%cl, $dst|$dst, %CL}",
1111 [(store (sra (loadi8 addr:$dst), CL), addr:$dst)]>,
1112 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001113 def SAR16mCL : I<0xD3, MRM7m, (ops i16mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001114 "sar{w} {%cl, $dst|$dst, %CL}",
1115 [(store (sra (loadi16 addr:$dst), CL), addr:$dst)]>,
1116 Imp<[CL],[]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001117 def SAR32mCL : I<0xD3, MRM7m, (ops i32mem:$dst),
Evan Cheng85dd8892005-12-13 07:24:22 +00001118 "sar{l} {%cl, $dst|$dst, %CL}",
1119 [(store (sra (loadi32 addr:$dst), CL), addr:$dst)]>,
1120 Imp<[CL],[]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001121 def SAR8mi : Ii8<0xC0, MRM7m, (ops i8mem :$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001122 "sar{b} {$src, $dst|$dst, $src}",
1123 [(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001124 def SAR16mi : Ii8<0xC1, MRM7m, (ops i16mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001125 "sar{w} {$src, $dst|$dst, $src}",
1126 [(store (sra (loadi16 addr:$dst), (i8 imm:$src)), addr:$dst)]>,
1127 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001128 def SAR32mi : Ii8<0xC1, MRM7m, (ops i32mem:$dst, i8imm:$src),
Evan Cheng85dd8892005-12-13 07:24:22 +00001129 "sar{l} {$src, $dst|$dst, $src}",
1130 [(store (sra (loadi32 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
Chris Lattnerf29ed092004-08-11 05:07:25 +00001131}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001132
Chris Lattner40ff6332005-01-19 07:50:03 +00001133// Rotate instructions
1134// FIXME: provide shorter instructions when imm8 == 1
1135def ROL8rCL : I<0xD2, MRM0r, (ops R8 :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001136 "rol{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001137def ROL16rCL : I<0xD3, MRM0r, (ops R16:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001138 "rol{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001139def ROL32rCL : I<0xD3, MRM0r, (ops R32:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001140 "rol{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001141
1142def ROL8ri : Ii8<0xC0, MRM0r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001143 "rol{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001144def ROL16ri : Ii8<0xC1, MRM0r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001145 "rol{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001146def ROL32ri : Ii8<0xC1, MRM0r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001147 "rol{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001148
1149let isTwoAddress = 0 in {
1150 def ROL8mCL : I<0xD2, MRM0m, (ops i8mem :$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001151 "rol{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001152 def ROL16mCL : I<0xD3, MRM0m, (ops i16mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001153 "rol{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001154 def ROL32mCL : I<0xD3, MRM0m, (ops i32mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001155 "rol{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001156 def ROL8mi : Ii8<0xC0, MRM0m, (ops i8mem :$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001157 "rol{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001158 def ROL16mi : Ii8<0xC1, MRM0m, (ops i16mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001159 "rol{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001160 def ROL32mi : Ii8<0xC1, MRM0m, (ops i32mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001161 "rol{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001162}
1163
1164def ROR8rCL : I<0xD2, MRM1r, (ops R8 :$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001165 "ror{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001166def ROR16rCL : I<0xD3, MRM1r, (ops R16:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001167 "ror{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001168def ROR32rCL : I<0xD3, MRM1r, (ops R32:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001169 "ror{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001170
1171def ROR8ri : Ii8<0xC0, MRM1r, (ops R8 :$dst, R8 :$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001172 "ror{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001173def ROR16ri : Ii8<0xC1, MRM1r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001174 "ror{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001175def ROR32ri : Ii8<0xC1, MRM1r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001176 "ror{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001177let isTwoAddress = 0 in {
1178 def ROR8mCL : I<0xD2, MRM1m, (ops i8mem :$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001179 "ror{b} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001180 def ROR16mCL : I<0xD3, MRM1m, (ops i16mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001181 "ror{w} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001182 def ROR32mCL : I<0xD3, MRM1m, (ops i32mem:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001183 "ror{l} {%cl, $dst|$dst, %CL}", []>, Imp<[CL],[]>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001184 def ROR8mi : Ii8<0xC0, MRM1m, (ops i8mem :$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001185 "ror{b} {$src, $dst|$dst, $src}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001186 def ROR16mi : Ii8<0xC1, MRM1m, (ops i16mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001187 "ror{w} {$src, $dst|$dst, $src}", []>, OpSize;
Chris Lattner40ff6332005-01-19 07:50:03 +00001188 def ROR32mi : Ii8<0xC1, MRM1m, (ops i32mem:$dst, i8imm:$src),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001189 "ror{l} {$src, $dst|$dst, $src}", []>;
Chris Lattner40ff6332005-01-19 07:50:03 +00001190}
1191
1192
1193
1194// Double shift instructions (generalizations of rotate)
1195
Chris Lattner57a02302004-08-11 04:31:00 +00001196def SHLD32rrCL : I<0xA5, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001197 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001198 Imp<[CL],[]>, TB;
Chris Lattner57a02302004-08-11 04:31:00 +00001199def SHRD32rrCL : I<0xAD, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001200 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001201 Imp<[CL],[]>, TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001202def SHLD16rrCL : I<0xA5, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001203 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001204 Imp<[CL],[]>, TB, OpSize;
1205def SHRD16rrCL : I<0xAD, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001206 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001207 Imp<[CL],[]>, TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001208
1209let isCommutable = 1 in { // These instructions commute to each other.
Chris Lattner3a173df2004-10-03 20:35:00 +00001210def SHLD32rri8 : Ii8<0xA4, MRMDestReg,
1211 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001212 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001213def SHRD32rri8 : Ii8<0xAC, MRMDestReg,
1214 (ops R32:$dst, R32:$src1, R32:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001215 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>, TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001216def SHLD16rri8 : Ii8<0xA4, MRMDestReg,
1217 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001218 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001219 TB, OpSize;
1220def SHRD16rri8 : Ii8<0xAC, MRMDestReg,
1221 (ops R16:$dst, R16:$src1, R16:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001222 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001223 TB, OpSize;
Chris Lattner41e431b2005-01-19 07:11:01 +00001224}
Chris Lattner0e967d42004-08-01 08:13:11 +00001225
Chris Lattner57a02302004-08-11 04:31:00 +00001226let isTwoAddress = 0 in {
1227 def SHLD32mrCL : I<0xA5, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001228 "shld{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001229 Imp<[CL],[]>, TB;
Chris Lattner57a02302004-08-11 04:31:00 +00001230 def SHRD32mrCL : I<0xAD, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001231 "shrd{l} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner3a173df2004-10-03 20:35:00 +00001232 Imp<[CL],[]>, TB;
1233 def SHLD32mri8 : Ii8<0xA4, MRMDestMem,
1234 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001235 "shld{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1236 TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001237 def SHRD32mri8 : Ii8<0xAC, MRMDestMem,
1238 (ops i32mem:$dst, R32:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001239 "shrd{l} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
1240 TB;
Chris Lattner0df53d22005-01-19 07:31:24 +00001241
1242 def SHLD16mrCL : I<0xA5, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001243 "shld{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001244 Imp<[CL],[]>, TB, OpSize;
1245 def SHRD16mrCL : I<0xAD, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001246 "shrd{w} {%cl, $src2, $dst|$dst, $src2, %CL}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001247 Imp<[CL],[]>, TB, OpSize;
1248 def SHLD16mri8 : Ii8<0xA4, MRMDestMem,
1249 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001250 "shld{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001251 TB, OpSize;
1252 def SHRD16mri8 : Ii8<0xAC, MRMDestMem,
1253 (ops i16mem:$dst, R16:$src2, i8imm:$src3),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001254 "shrd{w} {$src3, $src2, $dst|$dst, $src2, $src3}", []>,
Chris Lattner0df53d22005-01-19 07:31:24 +00001255 TB, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001256}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001257
1258
Chris Lattnercc65bee2005-01-02 02:35:46 +00001259// Arithmetic.
1260let isCommutable = 1 in { // X = ADD Y, Z --> X = ADD Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001261def ADD8rr : I<0x00, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001262 "add{b} {$src2, $dst|$dst, $src2}",
1263 [(set R8:$dst, (add R8:$src1, R8:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001264let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3a173df2004-10-03 20:35:00 +00001265def ADD16rr : I<0x01, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001266 "add{w} {$src2, $dst|$dst, $src2}",
1267 [(set R16:$dst, (add R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001268def ADD32rr : I<0x01, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001269 "add{l} {$src2, $dst|$dst, $src2}",
1270 [(set R32:$dst, (add R32:$src1, R32:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001271} // end isConvertibleToThreeAddress
1272} // end isCommutable
Chris Lattner3a173df2004-10-03 20:35:00 +00001273def ADD8rm : I<0x02, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001274 "add{b} {$src2, $dst|$dst, $src2}",
1275 [(set R8:$dst, (add R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001276def ADD16rm : I<0x03, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001277 "add{w} {$src2, $dst|$dst, $src2}",
1278 [(set R16:$dst, (add R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001279def ADD32rm : I<0x03, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengab24ed22005-12-09 22:48:48 +00001280 "add{l} {$src2, $dst|$dst, $src2}",
1281 [(set R32:$dst, (add R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001282
Chris Lattner3a173df2004-10-03 20:35:00 +00001283def ADD8ri : Ii8<0x80, MRM0r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001284 "add{b} {$src2, $dst|$dst, $src2}",
1285 [(set R8:$dst, (add R8:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001286
1287let isConvertibleToThreeAddress = 1 in { // Can transform into LEA.
Chris Lattner3a173df2004-10-03 20:35:00 +00001288def ADD16ri : Ii16<0x81, MRM0r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001289 "add{w} {$src2, $dst|$dst, $src2}",
1290 [(set R16:$dst, (add R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001291def ADD32ri : Ii32<0x81, MRM0r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001292 "add{l} {$src2, $dst|$dst, $src2}",
1293 [(set R32:$dst, (add R32:$src1, imm:$src2))]>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001294}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001295
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001296// FIXME: move ADD16ri8 above ADD16ri to optimize for space.
1297def ADD16ri8 : Ii8<0x83, MRM0r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1298 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001299 [(set R16:$dst, (add R16:$src1, i16immSExt8:$src2))]>,
1300 OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001301def ADD32ri8 : Ii8<0x83, MRM0r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1302 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001303 [(set R32:$dst, (add R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001304
1305let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001306 def ADD8mr : I<0x00, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001307 "add{b} {$src2, $dst|$dst, $src2}",
1308 [(store (add (load addr:$dst), R8:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001309 def ADD16mr : I<0x01, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001310 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001311 [(store (add (load addr:$dst), R16:$src2), addr:$dst)]>,
1312 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001313 def ADD32mr : I<0x01, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001314 "add{l} {$src2, $dst|$dst, $src2}",
1315 [(store (add (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001316 def ADD8mi : Ii8<0x80, MRM0m, (ops i8mem :$dst, i8imm :$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001317 "add{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001318 [(store (add (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001319 def ADD16mi : Ii16<0x81, MRM0m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001320 "add{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001321 [(store (add (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001322 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001323 def ADD32mi : Ii32<0x81, MRM0m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengee93f9d2005-12-12 19:45:23 +00001324 "add{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001325 [(store (add (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengee93f9d2005-12-12 19:45:23 +00001326 def ADD16mi8 : Ii8<0x83, MRM0m, (ops i16mem:$dst, i16i8imm :$src2),
1327 "add{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001328 [(store (add (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1329 OpSize;
Evan Chengee93f9d2005-12-12 19:45:23 +00001330 def ADD32mi8 : Ii8<0x83, MRM0m, (ops i32mem:$dst, i32i8imm :$src2),
1331 "add{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001332 [(store (add (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001333}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001334
Chris Lattner10197ff2005-01-03 01:27:59 +00001335let isCommutable = 1 in { // X = ADC Y, Z --> X = ADC Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001336def ADC32rr : I<0x11, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001337 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner10197ff2005-01-03 01:27:59 +00001338}
Chris Lattner3a173df2004-10-03 20:35:00 +00001339def ADC32rm : I<0x13, MRMSrcMem , (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001340 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001341def ADC32ri : Ii32<0x81, MRM2r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001342 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001343def ADC32ri8 : Ii8<0x83, MRM2r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001344 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001345
1346let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001347 def ADC32mr : I<0x11, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001348 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001349 def ADC32mi : Ii32<0x81, MRM2m, (ops i32mem:$dst, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001350 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001351 def ADC32mi8 : Ii8<0x83, MRM2m, (ops i32mem:$dst, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001352 "adc{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001353}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001354
Chris Lattner3a173df2004-10-03 20:35:00 +00001355def SUB8rr : I<0x28, MRMDestReg, (ops R8 :$dst, R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001356 "sub{b} {$src2, $dst|$dst, $src2}",
1357 [(set R8:$dst, (sub R8:$src1, R8:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001358def SUB16rr : I<0x29, MRMDestReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001359 "sub{w} {$src2, $dst|$dst, $src2}",
1360 [(set R16:$dst, (sub R16:$src1, R16:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001361def SUB32rr : I<0x29, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001362 "sub{l} {$src2, $dst|$dst, $src2}",
1363 [(set R32:$dst, (sub R32:$src1, R32:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001364def SUB8rm : I<0x2A, MRMSrcMem, (ops R8 :$dst, R8 :$src1, i8mem :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001365 "sub{b} {$src2, $dst|$dst, $src2}",
1366 [(set R8:$dst, (sub R8:$src1, (load addr:$src2)))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001367def SUB16rm : I<0x2B, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001368 "sub{w} {$src2, $dst|$dst, $src2}",
1369 [(set R16:$dst, (sub R16:$src1, (load addr:$src2)))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001370def SUB32rm : I<0x2B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001371 "sub{l} {$src2, $dst|$dst, $src2}",
1372 [(set R32:$dst, (sub R32:$src1, (load addr:$src2)))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001373
Chris Lattner36b68902004-08-10 21:21:30 +00001374def SUB8ri : Ii8 <0x80, MRM5r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001375 "sub{b} {$src2, $dst|$dst, $src2}",
1376 [(set R8:$dst, (sub R8:$src1, imm:$src2))]>;
Chris Lattner36b68902004-08-10 21:21:30 +00001377def SUB16ri : Ii16<0x81, MRM5r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001378 "sub{w} {$src2, $dst|$dst, $src2}",
1379 [(set R16:$dst, (sub R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001380def SUB32ri : Ii32<0x81, MRM5r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001381 "sub{l} {$src2, $dst|$dst, $src2}",
1382 [(set R32:$dst, (sub R32:$src1, imm:$src2))]>;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001383def SUB16ri8 : Ii8<0x83, MRM5r, (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1384 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001385 [(set R16:$dst, (sub R16:$src1, i16immSExt8:$src2))]>,
1386 OpSize;
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001387def SUB32ri8 : Ii8<0x83, MRM5r, (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1388 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001389 [(set R32:$dst, (sub R32:$src1, i32immSExt8:$src2))]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001390let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001391 def SUB8mr : I<0x28, MRMDestMem, (ops i8mem :$dst, R8 :$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001392 "sub{b} {$src2, $dst|$dst, $src2}",
1393 [(store (sub (load addr:$dst), R8:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001394 def SUB16mr : I<0x29, MRMDestMem, (ops i16mem:$dst, R16:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001395 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001396 [(store (sub (load addr:$dst), R16:$src2), addr:$dst)]>,
1397 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001398 def SUB32mr : I<0x29, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001399 "sub{l} {$src2, $dst|$dst, $src2}",
1400 [(store (sub (load addr:$dst), R32:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001401 def SUB8mi : Ii8<0x80, MRM5m, (ops i8mem :$dst, i8imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001402 "sub{b} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001403 [(store (sub (loadi8 addr:$dst), imm:$src2), addr:$dst)]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001404 def SUB16mi : Ii16<0x81, MRM5m, (ops i16mem:$dst, i16imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001405 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001406 [(store (sub (loadi16 addr:$dst), imm:$src2), addr:$dst)]>,
Evan Cheng9b6b6422005-12-13 00:14:11 +00001407 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001408 def SUB32mi : Ii32<0x81, MRM5m, (ops i32mem:$dst, i32imm:$src2),
Evan Chengd160d482005-12-12 21:54:05 +00001409 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Chengc937ffa2005-12-13 02:40:18 +00001410 [(store (sub (loadi32 addr:$dst), imm:$src2), addr:$dst)]>;
Evan Chengd160d482005-12-12 21:54:05 +00001411 def SUB16mi8 : Ii8<0x83, MRM5m, (ops i16mem:$dst, i16i8imm :$src2),
1412 "sub{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001413 [(store (sub (load addr:$dst), i16immSExt8:$src2), addr:$dst)]>,
1414 OpSize;
Evan Chengd160d482005-12-12 21:54:05 +00001415 def SUB32mi8 : Ii8<0x83, MRM5m, (ops i32mem:$dst, i32i8imm :$src2),
1416 "sub{l} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001417 [(store (sub (load addr:$dst), i32immSExt8:$src2), addr:$dst)]>;
Chris Lattner57a02302004-08-11 04:31:00 +00001418}
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001419
Chris Lattner3a173df2004-10-03 20:35:00 +00001420def SBB32rr : I<0x19, MRMDestReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001421 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001422
Chris Lattner57a02302004-08-11 04:31:00 +00001423let isTwoAddress = 0 in {
Chris Lattner3a173df2004-10-03 20:35:00 +00001424 def SBB32mr : I<0x19, MRMDestMem, (ops i32mem:$dst, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001425 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001426 def SBB8mi : Ii32<0x80, MRM3m, (ops i8mem:$dst, i8imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001427 "sbb{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001428 def SBB16mi : Ii32<0x81, MRM3m, (ops i16mem:$dst, i16imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001429 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001430 def SBB32mi : Ii32<0x81, MRM3m, (ops i32mem:$dst, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001431 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001432 def SBB16mi8 : Ii8<0x83, MRM3m, (ops i16mem:$dst, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001433 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001434 def SBB32mi8 : Ii8<0x83, MRM3m, (ops i32mem:$dst, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001435 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001436}
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001437def SBB8ri : Ii8<0x80, MRM3r, (ops R8:$dst, R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001438 "sbb{b} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001439def SBB16ri : Ii16<0x81, MRM3r, (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001440 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001441
Chris Lattner57a02302004-08-11 04:31:00 +00001442def SBB32rm : I<0x1B, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001443 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattner36b68902004-08-10 21:21:30 +00001444def SBB32ri : Ii32<0x81, MRM3r, (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001445 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Chris Lattnerd93d3b02004-10-06 04:01:02 +00001446
Chris Lattner09c750f2004-10-06 14:31:50 +00001447def SBB16ri8 : Ii8<0x83, MRM3r, (ops R16:$dst, R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001448 "sbb{w} {$src2, $dst|$dst, $src2}", []>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001449def SBB32ri8 : Ii8<0x83, MRM3r, (ops R32:$dst, R32:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001450 "sbb{l} {$src2, $dst|$dst, $src2}", []>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001451
Chris Lattner10197ff2005-01-03 01:27:59 +00001452let isCommutable = 1 in { // X = IMUL Y, Z --> X = IMUL Z, Y
Chris Lattner3a173df2004-10-03 20:35:00 +00001453def IMUL16rr : I<0xAF, MRMSrcReg, (ops R16:$dst, R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001454 "imul{w} {$src2, $dst|$dst, $src2}",
1455 [(set R16:$dst, (mul R16:$src1, R16:$src2))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001456def IMUL32rr : I<0xAF, MRMSrcReg, (ops R32:$dst, R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001457 "imul{l} {$src2, $dst|$dst, $src2}",
1458 [(set R32:$dst, (mul R32:$src1, R32:$src2))]>, TB;
Chris Lattner10197ff2005-01-03 01:27:59 +00001459}
Chris Lattner3a173df2004-10-03 20:35:00 +00001460def IMUL16rm : I<0xAF, MRMSrcMem, (ops R16:$dst, R16:$src1, i16mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001461 "imul{w} {$src2, $dst|$dst, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001462 [(set R16:$dst, (mul R16:$src1, (load addr:$src2)))]>,
1463 TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001464def IMUL32rm : I<0xAF, MRMSrcMem, (ops R32:$dst, R32:$src1, i32mem:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001465 "imul{l} {$src2, $dst|$dst, $src2}",
1466 [(set R32:$dst, (mul R32:$src1, (load addr:$src2)))]>, TB;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001467
1468} // end Two Address instructions
1469
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001470// Suprisingly enough, these are not two address instructions!
Chris Lattner3a173df2004-10-03 20:35:00 +00001471def IMUL16rri : Ii16<0x69, MRMSrcReg, // R16 = R16*I16
1472 (ops R16:$dst, R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001473 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Chengf281e022005-12-12 23:47:46 +00001474 [(set R16:$dst, (mul R16:$src1, imm:$src2))]>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001475def IMUL32rri : Ii32<0x69, MRMSrcReg, // R32 = R32*I32
1476 (ops R32:$dst, R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001477 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1478 [(set R32:$dst, (mul R32:$src1, imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001479def IMUL16rri8 : Ii8<0x6B, MRMSrcReg, // R16 = R16*I8
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001480 (ops R16:$dst, R16:$src1, i16i8imm:$src2),
1481 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001482 [(set R16:$dst, (mul R16:$src1, i16immSExt8:$src2))]>,
1483 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001484def IMUL32rri8 : Ii8<0x6B, MRMSrcReg, // R32 = R32*I8
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001485 (ops R32:$dst, R32:$src1, i32i8imm:$src2),
1486 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001487 [(set R32:$dst, (mul R32:$src1, i32immSExt8:$src2))]>;
Chris Lattnerf5d3a832004-08-11 05:31:07 +00001488
Chris Lattner3a173df2004-10-03 20:35:00 +00001489def IMUL16rmi : Ii16<0x69, MRMSrcMem, // R16 = [mem16]*I16
Evan Chengf281e022005-12-12 23:47:46 +00001490 (ops R16:$dst, i16mem:$src1, i16imm:$src2),
1491 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
1492 [(set R16:$dst, (mul (load addr:$src1), imm:$src2))]>,
1493 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001494def IMUL32rmi : Ii32<0x69, MRMSrcMem, // R32 = [mem32]*I32
1495 (ops R32:$dst, i32mem:$src1, i32imm:$src2),
Evan Chengf281e022005-12-12 23:47:46 +00001496 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
1497 [(set R32:$dst, (mul (load addr:$src1), imm:$src2))]>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001498def IMUL16rmi8 : Ii8<0x6B, MRMSrcMem, // R16 = [mem16]*I8
Evan Chengf281e022005-12-12 23:47:46 +00001499 (ops R16:$dst, i16mem:$src1, i16i8imm :$src2),
1500 "imul{w} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001501 [(set R16:$dst, (mul (load addr:$src1), i16immSExt8:$src2))]>,
1502 OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001503def IMUL32rmi8 : Ii8<0x6B, MRMSrcMem, // R32 = [mem32]*I8
Evan Chengf281e022005-12-12 23:47:46 +00001504 (ops R32:$dst, i32mem:$src1, i32i8imm: $src2),
1505 "imul{l} {$src2, $src1, $dst|$dst, $src1, $src2}",
Evan Cheng9b6b6422005-12-13 00:14:11 +00001506 [(set R32:$dst, (mul (load addr:$src1), i32immSExt8:$src2))]>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001507
1508//===----------------------------------------------------------------------===//
1509// Test instructions are just like AND, except they don't generate a result.
Chris Lattner3a173df2004-10-03 20:35:00 +00001510//
Chris Lattnercc65bee2005-01-02 02:35:46 +00001511let isCommutable = 1 in { // TEST X, Y --> TEST Y, X
Chris Lattner36b68902004-08-10 21:21:30 +00001512def TEST8rr : I<0x84, MRMDestReg, (ops R8:$src1, R8:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001513 "test{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner36b68902004-08-10 21:21:30 +00001514def TEST16rr : I<0x85, MRMDestReg, (ops R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001515 "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner36b68902004-08-10 21:21:30 +00001516def TEST32rr : I<0x85, MRMDestReg, (ops R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001517 "test{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattnercc65bee2005-01-02 02:35:46 +00001518}
Chris Lattner57a02302004-08-11 04:31:00 +00001519def TEST8mr : I<0x84, MRMDestMem, (ops i8mem :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001520 "test{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001521def TEST16mr : I<0x85, MRMDestMem, (ops i16mem:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001522 "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001523def TEST32mr : I<0x85, MRMDestMem, (ops i32mem:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001524 "test{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001525def TEST8rm : I<0x84, MRMSrcMem, (ops R8 :$src1, i8mem :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001526 "test{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner57a02302004-08-11 04:31:00 +00001527def TEST16rm : I<0x85, MRMSrcMem, (ops R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001528 "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner57a02302004-08-11 04:31:00 +00001529def TEST32rm : I<0x85, MRMSrcMem, (ops R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001530 "test{l} {$src2, $src1|$src1, $src2}", []>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001531
Chris Lattner707c6fe2004-10-04 01:38:10 +00001532def TEST8ri : Ii8 <0xF6, MRM0r, // flags = R8 & imm8
1533 (ops R8:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001534 "test{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001535def TEST16ri : Ii16<0xF7, MRM0r, // flags = R16 & imm16
1536 (ops R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001537 "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001538def TEST32ri : Ii32<0xF7, MRM0r, // flags = R32 & imm32
1539 (ops R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001540 "test{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001541def TEST8mi : Ii8 <0xF6, MRM0m, // flags = [mem8] & imm8
1542 (ops i32mem:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001543 "test{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001544def TEST16mi : Ii16<0xF7, MRM0m, // flags = [mem16] & imm16
1545 (ops i16mem:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001546 "test{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner707c6fe2004-10-04 01:38:10 +00001547def TEST32mi : Ii32<0xF7, MRM0m, // flags = [mem32] & imm32
1548 (ops i32mem:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001549 "test{l} {$src2, $src1|$src1, $src2}", []>;
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001550
1551
1552
1553// Condition code ops, incl. set if equal/not equal/...
Evan Chengf0701842005-11-29 19:38:52 +00001554def SAHF : I<0x9E, RawFrm, (ops), "sahf", []>, Imp<[AH],[]>; // flags = AH
1555def LAHF : I<0x9F, RawFrm, (ops), "lahf", []>, Imp<[],[AH]>; // AH = flags
Alkis Evlogimenos5ab29b52004-02-28 22:02:05 +00001556
Chris Lattner3a173df2004-10-03 20:35:00 +00001557def SETBr : I<0x92, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001558 (ops R8 :$dst), "setb $dst", []>, TB; // R8 = < unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00001559def SETBm : I<0x92, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001560 (ops i8mem:$dst), "setb $dst", []>, TB; // [mem8] = < unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00001561def SETAEr : I<0x93, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001562 (ops R8 :$dst), "setae $dst", []>, TB; // R8 = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00001563def SETAEm : I<0x93, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001564 (ops i8mem:$dst), "setae $dst", []>, TB; // [mem8] = >= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00001565def SETEr : I<0x94, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001566 (ops R8 :$dst), "sete $dst", []>, TB; // R8 = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00001567def SETEm : I<0x94, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001568 (ops i8mem:$dst), "sete $dst", []>, TB; // [mem8] = ==
Chris Lattner3a173df2004-10-03 20:35:00 +00001569def SETNEr : I<0x95, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001570 (ops R8 :$dst), "setne $dst", []>, TB; // R8 = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00001571def SETNEm : I<0x95, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001572 (ops i8mem:$dst), "setne $dst", []>, TB; // [mem8] = !=
Chris Lattner3a173df2004-10-03 20:35:00 +00001573def SETBEr : I<0x96, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001574 (ops R8 :$dst), "setbe $dst", []>, TB; // R8 = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00001575def SETBEm : I<0x96, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001576 (ops i8mem:$dst), "setbe $dst", []>, TB; // [mem8] = <= unsign
Chris Lattner3a173df2004-10-03 20:35:00 +00001577def SETAr : I<0x97, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001578 (ops R8 :$dst), "seta $dst", []>, TB; // R8 = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001579def SETAm : I<0x97, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001580 (ops i8mem:$dst), "seta $dst", []>, TB; // [mem8] = > signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001581def SETSr : I<0x98, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001582 (ops R8 :$dst), "sets $dst", []>, TB; // R8 = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00001583def SETSm : I<0x98, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001584 (ops i8mem:$dst), "sets $dst", []>, TB; // [mem8] = <sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00001585def SETNSr : I<0x99, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001586 (ops R8 :$dst), "setns $dst", []>, TB; // R8 = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00001587def SETNSm : I<0x99, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001588 (ops i8mem:$dst), "setns $dst", []>, TB; // [mem8] = !<sign bit>
Chris Lattner3a173df2004-10-03 20:35:00 +00001589def SETPr : I<0x9A, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001590 (ops R8 :$dst), "setp $dst", []>, TB; // R8 = parity
Chris Lattner3a173df2004-10-03 20:35:00 +00001591def SETPm : I<0x9A, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001592 (ops i8mem:$dst), "setp $dst", []>, TB; // [mem8] = parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00001593def SETNPr : I<0x9B, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001594 (ops R8 :$dst), "setnp $dst", []>, TB; // R8 = not parity
Chris Lattnercc65bee2005-01-02 02:35:46 +00001595def SETNPm : I<0x9B, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001596 (ops i8mem:$dst), "setnp $dst", []>, TB; // [mem8] = not parity
Chris Lattner3a173df2004-10-03 20:35:00 +00001597def SETLr : I<0x9C, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001598 (ops R8 :$dst), "setl $dst", []>, TB; // R8 = < signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001599def SETLm : I<0x9C, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001600 (ops i8mem:$dst), "setl $dst", []>, TB; // [mem8] = < signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001601def SETGEr : I<0x9D, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001602 (ops R8 :$dst), "setge $dst", []>, TB; // R8 = >= signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001603def SETGEm : I<0x9D, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001604 (ops i8mem:$dst), "setge $dst", []>, TB; // [mem8] = >= signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001605def SETLEr : I<0x9E, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001606 (ops R8 :$dst), "setle $dst", []>, TB; // R8 = <= signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001607def SETLEm : I<0x9E, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001608 (ops i8mem:$dst), "setle $dst", []>, TB; // [mem8] = <= signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001609def SETGr : I<0x9F, MRM0r,
Evan Chengf0701842005-11-29 19:38:52 +00001610 (ops R8 :$dst), "setg $dst", []>, TB; // R8 = < signed
Chris Lattner3a173df2004-10-03 20:35:00 +00001611def SETGm : I<0x9F, MRM0m,
Evan Chengf0701842005-11-29 19:38:52 +00001612 (ops i8mem:$dst), "setg $dst", []>, TB; // [mem8] = < signed
Chris Lattner1cca5e32003-08-03 21:54:21 +00001613
1614// Integer comparisons
Chris Lattner3a173df2004-10-03 20:35:00 +00001615def CMP8rr : I<0x38, MRMDestReg,
1616 (ops R8 :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001617 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001618def CMP16rr : I<0x39, MRMDestReg,
1619 (ops R16:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001620 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001621def CMP32rr : I<0x39, MRMDestReg,
1622 (ops R32:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001623 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001624def CMP8mr : I<0x38, MRMDestMem,
1625 (ops i8mem :$src1, R8 :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001626 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001627def CMP16mr : I<0x39, MRMDestMem,
1628 (ops i16mem:$src1, R16:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001629 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001630def CMP32mr : I<0x39, MRMDestMem,
1631 (ops i32mem:$src1, R32:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001632 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001633def CMP8rm : I<0x3A, MRMSrcMem,
1634 (ops R8 :$src1, i8mem :$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001635 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001636def CMP16rm : I<0x3B, MRMSrcMem,
1637 (ops R16:$src1, i16mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001638 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001639def CMP32rm : I<0x3B, MRMSrcMem,
1640 (ops R32:$src1, i32mem:$src2),
Evan Chengf0701842005-11-29 19:38:52 +00001641 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001642def CMP8ri : Ii8<0x80, MRM7r,
1643 (ops R16:$src1, i8imm:$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001644 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001645def CMP16ri : Ii16<0x81, MRM7r,
1646 (ops R16:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001647 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001648def CMP32ri : Ii32<0x81, MRM7r,
1649 (ops R32:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001650 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001651def CMP8mi : Ii8 <0x80, MRM7m,
1652 (ops i8mem :$src1, i8imm :$src2),
Chris Lattnerf124d5e2005-11-18 01:04:42 +00001653 "cmp{b} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00001654def CMP16mi : Ii16<0x81, MRM7m,
1655 (ops i16mem:$src1, i16imm:$src2),
Chris Lattner78432fe2005-11-17 02:01:55 +00001656 "cmp{w} {$src2, $src1|$src1, $src2}", []>, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001657def CMP32mi : Ii32<0x81, MRM7m,
1658 (ops i32mem:$src1, i32imm:$src2),
Chris Lattner7a125372005-11-16 22:59:19 +00001659 "cmp{l} {$src2, $src1|$src1, $src2}", []>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00001660
1661// Sign/Zero extenders
Chris Lattner3a173df2004-10-03 20:35:00 +00001662def MOVSX16rr8 : I<0xBE, MRMSrcReg, (ops R16:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001663 "movs{bw|x} {$src, $dst|$dst, $src}",
1664 [(set R16:$dst, (sext R8:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001665def MOVSX16rm8 : I<0xBE, MRMSrcMem, (ops R16:$dst, i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001666 "movs{bw|x} {$src, $dst|$dst, $src}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001667def MOVSX32rr8 : I<0xBE, MRMSrcReg, (ops R32:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001668 "movs{bl|x} {$src, $dst|$dst, $src}",
1669 [(set R32:$dst, (sext R8:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001670def MOVSX32rm8 : I<0xBE, MRMSrcMem, (ops R32:$dst, i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001671 "movs{bl|x} {$src, $dst|$dst, $src}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001672def MOVSX32rr16: I<0xBF, MRMSrcReg, (ops R32:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001673 "movs{wl|x} {$src, $dst|$dst, $src}",
1674 [(set R32:$dst, (sext R16:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001675def MOVSX32rm16: I<0xBF, MRMSrcMem, (ops R32:$dst, i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001676 "movs{wl|x} {$src, $dst|$dst, $src}", []>, TB;
Alkis Evlogimenosa7be9822004-02-17 09:14:23 +00001677
Chris Lattner3a173df2004-10-03 20:35:00 +00001678def MOVZX16rr8 : I<0xB6, MRMSrcReg, (ops R16:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001679 "movz{bw|x} {$src, $dst|$dst, $src}",
1680 [(set R16:$dst, (zext R8:$src))]>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001681def MOVZX16rm8 : I<0xB6, MRMSrcMem, (ops R16:$dst, i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001682 "movz{bw|x} {$src, $dst|$dst, $src}", []>, TB, OpSize;
Chris Lattner3a173df2004-10-03 20:35:00 +00001683def MOVZX32rr8 : I<0xB6, MRMSrcReg, (ops R32:$dst, R8 :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001684 "movz{bl|x} {$src, $dst|$dst, $src}",
1685 [(set R32:$dst, (zext R8:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001686def MOVZX32rm8 : I<0xB6, MRMSrcMem, (ops R32:$dst, i8mem :$src),
Evan Chengf0701842005-11-29 19:38:52 +00001687 "movz{bl|x} {$src, $dst|$dst, $src}", []>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001688def MOVZX32rr16: I<0xB7, MRMSrcReg, (ops R32:$dst, R16:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001689 "movz{wl|x} {$src, $dst|$dst, $src}",
1690 [(set R32:$dst, (zext R16:$src))]>, TB;
Chris Lattner3a173df2004-10-03 20:35:00 +00001691def MOVZX32rm16: I<0xB7, MRMSrcMem, (ops R32:$dst, i16mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001692 "movz{wl|x} {$src, $dst|$dst, $src}", []>, TB;
Chris Lattner1cca5e32003-08-03 21:54:21 +00001693
Nate Begemanf1702ac2005-06-27 21:20:31 +00001694//===----------------------------------------------------------------------===//
1695// XMM Floating point support (requires SSE2)
1696//===----------------------------------------------------------------------===//
1697
Nate Begeman14e2cf62005-10-14 22:06:00 +00001698def MOVSSrr : I<0x10, MRMSrcReg, (ops V4F4:$dst, V4F4:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001699 "movss {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001700def MOVSSrm : I<0x10, MRMSrcMem, (ops V4F4:$dst, f32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001701 "movss {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001702def MOVSSmr : I<0x11, MRMDestMem, (ops f32mem:$dst, V4F4:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001703 "movss {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001704def MOVSDrr : I<0x10, MRMSrcReg, (ops V2F8:$dst, V2F8:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001705 "movsd {$src, $dst|$dst, $src}", []>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001706def MOVSDrm : I<0x10, MRMSrcMem, (ops V2F8:$dst, f64mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001707 "movsd {$src, $dst|$dst, $src}", []>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001708def MOVSDmr : I<0x11, MRMDestMem, (ops f64mem:$dst, V2F8:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001709 "movsd {$src, $dst|$dst, $src}", []>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001710
Nate Begeman14e2cf62005-10-14 22:06:00 +00001711def CVTTSD2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, V2F8:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001712 "cvttsd2si {$src, $dst|$dst, $src}",
1713 [(set R32:$dst, (fp_to_sint V2F8:$src))]>, XD;
Nate Begeman16b04f32005-07-15 00:38:55 +00001714def CVTTSD2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f64mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001715 "cvttsd2si {$src, $dst|$dst, $src}", []>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001716def CVTTSS2SIrr: I<0x2C, MRMSrcReg, (ops R32:$dst, V4F4:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001717 "cvttss2si {$src, $dst|$dst, $src}",
1718 [(set R32:$dst, (fp_to_sint V4F4:$src))]>, XS;
Nate Begeman16b04f32005-07-15 00:38:55 +00001719def CVTTSS2SIrm: I<0x2C, MRMSrcMem, (ops R32:$dst, f32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001720 "cvttss2si {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001721def CVTSD2SSrr: I<0x5A, MRMSrcReg, (ops V4F4:$dst, V2F8:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001722 "cvtsd2ss {$src, $dst|$dst, $src}",
1723 [(set V4F4:$dst, (fround V2F8:$src))]>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001724def CVTSD2SSrm: I<0x5A, MRMSrcMem, (ops V4F4:$dst, f64mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001725 "cvtsd2ss {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001726def CVTSS2SDrr: I<0x5A, MRMSrcReg, (ops V2F8:$dst, V4F4:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001727 "cvtss2sd {$src, $dst|$dst, $src}",
1728 [(set V2F8:$dst, (fextend V4F4:$src))]>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001729def CVTSS2SDrm: I<0x5A, MRMSrcMem, (ops V2F8:$dst, f32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001730 "cvtss2sd {$src, $dst|$dst, $src}", []>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001731def CVTSI2SSrr: I<0x2A, MRMSrcReg, (ops V4F4:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001732 "cvtsi2ss {$src, $dst|$dst, $src}",
1733 [(set V4F4:$dst, (sint_to_fp R32:$src))]>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001734def CVTSI2SSrm: I<0x2A, MRMSrcMem, (ops V4F4:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001735 "cvtsi2ss {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001736def CVTSI2SDrr: I<0x2A, MRMSrcReg, (ops V2F8:$dst, R32:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001737 "cvtsi2sd {$src, $dst|$dst, $src}",
1738 [(set V2F8:$dst, (sint_to_fp R32:$src))]>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001739def CVTSI2SDrm: I<0x2A, MRMSrcMem, (ops V2F8:$dst, i32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001740 "cvtsi2sd {$src, $dst|$dst, $src}", []>, XD;
Nate Begemanf63be7d2005-07-06 18:59:04 +00001741
Nate Begeman14e2cf62005-10-14 22:06:00 +00001742def SQRTSSrm : I<0x51, MRMSrcMem, (ops V4F4:$dst, f32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001743 "sqrtss {$src, $dst|$dst, $src}", []>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001744def SQRTSSrr : I<0x51, MRMSrcReg, (ops V4F4:$dst, V4F4:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001745 "sqrtss {$src, $dst|$dst, $src}",
1746 [(set V4F4:$dst, (fsqrt V4F4:$src))]>, XS;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001747def SQRTSDrm : I<0x51, MRMSrcMem, (ops V2F8:$dst, f64mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001748 "sqrtsd {$src, $dst|$dst, $src}", []>, XD;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001749def SQRTSDrr : I<0x51, MRMSrcReg, (ops V2F8:$dst, V2F8:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001750 "sqrtsd {$src, $dst|$dst, $src}",
1751 [(set V2F8:$dst, (fsqrt V2F8:$src))]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001752
Nate Begeman14e2cf62005-10-14 22:06:00 +00001753def UCOMISDrr: I<0x2E, MRMSrcReg, (ops V2F8:$dst, V2F8:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001754 "ucomisd {$src, $dst|$dst, $src}", []>, TB, OpSize;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001755def UCOMISDrm: I<0x2E, MRMSrcMem, (ops V2F8:$dst, f64mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001756 "ucomisd {$src, $dst|$dst, $src}", []>, TB, OpSize;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001757def UCOMISSrr: I<0x2E, MRMSrcReg, (ops V4F4:$dst, V4F4:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001758 "ucomiss {$src, $dst|$dst, $src}", []>, TB;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001759def UCOMISSrm: I<0x2E, MRMSrcMem, (ops V4F4:$dst, f32mem:$src),
Evan Chengf0701842005-11-29 19:38:52 +00001760 "ucomiss {$src, $dst|$dst, $src}", []>, TB;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001761
Evan Chengf0701842005-11-29 19:38:52 +00001762// Pseudo-instructions that map fld0 to xorps/xorpd for sse.
Nate Begeman1c73c7b2005-08-03 23:26:28 +00001763// FIXME: remove when we can teach regalloc that xor reg, reg is ok.
Nate Begeman14e2cf62005-10-14 22:06:00 +00001764def FLD0SS : I<0x57, MRMSrcReg, (ops V4F4:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001765 "xorps $dst, $dst", []>, TB;
Nate Begeman14e2cf62005-10-14 22:06:00 +00001766def FLD0SD : I<0x57, MRMSrcReg, (ops V2F8:$dst),
Evan Chengf0701842005-11-29 19:38:52 +00001767 "xorpd $dst, $dst", []>, TB, OpSize;
Nate Begeman1c73c7b2005-08-03 23:26:28 +00001768
Nate Begemanf1702ac2005-06-27 21:20:31 +00001769let isTwoAddress = 1 in {
1770let isCommutable = 1 in {
Evan Chengf0701842005-11-29 19:38:52 +00001771def ADDSSrr : I<0x58, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1772 "addss {$src2, $dst|$dst, $src2}",
1773 [(set V4F4:$dst, (fadd V4F4:$src1, V4F4:$src2))]>, XS;
1774def ADDSDrr : I<0x58, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1775 "addsd {$src2, $dst|$dst, $src2}",
1776 [(set V2F8:$dst, (fadd V2F8:$src1, V2F8:$src2))]>, XD;
1777def ANDPSrr : I<0x54, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1778 "andps {$src2, $dst|$dst, $src2}", []>, TB;
1779def ANDPDrr : I<0x54, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1780 "andpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
1781def MULSSrr : I<0x59, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1782 "mulss {$src2, $dst|$dst, $src2}",
1783 [(set V4F4:$dst, (fmul V4F4:$src1, V4F4:$src2))]>, XS;
1784def MULSDrr : I<0x59, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1785 "mulsd {$src2, $dst|$dst, $src2}",
1786 [(set V2F8:$dst, (fmul V2F8:$src1, V2F8:$src2))]>, XD;
1787def ORPSrr : I<0x56, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1788 "orps {$src2, $dst|$dst, $src2}", []>, TB;
1789def ORPDrr : I<0x56, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1790 "orpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
1791def XORPSrr : I<0x57, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1792 "xorps {$src2, $dst|$dst, $src2}", []>, TB;
1793def XORPDrr : I<0x57, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1794 "xorpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001795}
Evan Chengf0701842005-11-29 19:38:52 +00001796def ANDNPSrr : I<0x55, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1797 "andnps {$src2, $dst|$dst, $src2}", []>, TB;
1798def ANDNPDrr : I<0x55, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1799 "andnpd {$src2, $dst|$dst, $src2}", []>, TB, OpSize;
1800def ADDSSrm : I<0x58, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
1801 "addss {$src2, $dst|$dst, $src2}", []>, XS;
1802def ADDSDrm : I<0x58, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
1803 "addsd {$src2, $dst|$dst, $src2}", []>, XD;
1804def MULSSrm : I<0x59, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
1805 "mulss {$src2, $dst|$dst, $src2}", []>, XS;
1806def MULSDrm : I<0x59, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
1807 "mulsd {$src2, $dst|$dst, $src2}", []>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001808
Evan Chengf0701842005-11-29 19:38:52 +00001809def DIVSSrm : I<0x5E, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
1810 "divss {$src2, $dst|$dst, $src2}", []>, XS;
1811def DIVSSrr : I<0x5E, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1812 "divss {$src2, $dst|$dst, $src2}",
1813 [(set V4F4:$dst, (fdiv V4F4:$src1, V4F4:$src2))]>, XS;
1814def DIVSDrm : I<0x5E, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
1815 "divsd {$src2, $dst|$dst, $src2}", []>, XD;
1816def DIVSDrr : I<0x5E, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1817 "divsd {$src2, $dst|$dst, $src2}",
1818 [(set V2F8:$dst, (fdiv V2F8:$src1, V2F8:$src2))]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001819
Evan Chengf0701842005-11-29 19:38:52 +00001820def SUBSSrm : I<0x5C, MRMSrcMem, (ops V4F4:$dst, V4F4:$src1, f32mem:$src2),
1821 "subss {$src2, $dst|$dst, $src2}", []>, XS;
1822def SUBSSrr : I<0x5C, MRMSrcReg, (ops V4F4:$dst, V4F4:$src1, V4F4:$src2),
1823 "subss {$src2, $dst|$dst, $src2}",
1824 [(set V4F4:$dst, (fsub V4F4:$src1, V4F4:$src2))]>, XS;
1825def SUBSDrm : I<0x5C, MRMSrcMem, (ops V2F8:$dst, V2F8:$src1, f64mem:$src2),
1826 "subsd {$src2, $dst|$dst, $src2}", []>, XD;
1827def SUBSDrr : I<0x5C, MRMSrcReg, (ops V2F8:$dst, V2F8:$src1, V2F8:$src2),
1828 "subsd {$src2, $dst|$dst, $src2}",
1829 [(set V2F8:$dst, (fsub V2F8:$src1, V2F8:$src2))]>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001830
1831def CMPSSrr : I<0xC2, MRMSrcReg,
Nate Begeman14e2cf62005-10-14 22:06:00 +00001832 (ops V4F4:$dst, V4F4:$src1, V4F4:$src, SSECC:$cc),
Evan Chengf0701842005-11-29 19:38:52 +00001833 "cmp${cc}ss {$src, $dst|$dst, $src}", []>, XS;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001834def CMPSSrm : I<0xC2, MRMSrcMem,
Nate Begeman14e2cf62005-10-14 22:06:00 +00001835 (ops V4F4:$dst, V4F4:$src1, f32mem:$src, SSECC:$cc),
Evan Chengf0701842005-11-29 19:38:52 +00001836 "cmp${cc}ss {$src, $dst|$dst, $src}", []>, XS;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001837def CMPSDrr : I<0xC2, MRMSrcReg,
Nate Begeman14e2cf62005-10-14 22:06:00 +00001838 (ops V2F8:$dst, V2F8:$src1, V2F8:$src, SSECC:$cc),
Evan Chengf0701842005-11-29 19:38:52 +00001839 "cmp${cc}sd {$src, $dst|$dst, $src}", []>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001840def CMPSDrm : I<0xC2, MRMSrcMem,
Nate Begeman14e2cf62005-10-14 22:06:00 +00001841 (ops V2F8:$dst, V2F8:$src1, f64mem:$src, SSECC:$cc),
Evan Chengf0701842005-11-29 19:38:52 +00001842 "cmp${cc}sd {$src, $dst|$dst, $src}", []>, XD;
Nate Begemanf1702ac2005-06-27 21:20:31 +00001843}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001844
1845//===----------------------------------------------------------------------===//
Chris Lattner441b2232005-11-20 22:13:18 +00001846// Miscellaneous Instructions
1847//===----------------------------------------------------------------------===//
1848
Evan Chengf0701842005-11-29 19:38:52 +00001849def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", []>, TB, Imp<[],[EAX,EDX]>;
Chris Lattner441b2232005-11-20 22:13:18 +00001850
1851
1852//===----------------------------------------------------------------------===//
Nate Begemanf1702ac2005-06-27 21:20:31 +00001853// Stack-based Floating point support
Chris Lattner1cca5e32003-08-03 21:54:21 +00001854//===----------------------------------------------------------------------===//
1855
1856// FIXME: These need to indicate mod/ref sets for FP regs... & FP 'TOP'
1857
Chris Lattner9795b3a2004-08-11 06:50:10 +00001858// Floating point instruction template
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001859class FPI<bits<8> o, Format F, FPFormat fp, dag ops, string asm>
Chris Lattnerc96bb812004-08-11 07:12:04 +00001860 : X86Inst<o, F, NoImm, ops, asm> {
Chris Lattner9795b3a2004-08-11 06:50:10 +00001861 let FPForm = fp; let FPFormBits = FPForm.Value;
1862}
Chris Lattner1cca5e32003-08-03 21:54:21 +00001863
Chris Lattner9f8fd6d2004-02-02 19:31:38 +00001864// Pseudo instructions for floating point. We use these pseudo instructions
1865// because they can be expanded by the fp spackifier into one of many different
1866// forms of instructions for doing these operations. Until the stackifier runs,
1867// we prefer to be abstract.
Chris Lattner3a173df2004-10-03 20:35:00 +00001868def FpMOV : FPI<0, Pseudo, SpecialFP,
Chris Lattner43ef1312005-09-14 21:10:24 +00001869 (ops RFP:$dst, RFP:$src), "">; // f1 = fmov f2
Chris Lattner3a173df2004-10-03 20:35:00 +00001870def FpADD : FPI<0, Pseudo, TwoArgFP ,
Chris Lattner43ef1312005-09-14 21:10:24 +00001871 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fadd f2, f3
Chris Lattner3a173df2004-10-03 20:35:00 +00001872def FpSUB : FPI<0, Pseudo, TwoArgFP ,
Chris Lattner43ef1312005-09-14 21:10:24 +00001873 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fsub f2, f3
Chris Lattner3a173df2004-10-03 20:35:00 +00001874def FpMUL : FPI<0, Pseudo, TwoArgFP ,
Chris Lattner43ef1312005-09-14 21:10:24 +00001875 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fmul f2, f3
Chris Lattner3a173df2004-10-03 20:35:00 +00001876def FpDIV : FPI<0, Pseudo, TwoArgFP ,
Chris Lattner43ef1312005-09-14 21:10:24 +00001877 (ops RFP:$dst, RFP:$src1, RFP:$src2), "">; // f1 = fdiv f2, f3
Chris Lattner1cca5e32003-08-03 21:54:21 +00001878
Chris Lattner43ef1312005-09-14 21:10:24 +00001879def FpGETRESULT : FPI<0, Pseudo, SpecialFP, (ops RFP:$dst), "">,
Alkis Evlogimenos93c1ab22004-09-08 18:29:31 +00001880 Imp<[ST0], []>; // FPR = ST(0)
Alkis Evlogimenos978f6292004-09-08 16:54:54 +00001881
Chris Lattner43ef1312005-09-14 21:10:24 +00001882def FpSETRESULT : FPI<0, Pseudo, SpecialFP, (ops RFP:$src), "">,
Alkis Evlogimenos93c1ab22004-09-08 18:29:31 +00001883 Imp<[], [ST0]>; // ST(0) = FPR
Chris Lattner1cca5e32003-08-03 21:54:21 +00001884
Chris Lattner3a173df2004-10-03 20:35:00 +00001885// FADD reg, mem: Before stackification, these are represented by:
1886// R1 = FADD* R2, [mem]
1887def FADD32m : FPI<0xD8, MRM0m, OneArgFPRW, // ST(0) = ST(0) + [mem32real]
Chris Lattnerb822aba2005-08-19 00:38:22 +00001888 (ops f32mem:$src, variable_ops),
1889 "fadd{s} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001890def FADD64m : FPI<0xDC, MRM0m, OneArgFPRW, // ST(0) = ST(0) + [mem64real]
Chris Lattnerb822aba2005-08-19 00:38:22 +00001891 (ops f64mem:$src, variable_ops),
1892 "fadd{l} $src">;
Chris Lattner60c715c2004-10-04 00:43:31 +00001893//def FIADD16m : FPI<0xDE, MRM0m, OneArgFPRW>; // ST(0) = ST(0) + [mem16int]
1894//def FIADD32m : FPI<0xDA, MRM0m, OneArgFPRW>; // ST(0) = ST(0) + [mem32int]
Chris Lattner490e86f2004-04-11 20:24:15 +00001895
Chris Lattner3a173df2004-10-03 20:35:00 +00001896// FMUL reg, mem: Before stackification, these are represented by:
1897// R1 = FMUL* R2, [mem]
1898def FMUL32m : FPI<0xD8, MRM1m, OneArgFPRW, // ST(0) = ST(0) * [mem32real]
Chris Lattnerb822aba2005-08-19 00:38:22 +00001899 (ops f32mem:$src, variable_ops),
1900 "fmul{s} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001901def FMUL64m : FPI<0xDC, MRM1m, OneArgFPRW, // ST(0) = ST(0) * [mem64real]
Chris Lattnerb822aba2005-08-19 00:38:22 +00001902 (ops f64mem:$src, variable_ops),
1903 "fmul{l} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001904// ST(0) = ST(0) * [mem16int]
1905//def FIMUL16m : FPI16m<"fimul", 0xDE, MRM1m, OneArgFPRW>;
1906// ST(0) = ST(0) * [mem32int]
1907//def FIMUL32m : FPI32m<"fimul", 0xDA, MRM1m, OneArgFPRW>;
Chris Lattner490e86f2004-04-11 20:24:15 +00001908
Chris Lattner3a173df2004-10-03 20:35:00 +00001909// FSUB reg, mem: Before stackification, these are represented by:
1910// R1 = FSUB* R2, [mem]
1911def FSUB32m : FPI<0xD8, MRM4m, OneArgFPRW, // ST(0) = ST(0) - [mem32real]
Chris Lattner9d9dc812005-08-19 00:41:29 +00001912 (ops f32mem:$src, variable_ops),
1913 "fsub{s} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001914def FSUB64m : FPI<0xDC, MRM4m, OneArgFPRW, // ST(0) = ST(0) - [mem64real]
Chris Lattner9d9dc812005-08-19 00:41:29 +00001915 (ops f64mem:$src, variable_ops),
1916 "fsub{l} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001917// ST(0) = ST(0) - [mem16int]
1918//def FISUB16m : FPI16m<"fisub", 0xDE, MRM4m, OneArgFPRW>;
1919// ST(0) = ST(0) - [mem32int]
1920//def FISUB32m : FPI32m<"fisub", 0xDA, MRM4m, OneArgFPRW>;
Chris Lattner490e86f2004-04-11 20:24:15 +00001921
Chris Lattner3a173df2004-10-03 20:35:00 +00001922// FSUBR reg, mem: Before stackification, these are represented by:
1923// R1 = FSUBR* R2, [mem]
Chris Lattner490e86f2004-04-11 20:24:15 +00001924
Chris Lattner3a173df2004-10-03 20:35:00 +00001925// Note that the order of operands does not reflect the operation being
1926// performed.
1927def FSUBR32m : FPI<0xD8, MRM5m, OneArgFPRW, // ST(0) = [mem32real] - ST(0)
Chris Lattnerb822aba2005-08-19 00:38:22 +00001928 (ops f32mem:$src, variable_ops),
1929 "fsubr{s} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001930def FSUBR64m : FPI<0xDC, MRM5m, OneArgFPRW, // ST(0) = [mem64real] - ST(0)
Chris Lattnerb822aba2005-08-19 00:38:22 +00001931 (ops f64mem:$src, variable_ops),
1932 "fsubr{l} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001933// ST(0) = [mem16int] - ST(0)
1934//def FISUBR16m : FPI16m<"fisubr", 0xDE, MRM5m, OneArgFPRW>;
1935// ST(0) = [mem32int] - ST(0)
1936//def FISUBR32m : FPI32m<"fisubr", 0xDA, MRM5m, OneArgFPRW>;
Chris Lattner490e86f2004-04-11 20:24:15 +00001937
Chris Lattner3a173df2004-10-03 20:35:00 +00001938// FDIV reg, mem: Before stackification, these are represented by:
1939// R1 = FDIV* R2, [mem]
1940def FDIV32m : FPI<0xD8, MRM6m, OneArgFPRW, // ST(0) = ST(0) / [mem32real]
Chris Lattnerb822aba2005-08-19 00:38:22 +00001941 (ops f32mem:$src, variable_ops),
1942 "fdiv{s} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001943def FDIV64m : FPI<0xDC, MRM6m, OneArgFPRW, // ST(0) = ST(0) / [mem64real]
Chris Lattnerb822aba2005-08-19 00:38:22 +00001944 (ops f64mem:$src, variable_ops),
1945 "fdiv{l} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001946// ST(0) = ST(0) / [mem16int]
1947//def FIDIV16m : FPI16m<"fidiv", 0xDE, MRM6m, OneArgFPRW>;
1948// ST(0) = ST(0) / [mem32int]
1949//def FIDIV32m : FPI32m<"fidiv", 0xDA, MRM6m, OneArgFPRW>;
1950
1951// FDIVR reg, mem: Before stackification, these are represented by:
1952// R1 = FDIVR* R2, [mem]
1953// Note that the order of operands does not reflect the operation being
1954// performed.
1955def FDIVR32m : FPI<0xD8, MRM7m, OneArgFPRW, // ST(0) = [mem32real] / ST(0)
Chris Lattner9d9dc812005-08-19 00:41:29 +00001956 (ops f32mem:$src, variable_ops),
1957 "fdivr{s} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001958def FDIVR64m : FPI<0xDC, MRM7m, OneArgFPRW, // ST(0) = [mem64real] / ST(0)
Chris Lattner9d9dc812005-08-19 00:41:29 +00001959 (ops f64mem:$src, variable_ops),
1960 "fdivr{l} $src">;
Chris Lattner3a173df2004-10-03 20:35:00 +00001961// ST(0) = [mem16int] / ST(0)
1962//def FIDIVR16m : FPI16m<"fidivr", 0xDE, MRM7m, OneArgFPRW>;
1963// ST(0) = [mem32int] / ST(0)
1964//def FIDIVR32m : FPI32m<"fidivr", 0xDA, MRM7m, OneArgFPRW>;
Chris Lattner490e86f2004-04-11 20:24:15 +00001965
Chris Lattner1c54a852004-03-31 22:02:13 +00001966
1967// Floating point cmovs...
Chris Lattner0e967d42004-08-01 08:13:11 +00001968let isTwoAddress = 1, Uses = [ST0], Defs = [ST0] in {
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001969 def FCMOVB : FPI<0xC0, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001970 (ops RST:$op, variable_ops),
1971 "fcmovb {$op, %ST(0)|%ST(0), $op}">, DA;
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001972 def FCMOVBE : FPI<0xD0, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001973 (ops RST:$op, variable_ops),
1974 "fcmovbe {$op, %ST(0)|%ST(0), $op}">, DA;
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001975 def FCMOVE : FPI<0xC8, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001976 (ops RST:$op, variable_ops),
1977 "fcmove {$op, %ST(0)|%ST(0), $op}">, DA;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001978 def FCMOVP : FPI<0xD8, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001979 (ops RST:$op, variable_ops),
1980 "fcmovu {$op, %ST(0)|%ST(0), $op}">, DA;
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001981 def FCMOVAE : FPI<0xC0, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001982 (ops RST:$op, variable_ops),
1983 "fcmovae {$op, %ST(0)|%ST(0), $op}">, DB;
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001984 def FCMOVA : FPI<0xD0, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001985 (ops RST:$op, variable_ops),
1986 "fcmova {$op, %ST(0)|%ST(0), $op}">, DB;
Chris Lattner0f38e6c2004-08-11 05:54:16 +00001987 def FCMOVNE : FPI<0xC8, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001988 (ops RST:$op, variable_ops),
1989 "fcmovne {$op, %ST(0)|%ST(0), $op}">, DB;
Chris Lattner57fbfb52005-01-10 22:09:33 +00001990 def FCMOVNP : FPI<0xD8, AddRegFrm, CondMovFP,
Chris Lattnerb822aba2005-08-19 00:38:22 +00001991 (ops RST:$op, variable_ops),
1992 "fcmovnu {$op, %ST(0)|%ST(0), $op}">, DB;
Chris Lattner1c54a852004-03-31 22:02:13 +00001993}
1994
Chris Lattner1cca5e32003-08-03 21:54:21 +00001995// Floating point loads & stores...
Chris Lattnerb822aba2005-08-19 00:38:22 +00001996// FIXME: these are all marked variable_ops because they have an implicit
1997// destination. Instructions like FILD* that are generated by the instruction
1998// selector (not the fp stackifier) need more accurate operand accounting.
1999def FLDrr : FPI<0xC0, AddRegFrm, NotFP,
2000 (ops RST:$src, variable_ops),
2001 "fld $src">, D9;
2002def FLD32m : FPI<0xD9, MRM0m, ZeroArgFP,
2003 (ops f32mem:$src, variable_ops),
2004 "fld{s} $src">;
2005def FLD64m : FPI<0xDD, MRM0m, ZeroArgFP,
2006 (ops f64mem:$src, variable_ops),
2007 "fld{l} $src">;
2008def FLD80m : FPI<0xDB, MRM5m, ZeroArgFP,
2009 (ops f80mem:$src, variable_ops),
2010 "fld{t} $src">;
2011def FILD16m : FPI<0xDF, MRM0m, ZeroArgFP,
2012 (ops i16mem:$src, variable_ops),
2013 "fild{s} $src">;
2014def FILD32m : FPI<0xDB, MRM0m, ZeroArgFP,
2015 (ops i32mem:$src, variable_ops),
2016 "fild{l} $src">;
2017def FILD64m : FPI<0xDF, MRM5m, ZeroArgFP,
2018 (ops i64mem:$src, variable_ops),
2019 "fild{ll} $src">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002020
Chris Lattnerb822aba2005-08-19 00:38:22 +00002021def FSTrr : FPI<0xD0, AddRegFrm, NotFP,
2022 (ops RST:$op, variable_ops),
2023 "fst $op">, DD;
2024def FSTPrr : FPI<0xD8, AddRegFrm, NotFP,
2025 (ops RST:$op, variable_ops),
2026 "fstp $op">, DD;
2027def FST32m : FPI<0xD9, MRM2m, OneArgFP,
2028 (ops f32mem:$op, variable_ops),
2029 "fst{s} $op">;
2030def FST64m : FPI<0xDD, MRM2m, OneArgFP,
2031 (ops f64mem:$op, variable_ops),
2032 "fst{l} $op">;
2033def FSTP32m : FPI<0xD9, MRM3m, OneArgFP,
2034 (ops f32mem:$op, variable_ops),
2035 "fstp{s} $op">;
2036def FSTP64m : FPI<0xDD, MRM3m, OneArgFP,
2037 (ops f64mem:$op, variable_ops),
2038 "fstp{l} $op">;
2039def FSTP80m : FPI<0xDB, MRM7m, OneArgFP,
2040 (ops f80mem:$op, variable_ops),
2041 "fstp{t} $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002042
Chris Lattnerb822aba2005-08-19 00:38:22 +00002043def FIST16m : FPI<0xDF, MRM2m , OneArgFP,
2044 (ops i16mem:$op, variable_ops),
2045 "fist{s} $op">;
2046def FIST32m : FPI<0xDB, MRM2m , OneArgFP,
2047 (ops i32mem:$op, variable_ops),
2048 "fist{l} $op">;
2049def FISTP16m : FPI<0xDF, MRM3m , NotFP ,
2050 (ops i16mem:$op, variable_ops),
2051 "fistp{s} $op">;
2052def FISTP32m : FPI<0xDB, MRM3m , NotFP ,
2053 (ops i32mem:$op, variable_ops),
2054 "fistp{l} $op">;
2055def FISTP64m : FPI<0xDF, MRM7m , OneArgFP,
2056 (ops i64mem:$op, variable_ops),
2057 "fistp{ll} $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002058
Chris Lattner3a173df2004-10-03 20:35:00 +00002059def FXCH : FPI<0xC8, AddRegFrm, NotFP,
2060 (ops RST:$op), "fxch $op">, D9; // fxch ST(i), ST(0)
Chris Lattner1cca5e32003-08-03 21:54:21 +00002061
2062// Floating point constant loads...
Chris Lattnerb822aba2005-08-19 00:38:22 +00002063def FLD0 : FPI<0xEE, RawFrm, ZeroArgFP, (ops variable_ops), "fldz">, D9;
2064def FLD1 : FPI<0xE8, RawFrm, ZeroArgFP, (ops variable_ops), "fld1">, D9;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002065
Chris Lattner9f8fd6d2004-02-02 19:31:38 +00002066
Chris Lattner3b904eb2004-02-03 07:27:50 +00002067// Unary operations...
Chris Lattnerb822aba2005-08-19 00:38:22 +00002068def FCHS : FPI<0xE0, RawFrm, OneArgFPRW, // f1 = fchs f2
2069 (ops variable_ops),
2070 "fchs">, D9;
2071def FABS : FPI<0xE1, RawFrm, OneArgFPRW, // f1 = fabs f2
2072 (ops variable_ops),
2073 "fabs">, D9;
2074def FSQRT : FPI<0xFA, RawFrm, OneArgFPRW, // fsqrt ST(0)
2075 (ops variable_ops),
2076 "fsqrt">, D9;
2077def FSIN : FPI<0xFE, RawFrm, OneArgFPRW, // fsin ST(0)
2078 (ops variable_ops),
2079 "fsin">, D9;
2080def FCOS : FPI<0xFF, RawFrm, OneArgFPRW, // fcos ST(0)
2081 (ops variable_ops),
2082 "fcos">, D9;
2083def FTST : FPI<0xE4, RawFrm, OneArgFP , // ftst ST(0)
2084 (ops variable_ops),
2085 "ftst">, D9;
Chris Lattner3b904eb2004-02-03 07:27:50 +00002086
Chris Lattner1cca5e32003-08-03 21:54:21 +00002087// Binary arithmetic operations...
Chris Lattner3a173df2004-10-03 20:35:00 +00002088class FPST0rInst<bits<8> o, dag ops, string asm>
Evan Chengf0701842005-11-29 19:38:52 +00002089 : I<o, AddRegFrm, ops, asm, []>, D8 {
Chris Lattner1cca5e32003-08-03 21:54:21 +00002090 list<Register> Uses = [ST0];
2091 list<Register> Defs = [ST0];
2092}
Chris Lattner3a173df2004-10-03 20:35:00 +00002093class FPrST0Inst<bits<8> o, dag ops, string asm>
Evan Chengf0701842005-11-29 19:38:52 +00002094 : I<o, AddRegFrm, ops, asm, []>, DC {
Chris Lattner1cca5e32003-08-03 21:54:21 +00002095 list<Register> Uses = [ST0];
2096}
Chris Lattner3a173df2004-10-03 20:35:00 +00002097class FPrST0PInst<bits<8> o, dag ops, string asm>
Evan Chengf0701842005-11-29 19:38:52 +00002098 : I<o, AddRegFrm, ops, asm, []>, DE {
Chris Lattner1cca5e32003-08-03 21:54:21 +00002099 list<Register> Uses = [ST0];
2100}
2101
Chris Lattner3a173df2004-10-03 20:35:00 +00002102def FADDST0r : FPST0rInst <0xC0, (ops RST:$op),
2103 "fadd $op">;
2104def FADDrST0 : FPrST0Inst <0xC0, (ops RST:$op),
2105 "fadd {%ST(0), $op|$op, %ST(0)}">;
2106def FADDPrST0 : FPrST0PInst<0xC0, (ops RST:$op),
2107 "faddp $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002108
Chris Lattner10f873b2004-10-04 07:08:46 +00002109// NOTE: GAS and apparently all other AT&T style assemblers have a broken notion
2110// of some of the 'reverse' forms of the fsub and fdiv instructions. As such,
Chris Lattnerda895d62005-02-27 06:18:25 +00002111// we have to put some 'r's in and take them out of weird places.
Chris Lattner3a173df2004-10-03 20:35:00 +00002112def FSUBRST0r : FPST0rInst <0xE8, (ops RST:$op),
2113 "fsubr $op">;
2114def FSUBrST0 : FPrST0Inst <0xE8, (ops RST:$op),
Chris Lattner10f873b2004-10-04 07:08:46 +00002115 "fsub{r} {%ST(0), $op|$op, %ST(0)}">;
Chris Lattner3a173df2004-10-03 20:35:00 +00002116def FSUBPrST0 : FPrST0PInst<0xE8, (ops RST:$op),
Chris Lattner10f873b2004-10-04 07:08:46 +00002117 "fsub{r}p $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002118
Chris Lattner3a173df2004-10-03 20:35:00 +00002119def FSUBST0r : FPST0rInst <0xE0, (ops RST:$op),
2120 "fsub $op">;
2121def FSUBRrST0 : FPrST0Inst <0xE0, (ops RST:$op),
Chris Lattner10f873b2004-10-04 07:08:46 +00002122 "fsub{|r} {%ST(0), $op|$op, %ST(0)}">;
Chris Lattner3a173df2004-10-03 20:35:00 +00002123def FSUBRPrST0 : FPrST0PInst<0xE0, (ops RST:$op),
Chris Lattner10f873b2004-10-04 07:08:46 +00002124 "fsub{|r}p $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002125
Chris Lattner3a173df2004-10-03 20:35:00 +00002126def FMULST0r : FPST0rInst <0xC8, (ops RST:$op),
2127 "fmul $op">;
2128def FMULrST0 : FPrST0Inst <0xC8, (ops RST:$op),
2129 "fmul {%ST(0), $op|$op, %ST(0)}">;
2130def FMULPrST0 : FPrST0PInst<0xC8, (ops RST:$op),
2131 "fmulp $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002132
Chris Lattner3a173df2004-10-03 20:35:00 +00002133def FDIVRST0r : FPST0rInst <0xF8, (ops RST:$op),
2134 "fdivr $op">;
2135def FDIVrST0 : FPrST0Inst <0xF8, (ops RST:$op),
Chris Lattner10f873b2004-10-04 07:08:46 +00002136 "fdiv{r} {%ST(0), $op|$op, %ST(0)}">;
Chris Lattner3a173df2004-10-03 20:35:00 +00002137def FDIVPrST0 : FPrST0PInst<0xF8, (ops RST:$op),
Chris Lattner10f873b2004-10-04 07:08:46 +00002138 "fdiv{r}p $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002139
Chris Lattner3a173df2004-10-03 20:35:00 +00002140def FDIVST0r : FPST0rInst <0xF0, (ops RST:$op), // ST(0) = ST(0) / ST(i)
2141 "fdiv $op">;
2142def FDIVRrST0 : FPrST0Inst <0xF0, (ops RST:$op), // ST(i) = ST(0) / ST(i)
Chris Lattner10f873b2004-10-04 07:08:46 +00002143 "fdiv{|r} {%ST(0), $op|$op, %ST(0)}">;
Chris Lattner3a173df2004-10-03 20:35:00 +00002144def FDIVRPrST0 : FPrST0PInst<0xF0, (ops RST:$op), // ST(i) = ST(0) / ST(i), pop
Chris Lattner10f873b2004-10-04 07:08:46 +00002145 "fdiv{|r}p $op">;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002146
2147// Floating point compares
Chris Lattner3a173df2004-10-03 20:35:00 +00002148def FUCOMr : FPI<0xE0, AddRegFrm, CompareFP, // FPSW = cmp ST(0) with ST(i)
Chris Lattnerb822aba2005-08-19 00:38:22 +00002149 (ops RST:$reg, variable_ops),
Chris Lattner3a173df2004-10-03 20:35:00 +00002150 "fucom $reg">, DD, Imp<[ST0],[]>;
Chris Lattnerb822aba2005-08-19 00:38:22 +00002151def FUCOMPr : I<0xE8, AddRegFrm, // FPSW = cmp ST(0) with ST(i), pop
2152 (ops RST:$reg, variable_ops),
Evan Chengf0701842005-11-29 19:38:52 +00002153 "fucomp $reg", []>, DD, Imp<[ST0],[]>;
Chris Lattnerb822aba2005-08-19 00:38:22 +00002154def FUCOMPPr : I<0xE9, RawFrm, // cmp ST(0) with ST(1), pop, pop
2155 (ops variable_ops),
Evan Chengf0701842005-11-29 19:38:52 +00002156 "fucompp", []>, DA, Imp<[ST0],[]>;
Chris Lattner1cca5e32003-08-03 21:54:21 +00002157
Chris Lattner3a173df2004-10-03 20:35:00 +00002158def FUCOMIr : FPI<0xE8, AddRegFrm, CompareFP, // CC = cmp ST(0) with ST(i)
Chris Lattnerb822aba2005-08-19 00:38:22 +00002159 (ops RST:$reg, variable_ops),
Chris Lattner3a173df2004-10-03 20:35:00 +00002160 "fucomi {$reg, %ST(0)|%ST(0), $reg}">, DB, Imp<[ST0],[]>;
2161def FUCOMIPr : I<0xE8, AddRegFrm, // CC = cmp ST(0) with ST(i), pop
Chris Lattnerb822aba2005-08-19 00:38:22 +00002162 (ops RST:$reg, variable_ops),
Evan Chengf0701842005-11-29 19:38:52 +00002163 "fucomip {$reg, %ST(0)|%ST(0), $reg}", []>, DF, Imp<[ST0],[]>;
Chris Lattner0e967d42004-08-01 08:13:11 +00002164
Chris Lattnera1b5e162004-04-12 01:38:55 +00002165
Chris Lattnerc8f45872003-08-04 04:59:56 +00002166// Floating point flag ops
Chris Lattner3a173df2004-10-03 20:35:00 +00002167def FNSTSW8r : I<0xE0, RawFrm, // AX = fp flags
Evan Chengf0701842005-11-29 19:38:52 +00002168 (ops), "fnstsw", []>, DF, Imp<[],[AX]>;
Chris Lattner96563df2004-08-01 06:01:00 +00002169
Chris Lattner3a173df2004-10-03 20:35:00 +00002170def FNSTCW16m : I<0xD9, MRM7m, // [mem16] = X87 control world
Evan Chengf0701842005-11-29 19:38:52 +00002171 (ops i16mem:$dst), "fnstcw $dst", []>;
Chris Lattner3a173df2004-10-03 20:35:00 +00002172def FLDCW16m : I<0xD9, MRM5m, // X87 control world = [mem16]
Evan Chengf0701842005-11-29 19:38:52 +00002173 (ops i16mem:$dst), "fldcw $dst", []>;