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 //===----------------------------------------------------------------------===//
10 //===----------------------------------------------------------------------===//
12 // PowerPC instruction formats
14 class I<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
18 bit PPC64 = 0; // Default value, override with isPPC64
21 let Namespace = "PPC";
22 let Inst{0-5} = opcode;
24 let AsmString = asmstr;
27 /// These fields correspond to the fields in PPCInstrInfo.h. Any changes to
28 /// these must be reflected there! See comments there for what these are.
29 bits<1> PPC970_First = 0;
30 bits<1> PPC970_Single = 0;
31 bits<1> PPC970_Cracked = 0;
32 bits<3> PPC970_Unit = 0;
35 class PPC970_DGroup_First { bits<1> PPC970_First = 1; }
36 class PPC970_DGroup_Single { bits<1> PPC970_Single = 1; }
37 class PPC970_DGroup_Cracked { bits<1> PPC970_Cracked = 1; }
38 class PPC970_MicroCode;
40 class PPC970_Unit_Pseudo { bits<3> PPC970_Unit = 0; }
41 class PPC970_Unit_FXU { bits<3> PPC970_Unit = 1; }
42 class PPC970_Unit_LSU { bits<3> PPC970_Unit = 2; }
43 class PPC970_Unit_FPU { bits<3> PPC970_Unit = 3; }
44 class PPC970_Unit_CRU { bits<3> PPC970_Unit = 4; }
45 class PPC970_Unit_VALU { bits<3> PPC970_Unit = 5; }
46 class PPC970_Unit_VPERM { bits<3> PPC970_Unit = 6; }
47 class PPC970_Unit_BRU { bits<3> PPC970_Unit = 7; }
51 class IForm<bits<6> opcode, bit aa, bit lk, dag OL, string asmstr,
52 InstrItinClass itin, list<dag> pattern>
53 : I<opcode, OL, asmstr, itin> {
54 let Pattern = pattern;
63 class BForm<bits<6> opcode, bit aa, bit lk, bits<5> bo, bits<2> bicode, dag OL,
64 string asmstr, InstrItinClass itin>
65 : I<opcode, OL, asmstr, itin> {
71 let Inst{14-15} = bicode;
78 class DForm_base<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
80 : I<opcode, OL, asmstr, itin> {
85 let Pattern = pattern;
92 class DForm_1<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
94 : I<opcode, OL, asmstr, itin> {
99 let Pattern = pattern;
106 class DForm_2<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
108 : DForm_base<opcode, OL, asmstr, itin, pattern>;
110 class DForm_2_r0<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
112 : I<opcode, OL, asmstr, itin> {
116 let Pattern = pattern;
123 // Currently we make the use/def reg distinction in ISel, not tablegen
124 class DForm_3<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
126 : DForm_1<opcode, OL, asmstr, itin, pattern>;
128 class DForm_4<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
130 : I<opcode, OL, asmstr, itin> {
135 let Pattern = pattern;
142 class DForm_4_zero<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
144 : DForm_1<opcode, OL, asmstr, itin, pattern> {
150 class DForm_5<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
151 : I<opcode, OL, asmstr, itin> {
160 let Inst{11-15} = RA;
164 class DForm_5_ext<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
165 : DForm_5<opcode, OL, asmstr, itin> {
169 class DForm_6<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
170 : DForm_5<opcode, OL, asmstr, itin>;
172 class DForm_6_ext<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
173 : DForm_6<opcode, OL, asmstr, itin> {
179 class DSForm_1<bits<6> opcode, bits<2> xo, dag OL, string asmstr,
180 InstrItinClass itin, list<dag> pattern>
181 : I<opcode, OL, asmstr, itin> {
186 let Pattern = pattern;
188 let Inst{6-10} = RST;
189 let Inst{11-15} = RA;
190 let Inst{16-29} = DS;
191 let Inst{30-31} = xo;
195 class XForm_base_r3xo<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
196 InstrItinClass itin, list<dag> pattern>
197 : I<opcode, OL, asmstr, itin> {
202 let Pattern = pattern;
204 bit RC = 0; // set by isDOT
206 let Inst{6-10} = RST;
209 let Inst{21-30} = xo;
213 // This is the same as XForm_base_r3xo, but the first two operands are swapped
214 // when code is emitted.
215 class XForm_base_r3xo_swapped
216 <bits<6> opcode, bits<10> xo, dag OL, string asmstr,
218 : I<opcode, OL, asmstr, itin> {
223 bit RC = 0; // set by isDOT
225 let Inst{6-10} = RST;
228 let Inst{21-30} = xo;
233 class XForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
234 InstrItinClass itin, list<dag> pattern>
235 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern>;
237 class XForm_6<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
238 InstrItinClass itin, list<dag> pattern>
239 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
240 let Pattern = pattern;
243 class XForm_8<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
244 InstrItinClass itin, list<dag> pattern>
245 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern>;
247 class XForm_10<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
248 InstrItinClass itin, list<dag> pattern>
249 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
250 let Pattern = pattern;
253 class XForm_11<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
254 InstrItinClass itin, list<dag> pattern>
255 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
257 let Pattern = pattern;
260 class XForm_16<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
262 : I<opcode, OL, asmstr, itin> {
271 let Inst{11-15} = RA;
272 let Inst{16-20} = RB;
273 let Inst{21-30} = xo;
277 class XForm_16_ext<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
279 : XForm_16<opcode, xo, OL, asmstr, itin> {
283 class XForm_17<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
285 : I<opcode, OL, asmstr, itin> {
292 let Inst{11-15} = FRA;
293 let Inst{16-20} = FRB;
294 let Inst{21-30} = xo;
298 class XForm_25<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
299 InstrItinClass itin, list<dag> pattern>
300 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
303 class XForm_26<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
304 InstrItinClass itin, list<dag> pattern>
305 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
309 class XForm_28<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
310 InstrItinClass itin, list<dag> pattern>
311 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
314 // DCB_Form - Form X instruction, used for dcb* instructions.
315 class DCB_Form<bits<10> xo, bits<5> immfield, dag OL, string asmstr,
316 InstrItinClass itin, list<dag> pattern>
317 : I<31, OL, asmstr, itin> {
321 let Pattern = pattern;
323 let Inst{6-10} = immfield;
326 let Inst{21-30} = xo;
331 // DSS_Form - Form X instruction, used for altivec dss* instructions.
332 class DSS_Form<bits<10> xo, dag OL, string asmstr,
333 InstrItinClass itin, list<dag> pattern>
334 : I<31, OL, asmstr, itin> {
340 let Pattern = pattern;
344 let Inst{9-10} = STRM;
347 let Inst{21-30} = xo;
352 class XLForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
354 : I<opcode, OL, asmstr, itin> {
363 let Inst{9-10} = CRDb;
364 let Inst{11-13} = CRA;
365 let Inst{14-15} = CRAb;
366 let Inst{16-18} = CRB;
367 let Inst{19-20} = CRBb;
368 let Inst{21-30} = xo;
372 class XLForm_2<bits<6> opcode, bits<10> xo, bit lk, dag OL, string asmstr,
373 InstrItinClass itin, list<dag> pattern>
374 : I<opcode, OL, asmstr, itin> {
379 let Pattern = pattern;
382 let Inst{11-15} = BI;
384 let Inst{19-20} = BH;
385 let Inst{21-30} = xo;
389 class XLForm_2_br<bits<6> opcode, bits<10> xo, bit lk,
390 dag OL, string asmstr, InstrItinClass itin, list<dag> pattern>
391 : XLForm_2<opcode, xo, lk, OL, asmstr, itin, pattern> {
392 bits<7> BIBO; // 2 bits of BI and 5 bits of BO.
396 let BI{0-1} = BIBO{0-1};
402 class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo, bits<5> bi, bit lk,
403 dag OL, string asmstr, InstrItinClass itin, list<dag> pattern>
404 : XLForm_2<opcode, xo, lk, OL, asmstr, itin, pattern> {
410 class XLForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
412 : I<opcode, OL, asmstr, itin> {
418 let Inst{11-13} = BFA;
421 let Inst{21-30} = xo;
426 class XFXForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
428 : I<opcode, OL, asmstr, itin> {
433 let Inst{11} = SPR{4};
434 let Inst{12} = SPR{3};
435 let Inst{13} = SPR{2};
436 let Inst{14} = SPR{1};
437 let Inst{15} = SPR{0};
438 let Inst{16} = SPR{9};
439 let Inst{17} = SPR{8};
440 let Inst{18} = SPR{7};
441 let Inst{19} = SPR{6};
442 let Inst{20} = SPR{5};
443 let Inst{21-30} = xo;
447 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
448 dag OL, string asmstr, InstrItinClass itin>
449 : XFXForm_1<opcode, xo, OL, asmstr, itin> {
453 class XFXForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
455 : I<opcode, OL, asmstr, itin> {
460 let Inst{21-30} = xo;
464 class XFXForm_5<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
466 : I<opcode, OL, asmstr, itin> {
472 let Inst{12-19} = FXM;
474 let Inst{21-30} = xo;
478 class XFXForm_5a<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
480 : I<opcode, OL, asmstr, itin> {
486 let Inst{12-19} = FXM;
488 let Inst{21-30} = xo;
492 class XFXForm_7<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
494 : XFXForm_1<opcode, xo, OL, asmstr, itin>;
496 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
497 dag OL, string asmstr, InstrItinClass itin>
498 : XFXForm_7<opcode, xo, OL, asmstr, itin> {
503 class XSForm_1<bits<6> opcode, bits<9> xo, dag OL, string asmstr,
504 InstrItinClass itin, list<dag> pattern>
505 : I<opcode, OL, asmstr, itin> {
510 bit RC = 0; // set by isDOT
511 let Pattern = pattern;
515 let Inst{16-20} = SH{1-5};
516 let Inst{21-29} = xo;
517 let Inst{30} = SH{0};
522 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, dag OL, string asmstr,
523 InstrItinClass itin, list<dag> pattern>
524 : I<opcode, OL, asmstr, itin> {
529 let Pattern = pattern;
531 bit RC = 0; // set by isDOT
534 let Inst{11-15} = RA;
535 let Inst{16-20} = RB;
537 let Inst{22-30} = xo;
541 class XOForm_3<bits<6> opcode, bits<9> xo, bit oe,
542 dag OL, string asmstr, InstrItinClass itin, list<dag> pattern>
543 : XOForm_1<opcode, xo, oe, OL, asmstr, itin, pattern> {
548 class AForm_1<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
549 InstrItinClass itin, list<dag> pattern>
550 : I<opcode, OL, asmstr, itin> {
556 let Pattern = pattern;
558 bit RC = 0; // set by isDOT
560 let Inst{6-10} = FRT;
561 let Inst{11-15} = FRA;
562 let Inst{16-20} = FRB;
563 let Inst{21-25} = FRC;
564 let Inst{26-30} = xo;
568 class AForm_2<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
569 InstrItinClass itin, list<dag> pattern>
570 : AForm_1<opcode, xo, OL, asmstr, itin, pattern> {
574 class AForm_3<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
575 InstrItinClass itin, list<dag> pattern>
576 : AForm_1<opcode, xo, OL, asmstr, itin, pattern> {
581 class MForm_1<bits<6> opcode, dag OL, string asmstr,
582 InstrItinClass itin, list<dag> pattern>
583 : I<opcode, OL, asmstr, itin> {
590 let Pattern = pattern;
592 bit RC = 0; // set by isDOT
595 let Inst{11-15} = RA;
596 let Inst{16-20} = RB;
597 let Inst{21-25} = MB;
598 let Inst{26-30} = ME;
602 class MForm_2<bits<6> opcode, dag OL, string asmstr,
603 InstrItinClass itin, list<dag> pattern>
604 : MForm_1<opcode, OL, asmstr, itin, pattern> {
608 class MDForm_1<bits<6> opcode, bits<3> xo, dag OL, string asmstr,
609 InstrItinClass itin, list<dag> pattern>
610 : I<opcode, OL, asmstr, itin> {
616 let Pattern = pattern;
618 bit RC = 0; // set by isDOT
621 let Inst{11-15} = RA;
622 let Inst{16-20} = { SH{4}, SH{3}, SH{2}, SH{1}, SH{0} };
623 let Inst{21-26} = { MBE{4}, MBE{3}, MBE{2}, MBE{1}, MBE{0}, MBE{5} };
624 let Inst{27-29} = xo;
625 let Inst{30} = SH{5};
633 // VAForm_1 - DACB ordering.
634 class VAForm_1<bits<6> xo, dag OL, string asmstr,
635 InstrItinClass itin, list<dag> pattern>
636 : I<4, OL, asmstr, itin> {
642 let Pattern = pattern;
645 let Inst{11-15} = VA;
646 let Inst{16-20} = VB;
647 let Inst{21-25} = VC;
648 let Inst{26-31} = xo;
651 // VAForm_1a - DABC ordering.
652 class VAForm_1a<bits<6> xo, dag OL, string asmstr,
653 InstrItinClass itin, list<dag> pattern>
654 : I<4, OL, asmstr, itin> {
660 let Pattern = pattern;
663 let Inst{11-15} = VA;
664 let Inst{16-20} = VB;
665 let Inst{21-25} = VC;
666 let Inst{26-31} = xo;
669 class VAForm_2<bits<6> xo, dag OL, string asmstr,
670 InstrItinClass itin, list<dag> pattern>
671 : I<4, OL, asmstr, itin> {
677 let Pattern = pattern;
680 let Inst{11-15} = VA;
681 let Inst{16-20} = VB;
683 let Inst{22-25} = SH;
684 let Inst{26-31} = xo;
688 class VXForm_1<bits<11> xo, dag OL, string asmstr,
689 InstrItinClass itin, list<dag> pattern>
690 : I<4, OL, asmstr, itin> {
695 let Pattern = pattern;
698 let Inst{11-15} = VA;
699 let Inst{16-20} = VB;
700 let Inst{21-31} = xo;
703 class VXForm_setzero<bits<11> xo, dag OL, string asmstr,
704 InstrItinClass itin, list<dag> pattern>
705 : VXForm_1<xo, OL, asmstr, itin, pattern> {
711 class VXForm_2<bits<11> xo, dag OL, string asmstr,
712 InstrItinClass itin, list<dag> pattern>
713 : I<4, OL, asmstr, itin> {
717 let Pattern = pattern;
721 let Inst{16-20} = VB;
722 let Inst{21-31} = xo;
725 class VXForm_3<bits<11> xo, dag OL, string asmstr,
726 InstrItinClass itin, list<dag> pattern>
727 : I<4, OL, asmstr, itin> {
731 let Pattern = pattern;
734 let Inst{11-15} = IMM;
736 let Inst{21-31} = xo;
739 /// VXForm_4 - VX instructions with "VD,0,0" register fields, like mfvscr.
740 class VXForm_4<bits<11> xo, dag OL, string asmstr,
741 InstrItinClass itin, list<dag> pattern>
742 : I<4, OL, asmstr, itin> {
745 let Pattern = pattern;
750 let Inst{21-31} = xo;
753 /// VXForm_5 - VX instructions with "0,0,VB" register fields, like mtvscr.
754 class VXForm_5<bits<11> xo, dag OL, string asmstr,
755 InstrItinClass itin, list<dag> pattern>
756 : I<4, OL, asmstr, itin> {
759 let Pattern = pattern;
763 let Inst{16-20} = VB;
764 let Inst{21-31} = xo;
768 class VXRForm_1<bits<10> xo, dag OL, string asmstr,
769 InstrItinClass itin, list<dag> pattern>
770 : I<4, OL, asmstr, itin> {
776 let Pattern = pattern;
779 let Inst{11-15} = VA;
780 let Inst{16-20} = VB;
782 let Inst{22-31} = xo;
785 //===----------------------------------------------------------------------===//
786 class Pseudo<dag OL, string asmstr, list<dag> pattern>
787 : I<0, OL, asmstr, NoItinerary> {
789 let Pattern = pattern;