blob: 6bf5f27d18cc620e0d367cbce7b303cb808537d1 [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 Lattner3ff57512005-12-16 06:02:58 +000038class PseudoInstV8<string nm, dag ops> : InstV8 {
Brian Gaeke7c4676f2004-07-16 10:32:10 +000039 let Name = nm;
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)>;
43def ADJCALLSTACKDOWN : PseudoInstV8<"ADJCALLSTACKDOWN", (ops variable_ops)>;
44def ADJCALLSTACKUP : PseudoInstV8<"ADJCALLSTACKUP", (ops variable_ops)>;
45def IMPLICIT_USE : PseudoInstV8<"IMPLICIT_USE", (ops variable_ops)>;
46def IMPLICIT_DEF : PseudoInstV8<"IMPLICIT_DEF", (ops variable_ops)>;
47def FpMOVD : PseudoInstV8<"FpMOVD", (ops)>; // pseudo 64-bit double move
Chris Lattner275f6452004-02-28 19:37:18 +000048
Brian Gaekea8056fa2004-03-06 05:32:13 +000049// Section A.3 - Synthetic Instructions, p. 85
Brian Gaekec3e97012004-05-08 04:21:32 +000050// special cases of JMPL:
Misha Brukman3df04c52004-10-14 22:32:49 +000051let isReturn = 1, isTerminator = 1, hasDelaySlot = 1 in {
52 let rd = I7.Num, rs1 = G0.Num, simm13 = 8 in
Chris Lattner96b84be2005-12-16 06:25:42 +000053 def RET : F3_2<2, 0b111000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000054 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
55 "ret $b, $c, $dst">;
Misha Brukman3df04c52004-10-14 22:32:49 +000056 let rd = O7.Num, rs1 = G0.Num, simm13 = 8 in
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000057 def RETL: F3_2<2, 0b111000, (ops),
58 "retl">;
Misha Brukman3df04c52004-10-14 22:32:49 +000059}
Brian Gaekec3e97012004-05-08 04:21:32 +000060// CMP is a special case of SUBCC where destination is ignored, by setting it to
61// %g0 (hardwired zero).
62// FIXME: should keep track of the fact that it defs the integer condition codes
63let rd = 0 in
Chris Lattner96b84be2005-12-16 06:25:42 +000064 def CMPri: F3_2<2, 0b010100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000065 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
66 "cmp $b, $c, $dst">;
Brian Gaeke8542e082004-04-02 20:53:37 +000067
68// Section B.1 - Load Integer Instructions, p. 90
Chris Lattner96b84be2005-12-16 06:25:42 +000069def LDSB: F3_2<3, 0b001001,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000070 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
71 "ldsb [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000072def LDSH: F3_2<3, 0b001010,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000073 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
74 "ldsh [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000075def LDUB: F3_2<3, 0b000001,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000076 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
77 "ldub [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000078def LDUH: F3_2<3, 0b000010,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000079 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
80 "lduh [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000081def LD : F3_2<3, 0b000000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000082 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
83 "ld [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000084def LDD : F3_2<3, 0b000011,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000085 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
86 "ldd [$b+$c], $dst">;
Brian Gaeke8542e082004-04-02 20:53:37 +000087
Brian Gaeke562d5b02004-06-18 05:19:27 +000088// Section B.2 - Load Floating-point Instructions, p. 92
Chris Lattner96b84be2005-12-16 06:25:42 +000089def LDFrr : F3_1<3, 0b100000,
Chris Lattner1c4f4352005-12-16 06:52:00 +000090 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000091 "ld [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000092def LDFri : F3_2<3, 0b100000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000093 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
94 "ld [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000095def LDDFrr : F3_1<3, 0b100011,
Chris Lattner1c4f4352005-12-16 06:52:00 +000096 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000097 "ldd [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +000098def LDDFri : F3_2<3, 0b100011,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +000099 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
100 "ldd [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000101def LDFSRrr: F3_1<3, 0b100001,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000102 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000103 "ld [$b+$c], $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000104def LDFSRri: F3_2<3, 0b100001,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000105 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
106 "ld [$b+$c], $dst">;
Brian Gaeke562d5b02004-06-18 05:19:27 +0000107
Brian Gaeke8542e082004-04-02 20:53:37 +0000108// Section B.4 - Store Integer Instructions, p. 95
Chris Lattner96b84be2005-12-16 06:25:42 +0000109def STB : F3_2<3, 0b000101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000110 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
111 "stb $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000112def STH : F3_2<3, 0b000110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000113 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
114 "sth $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000115def ST : F3_2<3, 0b000100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000116 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
117 "st $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000118def STD : F3_2<3, 0b000111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000119 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
120 "std $src, [$base+$offset]">;
Brian Gaekee7f9e0b2004-06-24 07:36:59 +0000121
122// Section B.5 - Store Floating-point Instructions, p. 97
Chris Lattner96b84be2005-12-16 06:25:42 +0000123def STFrr : F3_1<3, 0b100100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000124 (ops IntRegs:$base, IntRegs:$offset, IntRegs:$src),
125 "st $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000126def STFri : F3_2<3, 0b100100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000127 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
128 "st $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000129def STDFrr : F3_1<3, 0b100111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000130 (ops IntRegs:$base, IntRegs:$offset, IntRegs:$src),
131 "std $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000132def STDFri : F3_2<3, 0b100111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000133 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
134 "std $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000135def STFSRrr : F3_1<3, 0b100101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000136 (ops IntRegs:$base, IntRegs:$offset, IntRegs:$src),
137 "st $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000138def STFSRri : F3_2<3, 0b100101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000139 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
140 "st $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000141def STDFQrr : F3_1<3, 0b100110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000142 (ops IntRegs:$base, IntRegs:$offset, IntRegs:$src),
143 "std $src, [$base+$offset]">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000144def STDFQri : F3_2<3, 0b100110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000145 (ops IntRegs:$base, IntRegs:$offset, i32imm:$src),
146 "std $src, [$base+$offset]">;
Misha Brukman23e6c1f2004-02-26 00:37:12 +0000147
Brian Gaeke775158d2004-03-04 04:37:45 +0000148// Section B.9 - SETHI Instruction, p. 104
Brian Gaekee8061732004-03-04 00:56:25 +0000149def SETHIi: F2_1<0b100, "sethi">;
150
Brian Gaeke8542e082004-04-02 20:53:37 +0000151// Section B.10 - NOP Instruction, p. 105
152// (It's a special case of SETHI)
Misha Brukmand36047d2004-10-14 22:33:32 +0000153let rd = 0, imm22 = 0 in
Brian Gaeke8542e082004-04-02 20:53:37 +0000154 def NOP : F2_1<0b100, "nop">;
155
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000156// Section B.11 - Logical Instructions, p. 106
Chris Lattner96b84be2005-12-16 06:25:42 +0000157def ANDrr : F3_1<2, 0b000001,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000158 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
159 "and $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000160def ANDri : F3_2<2, 0b000001,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000161 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
162 "and $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000163def ANDCCrr : F3_1<2, 0b010001,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000164 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
165 "andcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000166def ANDCCri : F3_2<2, 0b010001,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000167 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
168 "andcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000169def ANDNrr : F3_1<2, 0b000101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000170 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
171 "andn $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000172def ANDNri : F3_2<2, 0b000101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000173 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
174 "andn $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000175def ANDNCCrr: F3_1<2, 0b010101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000176 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
177 "andncc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000178def ANDNCCri: F3_2<2, 0b010101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000179 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
180 "andncc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000181def ORrr : F3_1<2, 0b000010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000182 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
183 "or $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000184def ORri : F3_2<2, 0b000010,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000185 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
186 "or $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000187def ORCCrr : F3_1<2, 0b010010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000188 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
189 "orcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000190def ORCCri : F3_2<2, 0b010010,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000191 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
192 "orcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000193def ORNrr : F3_1<2, 0b000110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000194 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
195 "orn $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000196def ORNri : F3_2<2, 0b000110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000197 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
198 "orn $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000199def ORNCCrr : F3_1<2, 0b010110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000200 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
201 "orncc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000202def ORNCCri : F3_2<2, 0b010110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000203 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
204 "orncc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000205def XORrr : F3_1<2, 0b000011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000206 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
207 "xor $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000208def XORri : F3_2<2, 0b000011,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000209 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
210 "xor $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000211def XORCCrr : F3_1<2, 0b010011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000212 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
213 "xorcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000214def XORCCri : F3_2<2, 0b010011,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000215 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
216 "xorcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000217def XNORrr : F3_1<2, 0b000111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000218 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
219 "xnor $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000220def XNORri : F3_2<2, 0b000111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000221 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
222 "xnor $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000223def XNORCCrr: F3_1<2, 0b010111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000224 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
225 "xnorcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000226def XNORCCri: F3_2<2, 0b010111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000227 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
228 "xnorcc $b, $c, $dst">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000229
230// Section B.12 - Shift Instructions, p. 107
Chris Lattner96b84be2005-12-16 06:25:42 +0000231def SLLrr : F3_1<2, 0b100101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000232 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
233 "sll $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000234def SLLri : F3_2<2, 0b100101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000235 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
236 "sll $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000237def SRLrr : F3_1<2, 0b100110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000238 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
239 "srl $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000240def SRLri : F3_2<2, 0b100110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000241 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
242 "srl $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000243def SRArr : F3_1<2, 0b100111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000244 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
245 "sra $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000246def SRAri : F3_2<2, 0b100111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000247 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
248 "sla $b, $c, $dst">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000249
250// Section B.13 - Add Instructions, p. 108
Chris Lattner96b84be2005-12-16 06:25:42 +0000251def ADDrr : F3_1<2, 0b000000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000252 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
253 "add $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000254def ADDri : F3_2<2, 0b000000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000255 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
256 "add $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000257def ADDCCrr : F3_1<2, 0b010000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000258 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
259 "addcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000260def ADDCCri : F3_2<2, 0b010000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000261 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
262 "addcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000263def ADDXrr : F3_1<2, 0b001000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000264 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
265 "addx $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000266def ADDXri : F3_2<2, 0b001000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000267 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
268 "addx $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000269def ADDXCCrr: F3_1<2, 0b011000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000270 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
271 "addxcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000272def ADDXCCri: F3_2<2, 0b011000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000273 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
274 "addxcc $b, $c, $dst">;
Brian Gaekebc1d27a2004-03-03 23:03:14 +0000275
Brian Gaeke775158d2004-03-04 04:37:45 +0000276// Section B.15 - Subtract Instructions, p. 110
Chris Lattner96b84be2005-12-16 06:25:42 +0000277def SUBrr : F3_1<2, 0b000100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000278 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
279 "sub $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000280def SUBri : F3_2<2, 0b000100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000281 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
282 "sub $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000283def SUBCCrr : F3_1<2, 0b010100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000284 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
285 "subcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000286def SUBCCri : F3_2<2, 0b010100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000287 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
288 "subcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000289def SUBXrr : F3_1<2, 0b001100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000290 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
291 "subx $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000292def SUBXri : F3_2<2, 0b001100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000293 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
294 "subx $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000295def SUBXCCrr: F3_1<2, 0b011100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000296 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
297 "subxcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000298def SUBXCCri: F3_2<2, 0b011100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000299 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
300 "subxcc $b, $c, $dst">;
Brian Gaeke775158d2004-03-04 04:37:45 +0000301
Brian Gaeke032f80f2004-03-16 22:37:13 +0000302// Section B.18 - Multiply Instructions, p. 113
Chris Lattner96b84be2005-12-16 06:25:42 +0000303def UMULrr : F3_1<2, 0b001010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000304 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
305 "umul $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000306def UMULri : F3_2<2, 0b001010,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000307 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
308 "umul $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000309def SMULrr : F3_1<2, 0b001011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000310 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
311 "smul $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000312def SMULri : F3_2<2, 0b001011,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000313 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
314 "smul $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000315def UMULCCrr: F3_1<2, 0b011010,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000316 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
317 "umulcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000318def UMULCCri: F3_2<2, 0b011010,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000319 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
320 "umulcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000321def SMULCCrr: F3_1<2, 0b011011,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000322 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
323 "smulcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000324def SMULCCri: F3_2<2, 0b011011,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000325 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
326 "smulcc $b, $c, $dst">;
Brian Gaeke032f80f2004-03-16 22:37:13 +0000327
Brian Gaekee88c9dc2004-04-07 04:01:00 +0000328// Section B.19 - Divide Instructions, p. 115
Chris Lattner96b84be2005-12-16 06:25:42 +0000329def UDIVrr : F3_1<2, 0b001110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000330 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
331 "udiv $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000332def UDIVri : F3_2<2, 0b001110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000333 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
334 "udiv $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000335def SDIVrr : F3_1<2, 0b001111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000336 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
337 "sdiv $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000338def SDIVri : F3_2<2, 0b001111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000339 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
340 "sdiv $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000341def UDIVCCrr : F3_1<2, 0b011110,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000342 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
343 "udivcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000344def UDIVCCri : F3_2<2, 0b011110,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000345 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
346 "udivcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000347def SDIVCCrr : F3_1<2, 0b011111,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000348 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
349 "sdivcc $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000350def SDIVCCri : F3_2<2, 0b011111,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000351 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
352 "sdivcc $b, $c, $dst">;
Brian Gaekee88c9dc2004-04-07 04:01:00 +0000353
Brian Gaekea8056fa2004-03-06 05:32:13 +0000354// Section B.20 - SAVE and RESTORE, p. 117
Chris Lattner96b84be2005-12-16 06:25:42 +0000355def SAVErr : F3_1<2, 0b111100,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000356 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
357 "save $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000358def SAVEri : F3_2<2, 0b111100,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000359 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
360 "save $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000361def RESTORErr : F3_1<2, 0b111101,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000362 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
363 "restore $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000364def RESTOREri : F3_2<2, 0b111101,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000365 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
366 "restore $b, $c, $dst">;
Brian Gaekea8056fa2004-03-06 05:32:13 +0000367
Brian Gaekec3e97012004-05-08 04:21:32 +0000368// Section B.21 - Branch on Integer Condition Codes Instructions, p. 119
Brian Gaeke070bb4a2004-06-17 22:34:29 +0000369
370// conditional branch class:
371class BranchV8<bits<4> cc, string nm> : F2_2<cc, 0b010, nm> {
372 let isBranch = 1;
373 let isTerminator = 1;
Brian Gaeked7bf5012004-09-30 04:04:48 +0000374 let hasDelaySlot = 1;
Brian Gaeke070bb4a2004-06-17 22:34:29 +0000375}
Chris Lattner0f6eab32004-07-31 02:24:37 +0000376
377let isBarrier = 1 in
378 def BA : BranchV8<0b1000, "ba">;
Brian Gaeke070bb4a2004-06-17 22:34:29 +0000379def BN : BranchV8<0b0000, "bn">;
380def BNE : BranchV8<0b1001, "bne">;
381def BE : BranchV8<0b0001, "be">;
382def BG : BranchV8<0b1010, "bg">;
383def BLE : BranchV8<0b0010, "ble">;
384def BGE : BranchV8<0b1011, "bge">;
385def BL : BranchV8<0b0011, "bl">;
386def BGU : BranchV8<0b1100, "bgu">;
387def BLEU : BranchV8<0b0100, "bleu">;
388def BCC : BranchV8<0b1101, "bcc">;
389def BCS : BranchV8<0b0101, "bcs">;
Brian Gaekec3e97012004-05-08 04:21:32 +0000390
Brian Gaeke4185d032004-07-08 09:08:22 +0000391// Section B.22 - Branch on Floating-point Condition Codes Instructions, p. 121
392
393// floating-point conditional branch class:
394class FPBranchV8<bits<4> cc, string nm> : F2_2<cc, 0b110, nm> {
395 let isBranch = 1;
396 let isTerminator = 1;
Brian Gaeked7bf5012004-09-30 04:04:48 +0000397 let hasDelaySlot = 1;
Brian Gaeke4185d032004-07-08 09:08:22 +0000398}
399
400def FBA : FPBranchV8<0b1000, "fba">;
401def FBN : FPBranchV8<0b0000, "fbn">;
402def FBU : FPBranchV8<0b0111, "fbu">;
403def FBG : FPBranchV8<0b0110, "fbg">;
404def FBUG : FPBranchV8<0b0101, "fbug">;
405def FBL : FPBranchV8<0b0100, "fbl">;
406def FBUL : FPBranchV8<0b0011, "fbul">;
407def FBLG : FPBranchV8<0b0010, "fblg">;
408def FBNE : FPBranchV8<0b0001, "fbne">;
409def FBE : FPBranchV8<0b1001, "fbe">;
410def FBUE : FPBranchV8<0b1010, "fbue">;
411def FBGE : FPBranchV8<0b1011, "fbge">;
412def FBUGE: FPBranchV8<0b1100, "fbuge">;
413def FBLE : FPBranchV8<0b1101, "fble">;
414def FBULE: FPBranchV8<0b1110, "fbule">;
415def FBO : FPBranchV8<0b1111, "fbo">;
416
Brian Gaekeb354b712004-11-16 07:32:09 +0000417
418
Brian Gaeke8542e082004-04-02 20:53:37 +0000419// Section B.24 - Call and Link Instruction, p. 125
Brian Gaekea8056fa2004-03-06 05:32:13 +0000420// This is the only Format 1 instruction
Brian Gaekeb354b712004-11-16 07:32:09 +0000421let Uses = [O0, O1, O2, O3, O4, O5], hasDelaySlot = 1, isCall = 1 in {
Brian Gaeked7bf5012004-09-30 04:04:48 +0000422 // pc-relative call:
Brian Gaekeb354b712004-11-16 07:32:09 +0000423 let Defs = [O0, O1, O2, O3, O4, O5, O7, G1, G2, G3, G4, G5, G6, G7,
424 D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15] in
Brian Gaeke374b36d2004-09-29 20:45:05 +0000425 def CALL : InstV8 {
426 bits<30> disp;
427 let op = 1;
428 let Inst{29-0} = disp;
429 let Name = "call";
430 }
Brian Gaekeb354b712004-11-16 07:32:09 +0000431
432 // indirect call (O7 is an EXPLICIT def in indirect calls, so it cannot also
433 // be an implicit def):
434 let Defs = [O0, O1, O2, O3, O4, O5, G1, G2, G3, G4, G5, G6, G7,
435 D0, D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15] in
Chris Lattner1c4f4352005-12-16 06:52:00 +0000436 def JMPLrr : F3_1<2, 0b111000,
437 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
438 "jmpl $b+$c, $dst">;
Brian Gaeke374b36d2004-09-29 20:45:05 +0000439}
Misha Brukman23e6c1f2004-02-26 00:37:12 +0000440
Chris Lattner22ede702004-04-07 04:06:46 +0000441// Section B.29 - Write State Register Instructions
Chris Lattner96b84be2005-12-16 06:25:42 +0000442def WRrr : F3_1<2, 0b110000,
Chris Lattner1c4f4352005-12-16 06:52:00 +0000443 (ops IntRegs:$dst, IntRegs:$b, IntRegs:$c),
444 "wr $b, $c, $dst">;
Chris Lattner96b84be2005-12-16 06:25:42 +0000445def WRri : F3_2<2, 0b110000,
Chris Lattnerd4f2ab52005-12-16 07:10:02 +0000446 (ops IntRegs:$dst, IntRegs:$b, i32imm:$c),
447 "wr $b, $c, $dst">;
Chris Lattner61790472004-04-07 05:04:01 +0000448
Brian Gaekec53105c2004-06-27 22:53:56 +0000449// Convert Integer to Floating-point Instructions, p. 141
450def FITOS : F3_3<2, 0b110100, 0b011000100, "fitos">;
Brian Gaeke22ad67d2004-09-29 19:59:07 +0000451def FITOD : F3_3<2, 0b110100, 0b011001000, "fitod">;
Brian Gaekec53105c2004-06-27 22:53:56 +0000452
Brian Gaeke59e12ed2004-10-14 19:39:35 +0000453// Convert Floating-point to Integer Instructions, p. 142
454def FSTOI : F3_3<2, 0b110100, 0b011010001, "fstoi">;
455def FDTOI : F3_3<2, 0b110100, 0b011010010, "fdtoi">;
456
Brian Gaeke57ff2e32004-06-24 21:22:09 +0000457// Convert between Floating-point Formats Instructions, p. 143
458def FSTOD : F3_3<2, 0b110100, 0b011001001, "fstod">;
459def FDTOS : F3_3<2, 0b110100, 0b011000110, "fdtos">;
460
Brian Gaekef89cc652004-06-18 06:28:10 +0000461// Floating-point Move Instructions, p. 144
462def FMOVS : F3_3<2, 0b110100, 0b000000001, "fmovs">;
463def FNEGS : F3_3<2, 0b110100, 0b000000101, "fnegs">;
464def FABSS : F3_3<2, 0b110100, 0b000001001, "fabss">;
465
Brian Gaekec53105c2004-06-27 22:53:56 +0000466// Floating-point Add and Subtract Instructions, p. 146
467def FADDS : F3_3<2, 0b110100, 0b001000001, "fadds">;
468def FADDD : F3_3<2, 0b110100, 0b001000010, "faddd">;
469def FSUBS : F3_3<2, 0b110100, 0b001000101, "fsubs">;
470def FSUBD : F3_3<2, 0b110100, 0b001000110, "fsubd">;
471
472// Floating-point Multiply and Divide Instructions, p. 147
473def FMULS : F3_3<2, 0b110100, 0b001001001, "fmuls">;
474def FMULD : F3_3<2, 0b110100, 0b001001010, "fmuld">;
475def FSMULD : F3_3<2, 0b110100, 0b001101001, "fsmuld">;
476def FDIVS : F3_3<2, 0b110100, 0b001001101, "fdivs">;
477def FDIVD : F3_3<2, 0b110100, 0b001001110, "fdivd">;
Brian Gaeke57ff2e32004-06-24 21:22:09 +0000478
Brian Gaeke4185d032004-07-08 09:08:22 +0000479// Floating-point Compare Instructions, p. 148
Brian Gaeked7bf5012004-09-30 04:04:48 +0000480// Note: the 2nd template arg is different for these guys.
481// Note 2: the result of a FCMP is not available until the 2nd cycle
482// after the instr is retired, but there is no interlock. This behavior
483// is modelled as a delay slot.
484let hasDelaySlot = 1 in {
485 def FCMPS : F3_3<2, 0b110101, 0b001010001, "fcmps">;
486 def FCMPD : F3_3<2, 0b110101, 0b001010010, "fcmpd">;
487 def FCMPES : F3_3<2, 0b110101, 0b001010101, "fcmpes">;
488 def FCMPED : F3_3<2, 0b110101, 0b001010110, "fcmped">;
489}
Brian Gaeke4185d032004-07-08 09:08:22 +0000490