blob: f423dfa342075706e50fd3f16c7bb1b08b64c760 [file] [log] [blame]
Scott Michel8efdca42007-12-04 22:23:35 +00001//==== SPUInstrFormats.td - Cell SPU Instruction Formats ---*- tablegen -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Scott Michel8efdca42007-12-04 22:23:35 +00007//
8//===----------------------------------------------------------------------===//
9
10//===----------------------------------------------------------------------===//
11//
12// Cell SPU instruction formats. Note that these are notationally similar to
13// PowerPC, like "A-Form". But the sizes of operands and fields differ.
14
15// This was kiped from the PPC instruction formats (seemed like a good idea...)
16
Scott Michel97872d32008-02-23 18:41:37 +000017class SPUInstr<dag OOL, dag IOL, string asmstr, InstrItinClass itin>
Scott Michel8efdca42007-12-04 22:23:35 +000018 : Instruction {
19 field bits<32> Inst;
20
Scott Michel8efdca42007-12-04 22:23:35 +000021 let Namespace = "SPU";
22 let OutOperandList = OOL;
23 let InOperandList = IOL;
24 let AsmString = asmstr;
25 let Itinerary = itin;
26}
27
28// RR Format
29class RRForm<bits<11> opcode, dag OOL, dag IOL, string asmstr,
30 InstrItinClass itin, list<dag> pattern>
Scott Michel97872d32008-02-23 18:41:37 +000031 : SPUInstr<OOL, IOL, asmstr, itin> {
Scott Michel8efdca42007-12-04 22:23:35 +000032 bits<7> RA;
33 bits<7> RB;
34 bits<7> RT;
35
36 let Pattern = pattern;
37
38 let Inst{0-10} = opcode;
39 let Inst{11-17} = RB;
40 let Inst{18-24} = RA;
41 let Inst{25-31} = RT;
42}
43
44let RB = 0 in {
45 // RR Format, where RB is zeroed (dont care):
46 class RRForm_1<bits<11> opcode, dag OOL, dag IOL, string asmstr,
47 InstrItinClass itin, list<dag> pattern>
48 : RRForm<opcode, OOL, IOL, asmstr, itin, pattern>
49 { }
50
51 let RA = 0 in {
52 // RR Format, where RA and RB are zeroed (dont care):
53 // Used for reads from status control registers (see FPSCRRr32)
54 class RRForm_2<bits<11> opcode, dag OOL, dag IOL, string asmstr,
55 InstrItinClass itin, list<dag> pattern>
56 : RRForm<opcode, OOL, IOL, asmstr, itin, pattern>
57 { }
58 }
59}
60
61let RT = 0 in {
62 // RR Format, where RT is zeroed (don't care), or as the instruction handbook
63 // says, "RT is a false target." Used in "Halt if" instructions
64 class RRForm_3<bits<11> opcode, dag OOL, dag IOL, string asmstr,
65 InstrItinClass itin, list<dag> pattern>
66 : RRForm<opcode, OOL, IOL, asmstr, itin, pattern>
67 { }
68}
69
70// RRR Format
71class RRRForm<bits<4> opcode, dag OOL, dag IOL, string asmstr,
72 InstrItinClass itin, list<dag> pattern>
Scott Michel97872d32008-02-23 18:41:37 +000073 : SPUInstr<OOL, IOL, asmstr, itin>
Scott Michel8efdca42007-12-04 22:23:35 +000074{
75 bits<7> RA;
76 bits<7> RB;
77 bits<7> RC;
78 bits<7> RT;
79
80 let Pattern = pattern;
81
82 let Inst{0-3} = opcode;
83 let Inst{4-10} = RT;
84 let Inst{11-17} = RB;
85 let Inst{18-24} = RA;
86 let Inst{25-31} = RC;
87}
88
89// RI7 Format
90class RI7Form<bits<11> opcode, dag OOL, dag IOL, string asmstr,
91 InstrItinClass itin, list<dag> pattern>
Scott Michel97872d32008-02-23 18:41:37 +000092 : SPUInstr<OOL, IOL, asmstr, itin>
Scott Michel8efdca42007-12-04 22:23:35 +000093{
94 bits<7> i7;
95 bits<7> RA;
96 bits<7> RT;
97
98 let Pattern = pattern;
99
100 let Inst{0-10} = opcode;
101 let Inst{11-17} = i7;
102 let Inst{18-24} = RA;
103 let Inst{25-31} = RT;
104}
105
106// CVTIntFp Format
107class CVTIntFPForm<bits<10> opcode, dag OOL, dag IOL, string asmstr,
108 InstrItinClass itin, list<dag> pattern>
Scott Michel97872d32008-02-23 18:41:37 +0000109 : SPUInstr<OOL, IOL, asmstr, itin>
Scott Michel8efdca42007-12-04 22:23:35 +0000110{
111 bits<7> RA;
112 bits<7> RT;
113
114 let Pattern = pattern;
115
116 let Inst{0-9} = opcode;
117 let Inst{10-17} = 0;
118 let Inst{18-24} = RA;
119 let Inst{25-31} = RT;
120}
121
122let RA = 0 in {
123 class BICondForm<bits<11> opcode, string asmstr, list<dag> pattern>
124 : RRForm<opcode, (outs), (ins R32C:$rA, R32C:$func), asmstr,
125 BranchResolv, pattern>
126 { }
127
128 let RT = 0 in {
129 // Branch instruction format (without D/E flag settings)
130 class BRForm<bits<11> opcode, dag OOL, dag IOL, string asmstr,
131 InstrItinClass itin, list<dag> pattern>
132 : RRForm<opcode, OOL, IOL, asmstr, itin, pattern>
133 { }
134
135 class BIForm<bits<11> opcode, string asmstr, list<dag> pattern>
136 : RRForm<opcode, (outs), (ins R32C:$func), asmstr, BranchResolv,
137 pattern>
138 { }
139
140 let RB = 0 in {
141 // Return instruction (bi, branch indirect), RA is zero (LR):
142 class RETForm<string asmstr, list<dag> pattern>
143 : BRForm<0b00010101100, (outs), (ins), asmstr, BranchResolv,
144 pattern>
145 { }
146 }
147 }
148}
149
150// Branch indirect external data forms:
151class BISLEDForm<bits<2> DE_flag, string asmstr, list<dag> pattern>
Scott Michel97872d32008-02-23 18:41:37 +0000152 : SPUInstr<(outs), (ins indcalltarget:$func), asmstr, BranchResolv>
Scott Michel8efdca42007-12-04 22:23:35 +0000153{
154 bits<7> Rcalldest;
155
156 let Pattern = pattern;
157
158 let Inst{0-10} = 0b11010101100;
159 let Inst{11} = 0;
160 let Inst{12-13} = DE_flag;
161 let Inst{14-17} = 0b0000;
162 let Inst{18-24} = Rcalldest;
163 let Inst{25-31} = 0b0000000;
164}
165
166// RI10 Format
167class RI10Form<bits<8> opcode, dag OOL, dag IOL, string asmstr,
168 InstrItinClass itin, list<dag> pattern>
Scott Michel97872d32008-02-23 18:41:37 +0000169 : SPUInstr<OOL, IOL, asmstr, itin>
Scott Michel8efdca42007-12-04 22:23:35 +0000170{
171 bits<10> i10;
172 bits<7> RA;
173 bits<7> RT;
174
175 let Pattern = pattern;
176
177 let Inst{0-7} = opcode;
178 let Inst{8-17} = i10;
179 let Inst{18-24} = RA;
180 let Inst{25-31} = RT;
181}
182
183// RI10 Format, where the constant is zero (or effectively ignored by the
184// SPU)
Scott Michel97872d32008-02-23 18:41:37 +0000185let i10 = 0 in {
186 class RI10Form_1<bits<8> opcode, dag OOL, dag IOL, string asmstr,
187 InstrItinClass itin, list<dag> pattern>
188 : RI10Form<opcode, OOL, IOL, asmstr, itin, pattern>
189 { }
Scott Michel8efdca42007-12-04 22:23:35 +0000190}
191
192// RI10 Format, where RT is ignored.
193// This format is used primarily by the Halt If ... Immediate set of
194// instructions
Scott Michel97872d32008-02-23 18:41:37 +0000195let RT = 0 in {
196 class RI10Form_2<bits<8> opcode, dag OOL, dag IOL, string asmstr,
197 InstrItinClass itin, list<dag> pattern>
198 : RI10Form<opcode, OOL, IOL, asmstr, itin, pattern>
199 { }
Scott Michel8efdca42007-12-04 22:23:35 +0000200}
201
202// RI16 Format
203class RI16Form<bits<9> opcode, dag OOL, dag IOL, string asmstr,
204 InstrItinClass itin, list<dag> pattern>
Scott Michel97872d32008-02-23 18:41:37 +0000205 : SPUInstr<OOL, IOL, asmstr, itin>
Scott Michel8efdca42007-12-04 22:23:35 +0000206{
207 bits<16> i16;
208 bits<7> RT;
209
210 let Pattern = pattern;
211
212 let Inst{0-8} = opcode;
213 let Inst{9-24} = i16;
214 let Inst{25-31} = RT;
215}
216
217// Specialized version of the RI16 Format for unconditional branch relative and
218// branch absolute, branch and set link. Note that for branch and set link, the
219// link register doesn't have to be $lr, but this is actually hard coded into
220// the instruction pattern.
221
222let RT = 0 in {
223 class UncondBranch<bits<9> opcode, dag OOL, dag IOL, string asmstr,
224 list<dag> pattern>
225 : RI16Form<opcode, OOL, IOL, asmstr, BranchResolv, pattern>
226 { }
227
228 class BranchSetLink<bits<9> opcode, dag OOL, dag IOL, string asmstr,
229 list<dag> pattern>
230 : RI16Form<opcode, OOL, IOL, asmstr, BranchResolv, pattern>
231 { }
232}
233
Scott Michelf9f42e62008-01-29 02:16:57 +0000234//===----------------------------------------------------------------------===//
235// Specialized versions of RI16:
236//===----------------------------------------------------------------------===//
237
Scott Michel8efdca42007-12-04 22:23:35 +0000238// RI18 Format
239class RI18Form<bits<7> opcode, dag OOL, dag IOL, string asmstr,
240 InstrItinClass itin, list<dag> pattern>
Scott Michel97872d32008-02-23 18:41:37 +0000241 : SPUInstr<OOL, IOL, asmstr, itin>
Scott Michel8efdca42007-12-04 22:23:35 +0000242{
243 bits<18> i18;
244 bits<7> RT;
245
246 let Pattern = pattern;
247
248 let Inst{0-6} = opcode;
249 let Inst{7-24} = i18;
250 let Inst{25-31} = RT;
251}
252
253//===----------------------------------------------------------------------===//
254// Instruction formats for intrinsics:
255//===----------------------------------------------------------------------===//
256
257// RI10 Format for v8i16 intrinsics
258class RI10_Int_v8i16<bits<8> opcode, string opc, InstrItinClass itin,
259 Intrinsic IntID> :
260 RI10Form<opcode, (outs VECREG:$rT), (ins s10imm:$val, VECREG:$rA),
261 !strconcat(opc, " $rT, $rA, $val"), itin,
262 [(set (v8i16 VECREG:$rT), (IntID (v8i16 VECREG:$rA),
263 i16ImmSExt10:$val))] >;
264
265class RI10_Int_v4i32<bits<8> opcode, string opc, InstrItinClass itin,
266 Intrinsic IntID> :
267 RI10Form<opcode, (outs VECREG:$rT), (ins s10imm:$val, VECREG:$rA),
268 !strconcat(opc, " $rT, $rA, $val"), itin,
269 [(set (v4i32 VECREG:$rT), (IntID (v4i32 VECREG:$rA),
270 i32ImmSExt10:$val))] >;
271
272// RR Format for v8i16 intrinsics
273class RR_Int_v8i16<bits<11> opcode, string opc, InstrItinClass itin,
274 Intrinsic IntID> :
275 RRForm<opcode, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
276 !strconcat(opc, " $rT, $rA, $rB"), itin,
277 [(set (v8i16 VECREG:$rT), (IntID (v8i16 VECREG:$rA),
278 (v8i16 VECREG:$rB)))] >;
279
280// RR Format for v4i32 intrinsics
281class RR_Int_v4i32<bits<11> opcode, string opc, InstrItinClass itin,
282 Intrinsic IntID> :
283 RRForm<opcode, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
284 !strconcat(opc, " $rT, $rA, $rB"), itin,
285 [(set (v4i32 VECREG:$rT), (IntID (v4i32 VECREG:$rA),
286 (v4i32 VECREG:$rB)))] >;
287
288//===----------------------------------------------------------------------===//
289// Pseudo instructions, like call frames:
290//===----------------------------------------------------------------------===//
291
292class Pseudo<dag OOL, dag IOL, string asmstr, list<dag> pattern>
Scott Michel97872d32008-02-23 18:41:37 +0000293 : SPUInstr<OOL, IOL, asmstr, NoItinerary> {
Scott Michel8efdca42007-12-04 22:23:35 +0000294 let Pattern = pattern;
295 let Inst{31-0} = 0;
296}