blob: 1f8349e11bd4dec7705c3821da83d0f2cfef1e9e [file] [log] [blame]
Misha Brukmane07c2aa2004-02-25 21:02:21 +00001//===- SparcV8Instrs.td - Target Description for SparcV8 Target -----------===//
Brian Gaekee785e532004-02-25 19:28:19 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Misha Brukmane07c2aa2004-02-25 21:02:21 +000010// This file describes the SparcV8 instructions in TableGen format.
Brian Gaekee785e532004-02-25 19:28:19 +000011//
12//===----------------------------------------------------------------------===//
13
Misha Brukmane07c2aa2004-02-25 21:02:21 +000014//===----------------------------------------------------------------------===//
Misha Brukman23e6c1f2004-02-26 00:37:12 +000015// Instruction format superclass
Misha Brukmane07c2aa2004-02-25 21:02:21 +000016//===----------------------------------------------------------------------===//
17
18class InstV8 : Instruction { // SparcV8 instruction baseline
19 field bits<32> Inst;
20
21 let Namespace = "V8";
22
23 bits<2> op;
24 let Inst{31-30} = op; // Top two bits are the 'op' field
25
26 // Bit attributes specific to SparcV8 instructions
27 bit isPasi = 0; // Does this instruction affect an alternate addr space?
28 bit isPrivileged = 0; // Is this a privileged instruction?
Brian Gaekee785e532004-02-25 19:28:19 +000029}
30
Misha Brukmanc42077d2004-09-22 21:38:42 +000031include "SparcV8InstrFormats.td"
Brian Gaekee785e532004-02-25 19:28:19 +000032
Misha Brukman23e6c1f2004-02-26 00:37:12 +000033//===----------------------------------------------------------------------===//
34// Instructions
35//===----------------------------------------------------------------------===//
36
Chris Lattner275f6452004-02-28 19:37:18 +000037// Pseudo instructions.
Chris Lattner17392e02005-12-16 07:13:26 +000038class PseudoInstV8<string asmstr, dag ops> : InstV8 {
39 let AsmString = asmstr;
Chris Lattner3ff57512005-12-16 06:02:58 +000040 dag OperandList = ops;
Chris Lattner275f6452004-02-28 19:37:18 +000041}
Chris Lattner3ff57512005-12-16 06:02:58 +000042def PHI : PseudoInstV8<"PHI", (ops variable_ops)>;
Chris Lattner17392e02005-12-16 07:13:26 +000043def ADJCALLSTACKDOWN : PseudoInstV8<"!ADJCALLSTACKDOWN $amt",
44 (ops i32imm:$amt)>;
45def ADJCALLSTACKUP : PseudoInstV8<"!ADJCALLSTACKUP $amt",
46 (ops i32imm:$amt)>;
47//def IMPLICIT_USE : PseudoInstV8<"!IMPLICIT_USE",(ops variable_ops)>;
48def IMPLICIT_DEF : PseudoInstV8<"!IMPLICIT_DEF $dst",
49 (ops IntRegs:$dst)>;
50def FpMOVD : PseudoInstV8<"!FpMOVD", (ops)>; // pseudo 64-bit double move
Chris Lattner275f6452004-02-28 19:37:18 +000051
Brian Gaekea8056fa2004-03-06 05:32:13 +000052// Section A.3 - Synthetic Instructions, p. 85
Brian Gaekec3e97012004-05-08 04:21:32 +000053// special cases of JMPL:
Misha Brukman3df04c52004-10-14 22:32:49 +000054let isReturn = 1, isTerminator = 1, hasDelaySlot = 1 in {
55 let rd = I7.Num, rs1 = G0.Num, simm13 = 8 in
Chris Lattner96b84be2005-12-16 06:25:42 +000056 def RET : F3_2<2, 0b111000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000057 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
58 "ret $b, $c, $dst">;
Misha Brukman3df04c52004-10-14 22:32:49 +000059 let rd = O7.Num, rs1 = G0.Num, simm13 = 8 in
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000060 def RETL: F3_2<2, 0b111000, (ops),
61 "retl">;
Misha Brukman3df04c52004-10-14 22:32:49 +000062}
Brian Gaekec3e97012004-05-08 04:21:32 +000063// CMP is a special case of SUBCC where destination is ignored, by setting it to
64// %g0 (hardwired zero).
65// FIXME: should keep track of the fact that it defs the integer condition codes
66let rd = 0 in
Chris Lattner96b84be2005-12-16 06:25:42 +000067 def CMPri: F3_2<2, 0b010100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000068 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
69 "cmp $b, $c, $dst">;
Brian Gaeke8542e082004-04-02 20:53:37 +000070
71// Section B.1 - Load Integer Instructions, p. 90
Chris Lattner96b84be2005-12-16 06:25:42 +000072def LDSB: F3_2<3, 0b001001,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000073 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
74 "ldsb [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000075def LDSH: F3_2<3, 0b001010,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000076 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
77 "ldsh [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000078def LDUB: F3_2<3, 0b000001,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000079 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
80 "ldub [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000081def LDUH: F3_2<3, 0b000010,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000082 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
83 "lduh [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000084def LD : F3_2<3, 0b000000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000085 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
86 "ld [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000087def LDD : F3_2<3, 0b000011,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000088 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
89 "ldd [$b+$c], $dst">;
Brian Gaeke8542e082004-04-02 20:53:37 +000090
Brian Gaeke562d5b02004-06-18 05:19:27 +000091// Section B.2 - Load Floating-point Instructions, p. 92
Chris Lattner96b84be2005-12-16 06:25:42 +000092def LDFrr : F3_1<3, 0b100000,
Chris Lattner1c4f4352005-12-16 06:52:00 +000093 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000094 "ld [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000095def LDFri : F3_2<3, 0b100000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000096 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
97 "ld [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000098def LDDFrr : F3_1<3, 0b100011,
Chris Lattner1c4f4352005-12-16 06:52:00 +000099 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000100 "ldd [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000101def LDDFri : F3_2<3, 0b100011,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000102 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
103 "ldd [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000104def LDFSRrr: F3_1<3, 0b100001,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000105 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000106 "ld [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000107def LDFSRri: F3_2<3, 0b100001,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000108 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
109 "ld [$b+$c], $dst">;
Brian Gaeke562d5b02004-06-18 05:19:27 +0000110
Brian Gaeke8542e082004-04-02 20:53:37 +0000111// Section B.4 - Store Integer Instructions, p. 95
Chris Lattner96b84be2005-12-16 06:25:42 +0000112def STB : F3_2<3, 0b000101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000113 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
114 "stb $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000115def STH : F3_2<3, 0b000110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000116 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
117 "sth $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000118def ST : F3_2<3, 0b000100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000119 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
120 "st $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000121def STD : F3_2<3, 0b000111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000122 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
123 "std $src, [$base+$offset]">;
Brian Gaekee7f9e0b2004-06-24 07:36:59 +0000124
125// Section B.5 - Store Floating-point Instructions, p. 97
Chris Lattner96b84be2005-12-16 06:25:42 +0000126def STFrr : F3_1<3, 0b100100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000127 (ops IntRegs:$base, IntRegs:$offset, IntRegs:$src),
128 "st $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000129def STFri : F3_2<3, 0b100100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000130 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
131 "st $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000132def STDFrr : F3_1<3, 0b100111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000133 (ops IntRegs:$base, IntRegs:$offset, IntRegs:$src),
134 "std $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000135def STDFri : F3_2<3, 0b100111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000136 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
137 "std $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000138def STFSRrr : F3_1<3, 0b100101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000139 (ops IntRegs:$base, IntRegs:$offset, IntRegs:$src),
140 "st $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000141def STFSRri : F3_2<3, 0b100101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000142 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
143 "st $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000144def STDFQrr : F3_1<3, 0b100110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000145 (ops IntRegs:$base, IntRegs:$offset, IntRegs:$src),
146 "std $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000147def STDFQri : F3_2<3, 0b100110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000148 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
149 "std $src, [$base+$offset]">;
Misha Brukman23e6c1f2004-02-26 00:37:12 +0000150
Brian Gaeke775158d2004-03-04 04:37:45 +0000151// Section B.9 - SETHI Instruction, p. 104
Brian Gaekee8061732004-03-04 00:56:25 +0000152def SETHIi: F2_1<0b100, "sethi">;
153
Brian Gaeke8542e082004-04-02 20:53:37 +0000154// Section B.10 - NOP Instruction, p. 105
155// (It's a special case of SETHI)
Misha Brukmand36047d2004-10-14 22:33:32 +0000156let rd = 0, imm22 = 0 in
Brian Gaeke8542e082004-04-02 20:53:37 +0000157 def NOP : F2_1<0b100, "nop">;
158
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000159// Section B.11 - Logical Instructions, p. 106
Chris Lattner96b84be2005-12-16 06:25:42 +0000160def ANDrr : F3_1<2, 0b000001,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000161 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
162 "and $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000163def ANDri : F3_2<2, 0b000001,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000164 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
165 "and $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000166def ANDCCrr : F3_1<2, 0b010001,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000167 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
168 "andcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000169def ANDCCri : F3_2<2, 0b010001,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000170 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
171 "andcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000172def ANDNrr : F3_1<2, 0b000101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000173 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
174 "andn $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000175def ANDNri : F3_2<2, 0b000101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000176 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
177 "andn $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000178def ANDNCCrr: F3_1<2, 0b010101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000179 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
180 "andncc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000181def ANDNCCri: F3_2<2, 0b010101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000182 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
183 "andncc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000184def ORrr : F3_1<2, 0b000010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000185 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
186 "or $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000187def ORri : F3_2<2, 0b000010,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000188 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
189 "or $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000190def ORCCrr : F3_1<2, 0b010010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000191 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
192 "orcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000193def ORCCri : F3_2<2, 0b010010,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000194 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
195 "orcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000196def ORNrr : F3_1<2, 0b000110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000197 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
198 "orn $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000199def ORNri : F3_2<2, 0b000110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000200 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
201 "orn $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000202def ORNCCrr : F3_1<2, 0b010110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000203 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
204 "orncc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000205def ORNCCri : F3_2<2, 0b010110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000206 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
207 "orncc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000208def XORrr : F3_1<2, 0b000011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000209 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
210 "xor $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000211def XORri : F3_2<2, 0b000011,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000212 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
213 "xor $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000214def XORCCrr : F3_1<2, 0b010011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000215 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
216 "xorcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000217def XORCCri : F3_2<2, 0b010011,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000218 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
219 "xorcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000220def XNORrr : F3_1<2, 0b000111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000221 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
222 "xnor $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000223def XNORri : F3_2<2, 0b000111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000224 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
225 "xnor $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000226def XNORCCrr: F3_1<2, 0b010111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000227 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
228 "xnorcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000229def XNORCCri: F3_2<2, 0b010111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000230 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
231 "xnorcc $b, $c, $dst">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000232
233// Section B.12 - Shift Instructions, p. 107
Chris Lattner96b84be2005-12-16 06:25:42 +0000234def SLLrr : F3_1<2, 0b100101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000235 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
236 "sll $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000237def SLLri : F3_2<2, 0b100101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000238 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
239 "sll $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000240def SRLrr : F3_1<2, 0b100110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000241 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
242 "srl $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000243def SRLri : F3_2<2, 0b100110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000244 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
245 "srl $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000246def SRArr : F3_1<2, 0b100111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000247 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
248 "sra $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000249def SRAri : F3_2<2, 0b100111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000250 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
251 "sla $b, $c, $dst">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000252
253// Section B.13 - Add Instructions, p. 108
Chris Lattner96b84be2005-12-16 06:25:42 +0000254def ADDrr : F3_1<2, 0b000000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000255 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
256 "add $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000257def ADDri : F3_2<2, 0b000000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000258 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
259 "add $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000260def ADDCCrr : F3_1<2, 0b010000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000261 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
262 "addcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000263def ADDCCri : F3_2<2, 0b010000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000264 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
265 "addcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000266def ADDXrr : F3_1<2, 0b001000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000267 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
268 "addx $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000269def ADDXri : F3_2<2, 0b001000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000270 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
271 "addx $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000272def ADDXCCrr: F3_1<2, 0b011000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000273 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
274 "addxcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000275def ADDXCCri: F3_2<2, 0b011000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000276 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
277 "addxcc $b, $c, $dst">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000278
Brian Gaeke775158d2004-03-04 04:37:45 +0000279// Section B.15 - Subtract Instructions, p. 110
Chris Lattner96b84be2005-12-16 06:25:42 +0000280def SUBrr : F3_1<2, 0b000100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000281 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
282 "sub $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000283def SUBri : F3_2<2, 0b000100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000284 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
285 "sub $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000286def SUBCCrr : F3_1<2, 0b010100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000287 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
288 "subcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000289def SUBCCri : F3_2<2, 0b010100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000290 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
291 "subcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000292def SUBXrr : F3_1<2, 0b001100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000293 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
294 "subx $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000295def SUBXri : F3_2<2, 0b001100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000296 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
297 "subx $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000298def SUBXCCrr: F3_1<2, 0b011100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000299 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
300 "subxcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000301def SUBXCCri: F3_2<2, 0b011100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000302 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
303 "subxcc $b, $c, $dst">;
Brian Gaeke775158d2004-03-04 04:37:45 +0000304
Brian Gaeke032f80f2004-03-16 22:37:13 +0000305// Section B.18 - Multiply Instructions, p. 113
Chris Lattner96b84be2005-12-16 06:25:42 +0000306def UMULrr : F3_1<2, 0b001010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000307 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
308 "umul $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000309def UMULri : F3_2<2, 0b001010,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000310 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
311 "umul $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000312def SMULrr : F3_1<2, 0b001011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000313 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
314 "smul $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000315def SMULri : F3_2<2, 0b001011,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000316 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
317 "smul $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000318def UMULCCrr: F3_1<2, 0b011010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000319 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
320 "umulcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000321def UMULCCri: F3_2<2, 0b011010,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000322 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
323 "umulcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000324def SMULCCrr: F3_1<2, 0b011011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000325 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
326 "smulcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000327def SMULCCri: F3_2<2, 0b011011,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000328 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
329 "smulcc $b, $c, $dst">;
Brian Gaeke032f80f2004-03-16 22:37:13 +0000330
Brian Gaekee88c9dc2004-04-07 04:01:00 +0000331// Section B.19 - Divide Instructions, p. 115
Chris Lattner96b84be2005-12-16 06:25:42 +0000332def UDIVrr : F3_1<2, 0b001110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000333 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
334 "udiv $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000335def UDIVri : F3_2<2, 0b001110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000336 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
337 "udiv $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000338def SDIVrr : F3_1<2, 0b001111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000339 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
340 "sdiv $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000341def SDIVri : F3_2<2, 0b001111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000342 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
343 "sdiv $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000344def UDIVCCrr : F3_1<2, 0b011110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000345 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
346 "udivcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000347def UDIVCCri : F3_2<2, 0b011110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000348 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
349 "udivcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000350def SDIVCCrr : F3_1<2, 0b011111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000351 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
352 "sdivcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000353def SDIVCCri : F3_2<2, 0b011111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000354 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
355 "sdivcc $b, $c, $dst">;
Brian Gaekee88c9dc2004-04-07 04:01:00 +0000356
Brian Gaekea8056fa2004-03-06 05:32:13 +0000357// Section B.20 - SAVE and RESTORE, p. 117
Chris Lattner96b84be2005-12-16 06:25:42 +0000358def SAVErr : F3_1<2, 0b111100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000359 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
360 "save $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000361def SAVEri : F3_2<2, 0b111100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000362 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
363 "save $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000364def RESTORErr : F3_1<2, 0b111101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000365 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
366 "restore $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000367def RESTOREri : F3_2<2, 0b111101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000368 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
369 "restore $b, $c, $dst">;
Brian Gaekea8056fa2004-03-06 05:32:13 +0000370
Brian Gaekec3e97012004-05-08 04:21:32 +0000371// Section B.21 - Branch on Integer Condition Codes Instructions, p. 119
Brian Gaeke070bb4a2004-06-17 22:34:29 +0000372
373// conditional branch class:
374class BranchV8<bits<4> cc, string nm> : F2_2<cc, 0b010, nm> {
375 let isBranch = 1;
376 let isTerminator = 1;
Brian Gaeked7bf5012004-09-30 04:04:48 +0000377 let hasDelaySlot = 1;
Brian Gaeke070bb4a2004-06-17 22:34:29 +0000378}
Chris Lattner0f6eab32004-07-31 02:24:37 +0000379
380let isBarrier = 1 in
381 def BA : BranchV8<0b1000, "ba">;
Brian Gaeke070bb4a2004-06-17 22:34:29 +0000382def BN : BranchV8<0b0000, "bn">;
383def BNE : BranchV8<0b1001, "bne">;
384def BE : BranchV8<0b0001, "be">;
385def BG : BranchV8<0b1010, "bg">;
386def BLE : BranchV8<0b0010, "ble">;
387def BGE : BranchV8<0b1011, "bge">;
388def BL : BranchV8<0b0011, "bl">;
389def BGU : BranchV8<0b1100, "bgu">;
390def BLEU : BranchV8<0b0100, "bleu">;
391def BCC : BranchV8<0b1101, "bcc">;
392def BCS : BranchV8<0b0101, "bcs">;
Brian Gaekec3e97012004-05-08 04:21:32 +0000393
Brian Gaeke4185d032004-07-08 09:08:22 +0000394// Section B.22 - Branch on Floating-point Condition Codes Instructions, p. 121
395
396// floating-point conditional branch class:
397class FPBranchV8<bits<4> cc, string nm> : F2_2<cc, 0b110, nm> {
398 let isBranch = 1;
399 let isTerminator = 1;
Brian Gaeked7bf5012004-09-30 04:04:48 +0000400 let hasDelaySlot = 1;
Brian Gaeke4185d032004-07-08 09:08:22 +0000401}
402
403def FBA : FPBranchV8<0b1000, "fba">;
404def FBN : FPBranchV8<0b0000, "fbn">;
405def FBU : FPBranchV8<0b0111, "fbu">;
406def FBG : FPBranchV8<0b0110, "fbg">;
407def FBUG : FPBranchV8<0b0101, "fbug">;
408def FBL : FPBranchV8<0b0100, "fbl">;
409def FBUL : FPBranchV8<0b0011, "fbul">;
410def FBLG : FPBranchV8<0b0010, "fblg">;
411def FBNE : FPBranchV8<0b0001, "fbne">;
412def FBE : FPBranchV8<0b1001, "fbe">;
413def FBUE : FPBranchV8<0b1010, "fbue">;
414def FBGE : FPBranchV8<0b1011, "fbge">;
415def FBUGE: FPBranchV8<0b1100, "fbuge">;
416def FBLE : FPBranchV8<0b1101, "fble">;
417def FBULE: FPBranchV8<0b1110, "fbule">;
418def FBO : FPBranchV8<0b1111, "fbo">;
419
Brian Gaekeb354b712004-11-16 07:32:09 +0000420
421
Brian Gaeke8542e082004-04-02 20:53:37 +0000422// Section B.24 - Call and Link Instruction, p. 125
Brian Gaekea8056fa2004-03-06 05:32:13 +0000423// This is the only Format 1 instruction
Brian Gaekeb354b712004-11-16 07:32:09 +0000424let Uses = [O0, O1, O2, O3, O4, O5], hasDelaySlot = 1, isCall = 1 in {
Brian Gaeked7bf5012004-09-30 04:04:48 +0000425 // pc-relative call:
Brian Gaekeb354b712004-11-16 07:32:09 +0000426 let Defs = [O0, O1, O2, O3, O4, O5, O7, G1, G2, G3, G4, G5, G6, G7,
427 D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15] in
Brian Gaeke374b36d2004-09-29 20:45:05 +0000428 def CALL : InstV8 {
429 bits<30> disp;
430 let op = 1;
431 let Inst{29-0} = disp;
432 let Name = "call";
433 }
Brian Gaekeb354b712004-11-16 07:32:09 +0000434
435 // indirect call (O7 is an EXPLICIT def in indirect calls, so it cannot also
436 // be an implicit def):
437 let Defs = [O0, O1, O2, O3, O4, O5, G1, G2, G3, G4, G5, G6, G7,
438 D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15] in
Chris Lattner1c4f4352005-12-16 06:52:00 +0000439 def JMPLrr : F3_1<2, 0b111000,
440 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
441 "jmpl $b+$c, $dst">;
Brian Gaeke374b36d2004-09-29 20:45:05 +0000442}
Misha Brukman23e6c1f2004-02-26 00:37:12 +0000443
Chris Lattner22ede702004-04-07 04:06:46 +0000444// Section B.29 - Write State Register Instructions
Chris Lattner96b84be2005-12-16 06:25:42 +0000445def WRrr : F3_1<2, 0b110000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000446 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
447 "wr $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000448def WRri : F3_2<2, 0b110000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000449 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
450 "wr $b, $c, $dst">;
Chris Lattner61790472004-04-07 05:04:01 +0000451
Brian Gaekec53105c2004-06-27 22:53:56 +0000452// Convert Integer to Floating-point Instructions, p. 141
453def FITOS : F3_3<2, 0b110100, 0b011000100, "fitos">;
Brian Gaeke22ad67d2004-09-29 19:59:07 +0000454def FITOD : F3_3<2, 0b110100, 0b011001000, "fitod">;
Brian Gaekec53105c2004-06-27 22:53:56 +0000455
Brian Gaeke59e12ed2004-10-14 19:39:35 +0000456// Convert Floating-point to Integer Instructions, p. 142
457def FSTOI : F3_3<2, 0b110100, 0b011010001, "fstoi">;
458def FDTOI : F3_3<2, 0b110100, 0b011010010, "fdtoi">;
459
Brian Gaeke57ff2e32004-06-24 21:22:09 +0000460// Convert between Floating-point Formats Instructions, p. 143
461def FSTOD : F3_3<2, 0b110100, 0b011001001, "fstod">;
462def FDTOS : F3_3<2, 0b110100, 0b011000110, "fdtos">;
463
Brian Gaekef89cc652004-06-18 06:28:10 +0000464// Floating-point Move Instructions, p. 144
465def FMOVS : F3_3<2, 0b110100, 0b000000001, "fmovs">;
466def FNEGS : F3_3<2, 0b110100, 0b000000101, "fnegs">;
467def FABSS : F3_3<2, 0b110100, 0b000001001, "fabss">;
468
Brian Gaekec53105c2004-06-27 22:53:56 +0000469// Floating-point Add and Subtract Instructions, p. 146
470def FADDS : F3_3<2, 0b110100, 0b001000001, "fadds">;
471def FADDD : F3_3<2, 0b110100, 0b001000010, "faddd">;
472def FSUBS : F3_3<2, 0b110100, 0b001000101, "fsubs">;
473def FSUBD : F3_3<2, 0b110100, 0b001000110, "fsubd">;
474
475// Floating-point Multiply and Divide Instructions, p. 147
476def FMULS : F3_3<2, 0b110100, 0b001001001, "fmuls">;
477def FMULD : F3_3<2, 0b110100, 0b001001010, "fmuld">;
478def FSMULD : F3_3<2, 0b110100, 0b001101001, "fsmuld">;
479def FDIVS : F3_3<2, 0b110100, 0b001001101, "fdivs">;
480def FDIVD : F3_3<2, 0b110100, 0b001001110, "fdivd">;
Brian Gaeke57ff2e32004-06-24 21:22:09 +0000481
Brian Gaeke4185d032004-07-08 09:08:22 +0000482// Floating-point Compare Instructions, p. 148
Brian Gaeked7bf5012004-09-30 04:04:48 +0000483// Note: the 2nd template arg is different for these guys.
484// Note 2: the result of a FCMP is not available until the 2nd cycle
485// after the instr is retired, but there is no interlock. This behavior
486// is modelled as a delay slot.
487let hasDelaySlot = 1 in {
488 def FCMPS : F3_3<2, 0b110101, 0b001010001, "fcmps">;
489 def FCMPD : F3_3<2, 0b110101, 0b001010010, "fcmpd">;
490 def FCMPES : F3_3<2, 0b110101, 0b001010101, "fcmpes">;
491 def FCMPED : F3_3<2, 0b110101, 0b001010110, "fcmped">;
492}
Brian Gaeke4185d032004-07-08 09:08:22 +0000493