1 //===- PowerPCInstrFormats.td - PowerPC Instruction Formats --*- tablegen -*-=//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
13 class Format<bits<5> val> {
17 def Pseudo: Format<0>;
20 def Simm16 : Format<3>;
21 def PCRelimm24 : Format<5>;
22 def Imm24 : Format<6>;
24 def PCRelimm14 : Format<8>;
25 def Imm14 : Format<9>;
26 def Imm2 : Format<10>;
28 def Imm3 : Format<12>;
29 def Imm1 : Format<13>;
31 def Imm4 : Format<15>;
32 def Imm8 : Format<16>;
33 def Disimm16 : Format<17>;
34 def Disimm14 : Format<18>;
37 def Imm15 : Format<21>;
39 def Imm6 : Format<23>;
41 //===----------------------------------------------------------------------===//
43 // PowerPC instruction formats
45 class I<bits<6> opcode, dag OL, string asmstr> : Instruction {
48 bit PPC64 = 0; // Default value, override with isPPC64
49 bit VMX = 0; // Default value, override with isVMX
52 let Namespace = "PPC";
53 let Inst{0-5} = opcode;
55 let AsmString = asmstr;
59 class IForm<bits<6> opcode, bit aa, bit lk, dag OL, string asmstr>
60 : I<opcode, OL, asmstr> {
69 class BForm<bits<6> opcode, bit aa, bit lk, bits<5> bo, bits<2> bicode, dag OL,
71 : I<opcode, OL, asmstr> {
77 let Inst{14-15} = bicode;
84 class DForm_base<bits<6> opcode, dag OL, string asmstr, list<dag> pattern>
85 : I<opcode, OL, asmstr> {
86 let Pattern = pattern;
96 class DForm_1<bits<6> opcode, dag OL, string asmstr>
97 : I<opcode, OL, asmstr> {
107 class DForm_2<bits<6> opcode, dag OL, string asmstr, list<dag> pattern>
108 : DForm_base<opcode, OL, asmstr, pattern>;
110 class DForm_2_r0<bits<6> opcode, dag OL, string asmstr, list<dag> pattern>
111 : I<opcode, OL, asmstr> {
115 let Pattern = pattern;
122 // Currently we make the use/def reg distinction in ISel, not tablegen
123 class DForm_3<bits<6> opcode, dag OL, string asmstr>
124 : DForm_1<opcode, OL, asmstr>;
126 class DForm_4<bits<6> opcode, dag OL, string asmstr, list<dag> pattern>
127 : I<opcode, OL, asmstr> {
132 let Pattern = pattern;
139 class DForm_4_zero<bits<6> opcode, dag OL, string asmstr>
140 : DForm_1<opcode, OL, asmstr> {
146 class DForm_5<bits<6> opcode, dag OL, string asmstr> : I<opcode, OL, asmstr> {
155 let Inst{11-15} = RA;
159 class DForm_5_ext<bits<6> opcode, dag OL, string asmstr>
160 : DForm_5<opcode, OL, asmstr> {
164 class DForm_6<bits<6> opcode, dag OL, string asmstr>
165 : DForm_5<opcode, OL, asmstr>;
167 class DForm_6_ext<bits<6> opcode, dag OL, string asmstr>
168 : DForm_6<opcode, OL, asmstr> {
172 class DForm_8<bits<6> opcode, dag OL, string asmstr>
173 : DForm_1<opcode, OL, asmstr> {
176 class DForm_9<bits<6> opcode, dag OL, string asmstr>
177 : DForm_1<opcode, OL, asmstr> {
181 class DSForm_1<bits<6> opcode, bits<2> xo, dag OL, string asmstr>
182 : I<opcode, OL, asmstr> {
187 let Inst{6-10} = RST;
188 let Inst{11-15} = RA;
189 let Inst{16-29} = DS;
190 let Inst{30-31} = xo;
193 class DSForm_2<bits<6> opcode, bits<2> xo, dag OL, string asmstr>
194 : DSForm_1<opcode, xo, OL, asmstr>;
197 class XForm_base_r3xo<bits<6> opcode, bits<10> xo,
198 dag OL, string asmstr> : I<opcode, OL, asmstr> {
203 bit RC = 0; // set by isDOT
205 let Inst{6-10} = RST;
208 let Inst{21-30} = xo;
212 // This is the same as XForm_base_r3xo, but the first two operands are swapped
213 // when code is emitted.
214 class XForm_base_r3xo_swapped
215 <bits<6> opcode, bits<10> xo, dag OL, string asmstr>
216 : I<opcode, OL, asmstr> {
221 bit RC = 0; // set by isDOT
223 let Inst{6-10} = RST;
226 let Inst{21-30} = xo;
231 class XForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
232 : XForm_base_r3xo<opcode, xo, OL, asmstr>;
234 class XForm_6<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
236 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr> {
237 let Pattern = pattern;
240 class XForm_8<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
241 : XForm_base_r3xo<opcode, xo, OL, asmstr>;
243 class XForm_10<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
244 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr> {
247 class XForm_11<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
249 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr> {
251 let Pattern = pattern;
254 class XForm_16<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
255 : I<opcode, OL, asmstr> {
264 let Inst{11-15} = RA;
265 let Inst{16-20} = RB;
266 let Inst{21-30} = xo;
270 class XForm_16_ext<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
271 : XForm_16<opcode, xo, OL, asmstr> {
275 class XForm_17<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
276 : I<opcode, OL, asmstr> {
283 let Inst{11-15} = FRA;
284 let Inst{16-20} = FRB;
285 let Inst{21-30} = xo;
289 class XForm_25<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
290 : XForm_base_r3xo<opcode, xo, OL, asmstr> {
293 class XForm_26<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
294 : XForm_base_r3xo<opcode, xo, OL, asmstr> {
298 class XForm_28<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
299 : XForm_base_r3xo<opcode, xo, OL, asmstr> {
303 class XLForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
304 : I<opcode, OL, asmstr> {
313 let Inst{9-10} = CRDb;
314 let Inst{11-13} = CRA;
315 let Inst{14-15} = CRAb;
316 let Inst{16-18} = CRB;
317 let Inst{19-20} = CRBb;
318 let Inst{21-30} = xo;
322 class XLForm_2<bits<6> opcode, bits<10> xo, bit lk,
323 dag OL, string asmstr> : I<opcode, OL, asmstr> {
329 let Inst{11-15} = BI;
331 let Inst{19-20} = BH;
332 let Inst{21-30} = xo;
336 class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo,
337 bits<5> bi, bit lk, dag OL, string asmstr>
338 : XLForm_2<opcode, xo, lk, OL, asmstr> {
344 class XLForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
345 : I<opcode, OL, asmstr> {
351 let Inst{11-13} = BFA;
354 let Inst{21-30} = xo;
359 class XFXForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
360 : I<opcode, OL, asmstr> {
365 let Inst{11-20} = SPR;
366 let Inst{21-30} = xo;
370 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
371 dag OL, string asmstr>
372 : XFXForm_1<opcode, xo, OL, asmstr> {
376 class XFXForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
377 : I<opcode, OL, asmstr> {
382 let Inst{21-30} = xo;
386 class XFXForm_5<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
387 : I<opcode, OL, asmstr> {
393 let Inst{12-19} = FXM;
395 let Inst{21-30} = xo;
399 class XFXForm_5a<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
400 : I<opcode, OL, asmstr> {
406 let Inst{12-19} = FXM;
408 let Inst{21-30} = xo;
413 class XFXForm_7<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
414 : XFXForm_1<opcode, xo, OL, asmstr>;
416 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
417 dag OL, string asmstr>
418 : XFXForm_7<opcode, xo, OL, asmstr> {
423 class XSForm_1<bits<6> opcode, bits<9> xo, dag OL, string asmstr>
424 : I<opcode, OL, asmstr> {
429 bit RC = 0; // set by isDOT
433 let Inst{16-20} = SH{1-5};
434 let Inst{21-29} = xo;
435 let Inst{30} = SH{0};
440 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, dag OL, string asmstr,
442 : I<opcode, OL, asmstr> {
447 let Pattern = pattern;
449 bit RC = 0; // set by isDOT
452 let Inst{11-15} = RA;
453 let Inst{16-20} = RB;
455 let Inst{22-30} = xo;
459 class XOForm_3<bits<6> opcode, bits<9> xo, bit oe,
460 dag OL, string asmstr, list<dag> pattern>
461 : XOForm_1<opcode, xo, oe, OL, asmstr, pattern> {
466 class AForm_1<bits<6> opcode, bits<5> xo, dag OL, string asmstr>
467 : I<opcode, OL, asmstr> {
473 bit RC = 0; // set by isDOT
475 let Inst{6-10} = FRT;
476 let Inst{11-15} = FRA;
477 let Inst{16-20} = FRB;
478 let Inst{21-25} = FRC;
479 let Inst{26-30} = xo;
483 class AForm_2<bits<6> opcode, bits<5> xo, dag OL, string asmstr>
484 : AForm_1<opcode, xo, OL, asmstr> {
488 class AForm_3<bits<6> opcode, bits<5> xo, dag OL, string asmstr>
489 : AForm_1<opcode, xo, OL, asmstr> {
494 class MForm_1<bits<6> opcode, dag OL, string asmstr> : I<opcode, OL, asmstr> {
501 bit RC = 0; // set by isDOT
504 let Inst{11-15} = RA;
505 let Inst{16-20} = RB;
506 let Inst{21-25} = MB;
507 let Inst{26-30} = ME;
511 class MForm_2<bits<6> opcode, dag OL, string asmstr>
512 : MForm_1<opcode, OL, asmstr> {
516 class MDForm_1<bits<6> opcode, bits<3> xo, dag OL, string asmstr>
517 : I<opcode, OL, asmstr> {
523 bit RC = 0; // set by isDOT
526 let Inst{11-15} = RA;
527 let Inst{16-20} = SH{1-5};
528 let Inst{21-26} = MBE;
529 let Inst{27-29} = xo;
530 let Inst{30} = SH{0};
534 //===----------------------------------------------------------------------===//
536 class Pseudo<dag OL, string asmstr> : I<0, OL, asmstr> {