1 //==== SPUInstrFormats.td - Cell SPU Instruction Formats ---*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
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.
15 // This was kiped from the PPC instruction formats (seemed like a good idea...)
17 class SPUInstr<dag OOL, dag IOL, string asmstr, InstrItinClass itin>
21 let Namespace = "SPU";
22 let OutOperandList = OOL;
23 let InOperandList = IOL;
24 let AsmString = asmstr;
29 class RRForm<bits<11> opcode, dag OOL, dag IOL, string asmstr,
30 InstrItinClass itin, list<dag> pattern>
31 : SPUInstr<OOL, IOL, asmstr, itin> {
36 let Pattern = pattern;
38 let Inst{0-10} = opcode;
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>
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>
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>
71 class RRRForm<bits<4> opcode, dag OOL, dag IOL, string asmstr,
72 InstrItinClass itin, list<dag> pattern>
73 : SPUInstr<OOL, IOL, asmstr, itin>
80 let Pattern = pattern;
82 let Inst{0-3} = opcode;
90 class RI7Form<bits<11> opcode, dag OOL, dag IOL, string asmstr,
91 InstrItinClass itin, list<dag> pattern>
92 : SPUInstr<OOL, IOL, asmstr, itin>
98 let Pattern = pattern;
100 let Inst{0-10} = opcode;
101 let Inst{11-17} = i7;
102 let Inst{18-24} = RA;
103 let Inst{25-31} = RT;
107 class CVTIntFPForm<bits<10> opcode, dag OOL, dag IOL, string asmstr,
108 InstrItinClass itin, list<dag> pattern>
109 : SPUInstr<OOL, IOL, asmstr, itin>
114 let Pattern = pattern;
116 let Inst{0-9} = opcode;
118 let Inst{18-24} = RA;
119 let Inst{25-31} = RT;
123 class BICondForm<bits<11> opcode, dag OOL, dag IOL, string asmstr, list<dag> pattern>
124 : RRForm<opcode, OOL, IOL, asmstr, BranchResolv, pattern>
128 // Branch instruction format (without D/E flag settings)
129 class BRForm<bits<11> opcode, dag OOL, dag IOL, string asmstr,
130 InstrItinClass itin, list<dag> pattern>
131 : RRForm<opcode, OOL, IOL, asmstr, itin, pattern>
134 class BIForm<bits<11> opcode, string asmstr, list<dag> pattern>
135 : RRForm<opcode, (outs), (ins R32C:$func), asmstr, BranchResolv,
140 // Return instruction (bi, branch indirect), RA is zero (LR):
141 class RETForm<string asmstr, list<dag> pattern>
142 : BRForm<0b00010101100, (outs), (ins), asmstr, BranchResolv,
149 // Branch indirect external data forms:
150 class BISLEDForm<bits<2> DE_flag, string asmstr, list<dag> pattern>
151 : SPUInstr<(outs), (ins indcalltarget:$func), asmstr, BranchResolv>
155 let Pattern = pattern;
157 let Inst{0-10} = 0b11010101100;
159 let Inst{12-13} = DE_flag;
160 let Inst{14-17} = 0b0000;
161 let Inst{18-24} = Rcalldest;
162 let Inst{25-31} = 0b0000000;
166 class RI10Form<bits<8> opcode, dag OOL, dag IOL, string asmstr,
167 InstrItinClass itin, list<dag> pattern>
168 : SPUInstr<OOL, IOL, asmstr, itin>
174 let Pattern = pattern;
176 let Inst{0-7} = opcode;
177 let Inst{8-17} = i10;
178 let Inst{18-24} = RA;
179 let Inst{25-31} = RT;
182 // RI10 Format, where the constant is zero (or effectively ignored by the
185 class RI10Form_1<bits<8> opcode, dag OOL, dag IOL, string asmstr,
186 InstrItinClass itin, list<dag> pattern>
187 : RI10Form<opcode, OOL, IOL, asmstr, itin, pattern>
191 // RI10 Format, where RT is ignored.
192 // This format is used primarily by the Halt If ... Immediate set of
195 class RI10Form_2<bits<8> opcode, dag OOL, dag IOL, string asmstr,
196 InstrItinClass itin, list<dag> pattern>
197 : RI10Form<opcode, OOL, IOL, asmstr, itin, pattern>
202 class RI16Form<bits<9> opcode, dag OOL, dag IOL, string asmstr,
203 InstrItinClass itin, list<dag> pattern>
204 : SPUInstr<OOL, IOL, asmstr, itin>
209 let Pattern = pattern;
211 let Inst{0-8} = opcode;
212 let Inst{9-24} = i16;
213 let Inst{25-31} = RT;
216 // Specialized version of the RI16 Format for unconditional branch relative and
217 // branch absolute, branch and set link. Note that for branch and set link, the
218 // link register doesn't have to be $lr, but this is actually hard coded into
219 // the instruction pattern.
222 class UncondBranch<bits<9> opcode, dag OOL, dag IOL, string asmstr,
224 : RI16Form<opcode, OOL, IOL, asmstr, BranchResolv, pattern>
227 class BranchSetLink<bits<9> opcode, dag OOL, dag IOL, string asmstr,
229 : RI16Form<opcode, OOL, IOL, asmstr, BranchResolv, pattern>
233 //===----------------------------------------------------------------------===//
234 // Specialized versions of RI16:
235 //===----------------------------------------------------------------------===//
238 class RI18Form<bits<7> opcode, dag OOL, dag IOL, string asmstr,
239 InstrItinClass itin, list<dag> pattern>
240 : SPUInstr<OOL, IOL, asmstr, itin>
245 let Pattern = pattern;
247 let Inst{0-6} = opcode;
248 let Inst{7-24} = i18;
249 let Inst{25-31} = RT;
252 //===----------------------------------------------------------------------===//
253 // Instruction formats for intrinsics:
254 //===----------------------------------------------------------------------===//
256 // RI10 Format for v8i16 intrinsics
257 class RI10_Int_v8i16<bits<8> opcode, string opc, InstrItinClass itin,
259 RI10Form<opcode, (outs VECREG:$rT), (ins s10imm:$val, VECREG:$rA),
260 !strconcat(opc, " $rT, $rA, $val"), itin,
261 [(set (v8i16 VECREG:$rT), (IntID (v8i16 VECREG:$rA),
262 i16ImmSExt10:$val))] >;
264 class RI10_Int_v4i32<bits<8> opcode, string opc, InstrItinClass itin,
266 RI10Form<opcode, (outs VECREG:$rT), (ins s10imm:$val, VECREG:$rA),
267 !strconcat(opc, " $rT, $rA, $val"), itin,
268 [(set (v4i32 VECREG:$rT), (IntID (v4i32 VECREG:$rA),
269 i32ImmSExt10:$val))] >;
271 // RR Format for v8i16 intrinsics
272 class RR_Int_v8i16<bits<11> opcode, string opc, InstrItinClass itin,
274 RRForm<opcode, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
275 !strconcat(opc, " $rT, $rA, $rB"), itin,
276 [(set (v8i16 VECREG:$rT), (IntID (v8i16 VECREG:$rA),
277 (v8i16 VECREG:$rB)))] >;
279 // RR Format for v4i32 intrinsics
280 class RR_Int_v4i32<bits<11> opcode, string opc, InstrItinClass itin,
282 RRForm<opcode, (outs VECREG:$rT), (ins VECREG:$rA, VECREG:$rB),
283 !strconcat(opc, " $rT, $rA, $rB"), itin,
284 [(set (v4i32 VECREG:$rT), (IntID (v4i32 VECREG:$rA),
285 (v4i32 VECREG:$rB)))] >;
287 //===----------------------------------------------------------------------===//
288 // Pseudo instructions, like call frames:
289 //===----------------------------------------------------------------------===//
291 class Pseudo<dag OOL, dag IOL, string asmstr, list<dag> pattern>
292 : SPUInstr<OOL, IOL, asmstr, NoItinerary> {
293 let OutOperandList = OOL;
294 let InOperandList = IOL;
295 let AsmString = asmstr;
296 let Pattern = pattern;