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;
194 class DSForm_2<bits<6> opcode, bits<2> xo, dag OL, string asmstr,
195 InstrItinClass itin, list<dag> pattern>
196 : DSForm_1<opcode, xo, OL, asmstr, itin, pattern>;
199 class XForm_base_r3xo<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
200 InstrItinClass itin, list<dag> pattern>
201 : I<opcode, OL, asmstr, itin> {
206 let Pattern = pattern;
208 bit RC = 0; // set by isDOT
210 let Inst{6-10} = RST;
213 let Inst{21-30} = xo;
217 // This is the same as XForm_base_r3xo, but the first two operands are swapped
218 // when code is emitted.
219 class XForm_base_r3xo_swapped
220 <bits<6> opcode, bits<10> xo, dag OL, string asmstr,
222 : I<opcode, OL, asmstr, itin> {
227 bit RC = 0; // set by isDOT
229 let Inst{6-10} = RST;
232 let Inst{21-30} = xo;
237 class XForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
238 InstrItinClass itin, list<dag> pattern>
239 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern>;
241 class XForm_6<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
242 InstrItinClass itin, list<dag> pattern>
243 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
244 let Pattern = pattern;
247 class XForm_8<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
248 InstrItinClass itin, list<dag> pattern>
249 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern>;
251 class XForm_10<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
252 InstrItinClass itin, list<dag> pattern>
253 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
254 let Pattern = pattern;
257 class XForm_11<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
258 InstrItinClass itin, list<dag> pattern>
259 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
261 let Pattern = pattern;
264 class XForm_16<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
266 : I<opcode, OL, asmstr, itin> {
275 let Inst{11-15} = RA;
276 let Inst{16-20} = RB;
277 let Inst{21-30} = xo;
281 class XForm_16_ext<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
283 : XForm_16<opcode, xo, OL, asmstr, itin> {
287 class XForm_17<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
289 : I<opcode, OL, asmstr, itin> {
296 let Inst{11-15} = FRA;
297 let Inst{16-20} = FRB;
298 let Inst{21-30} = xo;
302 class XForm_25<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
303 InstrItinClass itin, list<dag> pattern>
304 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
307 class XForm_26<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
308 InstrItinClass itin, list<dag> pattern>
309 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
313 class XForm_28<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
314 InstrItinClass itin, list<dag> pattern>
315 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
318 // DCB_Form - Form X instruction, used for dcb* instructions.
319 class DCB_Form<bits<10> xo, bits<5> immfield, dag OL, string asmstr,
320 InstrItinClass itin, list<dag> pattern>
321 : I<31, OL, asmstr, itin> {
325 let Pattern = pattern;
327 let Inst{6-10} = immfield;
330 let Inst{21-30} = xo;
335 // DSS_Form - Form X instruction, used for altivec dss* instructions.
336 class DSS_Form<bits<10> xo, dag OL, string asmstr,
337 InstrItinClass itin, list<dag> pattern>
338 : I<31, OL, asmstr, itin> {
344 let Pattern = pattern;
348 let Inst{9-10} = STRM;
351 let Inst{21-30} = xo;
356 class XLForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
358 : I<opcode, OL, asmstr, itin> {
367 let Inst{9-10} = CRDb;
368 let Inst{11-13} = CRA;
369 let Inst{14-15} = CRAb;
370 let Inst{16-18} = CRB;
371 let Inst{19-20} = CRBb;
372 let Inst{21-30} = xo;
376 class XLForm_2<bits<6> opcode, bits<10> xo, bit lk, dag OL, string asmstr,
377 InstrItinClass itin, list<dag> pattern>
378 : I<opcode, OL, asmstr, itin> {
383 let Pattern = pattern;
386 let Inst{11-15} = BI;
388 let Inst{19-20} = BH;
389 let Inst{21-30} = xo;
393 class XLForm_2_br<bits<6> opcode, bits<10> xo, bit lk,
394 dag OL, string asmstr, InstrItinClass itin, list<dag> pattern>
395 : XLForm_2<opcode, xo, lk, OL, asmstr, itin, pattern> {
396 bits<7> BIBO; // 2 bits of BI and 5 bits of BO.
400 let BI{0-1} = BIBO{0-1};
406 class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo, bits<5> bi, bit lk,
407 dag OL, string asmstr, InstrItinClass itin, list<dag> pattern>
408 : XLForm_2<opcode, xo, lk, OL, asmstr, itin, pattern> {
414 class XLForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
416 : I<opcode, OL, asmstr, itin> {
422 let Inst{11-13} = BFA;
425 let Inst{21-30} = xo;
430 class XFXForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
432 : I<opcode, OL, asmstr, itin> {
437 let Inst{11} = SPR{4};
438 let Inst{12} = SPR{3};
439 let Inst{13} = SPR{2};
440 let Inst{14} = SPR{1};
441 let Inst{15} = SPR{0};
442 let Inst{16} = SPR{9};
443 let Inst{17} = SPR{8};
444 let Inst{18} = SPR{7};
445 let Inst{19} = SPR{6};
446 let Inst{20} = SPR{5};
447 let Inst{21-30} = xo;
451 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
452 dag OL, string asmstr, InstrItinClass itin>
453 : XFXForm_1<opcode, xo, OL, asmstr, itin> {
457 class XFXForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
459 : I<opcode, OL, asmstr, itin> {
464 let Inst{21-30} = xo;
468 class XFXForm_5<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
470 : I<opcode, OL, asmstr, itin> {
476 let Inst{12-19} = FXM;
478 let Inst{21-30} = xo;
482 class XFXForm_5a<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
484 : I<opcode, OL, asmstr, itin> {
490 let Inst{12-19} = FXM;
492 let Inst{21-30} = xo;
496 class XFXForm_7<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
498 : XFXForm_1<opcode, xo, OL, asmstr, itin>;
500 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
501 dag OL, string asmstr, InstrItinClass itin>
502 : XFXForm_7<opcode, xo, OL, asmstr, itin> {
507 class XSForm_1<bits<6> opcode, bits<9> xo, dag OL, string asmstr,
508 InstrItinClass itin, list<dag> pattern>
509 : I<opcode, OL, asmstr, itin> {
514 bit RC = 0; // set by isDOT
515 let Pattern = pattern;
519 let Inst{16-20} = SH{1-5};
520 let Inst{21-29} = xo;
521 let Inst{30} = SH{0};
526 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, dag OL, string asmstr,
527 InstrItinClass itin, list<dag> pattern>
528 : I<opcode, OL, asmstr, itin> {
533 let Pattern = pattern;
535 bit RC = 0; // set by isDOT
538 let Inst{11-15} = RA;
539 let Inst{16-20} = RB;
541 let Inst{22-30} = xo;
545 class XOForm_3<bits<6> opcode, bits<9> xo, bit oe,
546 dag OL, string asmstr, InstrItinClass itin, list<dag> pattern>
547 : XOForm_1<opcode, xo, oe, OL, asmstr, itin, pattern> {
552 class AForm_1<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
553 InstrItinClass itin, list<dag> pattern>
554 : I<opcode, OL, asmstr, itin> {
560 let Pattern = pattern;
562 bit RC = 0; // set by isDOT
564 let Inst{6-10} = FRT;
565 let Inst{11-15} = FRA;
566 let Inst{16-20} = FRB;
567 let Inst{21-25} = FRC;
568 let Inst{26-30} = xo;
572 class AForm_2<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
573 InstrItinClass itin, list<dag> pattern>
574 : AForm_1<opcode, xo, OL, asmstr, itin, pattern> {
578 class AForm_3<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
579 InstrItinClass itin, list<dag> pattern>
580 : AForm_1<opcode, xo, OL, asmstr, itin, pattern> {
585 class MForm_1<bits<6> opcode, dag OL, string asmstr,
586 InstrItinClass itin, list<dag> pattern>
587 : I<opcode, OL, asmstr, itin> {
594 let Pattern = pattern;
596 bit RC = 0; // set by isDOT
599 let Inst{11-15} = RA;
600 let Inst{16-20} = RB;
601 let Inst{21-25} = MB;
602 let Inst{26-30} = ME;
606 class MForm_2<bits<6> opcode, dag OL, string asmstr,
607 InstrItinClass itin, list<dag> pattern>
608 : MForm_1<opcode, OL, asmstr, itin, pattern> {
612 class MDForm_1<bits<6> opcode, bits<3> xo, dag OL, string asmstr,
613 InstrItinClass itin, list<dag> pattern>
614 : I<opcode, OL, asmstr, itin> {
620 let Pattern = pattern;
622 bit RC = 0; // set by isDOT
625 let Inst{11-15} = RA;
626 let Inst{16-20} = { SH{4}, SH{3}, SH{2}, SH{1}, SH{0} };
627 let Inst{21-26} = { MBE{4}, MBE{3}, MBE{2}, MBE{1}, MBE{0}, MBE{5} };
628 let Inst{27-29} = xo;
629 let Inst{30} = SH{5};
637 // VAForm_1 - DACB ordering.
638 class VAForm_1<bits<6> xo, dag OL, string asmstr,
639 InstrItinClass itin, list<dag> pattern>
640 : I<4, OL, asmstr, itin> {
646 let Pattern = pattern;
649 let Inst{11-15} = VA;
650 let Inst{16-20} = VB;
651 let Inst{21-25} = VC;
652 let Inst{26-31} = xo;
655 // VAForm_1a - DABC ordering.
656 class VAForm_1a<bits<6> xo, dag OL, string asmstr,
657 InstrItinClass itin, list<dag> pattern>
658 : I<4, OL, asmstr, itin> {
664 let Pattern = pattern;
667 let Inst{11-15} = VA;
668 let Inst{16-20} = VB;
669 let Inst{21-25} = VC;
670 let Inst{26-31} = xo;
673 class VAForm_2<bits<6> xo, dag OL, string asmstr,
674 InstrItinClass itin, list<dag> pattern>
675 : I<4, OL, asmstr, itin> {
681 let Pattern = pattern;
684 let Inst{11-15} = VA;
685 let Inst{16-20} = VB;
687 let Inst{22-25} = SH;
688 let Inst{26-31} = xo;
692 class VXForm_1<bits<11> xo, dag OL, string asmstr,
693 InstrItinClass itin, list<dag> pattern>
694 : I<4, OL, asmstr, itin> {
699 let Pattern = pattern;
702 let Inst{11-15} = VA;
703 let Inst{16-20} = VB;
704 let Inst{21-31} = xo;
707 class VXForm_setzero<bits<11> xo, dag OL, string asmstr,
708 InstrItinClass itin, list<dag> pattern>
709 : VXForm_1<xo, OL, asmstr, itin, pattern> {
715 class VXForm_2<bits<11> xo, dag OL, string asmstr,
716 InstrItinClass itin, list<dag> pattern>
717 : I<4, OL, asmstr, itin> {
721 let Pattern = pattern;
725 let Inst{16-20} = VB;
726 let Inst{21-31} = xo;
729 class VXForm_3<bits<11> xo, dag OL, string asmstr,
730 InstrItinClass itin, list<dag> pattern>
731 : I<4, OL, asmstr, itin> {
735 let Pattern = pattern;
738 let Inst{11-15} = IMM;
740 let Inst{21-31} = xo;
743 /// VXForm_4 - VX instructions with "VD,0,0" register fields, like mfvscr.
744 class VXForm_4<bits<11> xo, dag OL, string asmstr,
745 InstrItinClass itin, list<dag> pattern>
746 : I<4, OL, asmstr, itin> {
749 let Pattern = pattern;
754 let Inst{21-31} = xo;
757 /// VXForm_5 - VX instructions with "0,0,VB" register fields, like mtvscr.
758 class VXForm_5<bits<11> xo, dag OL, string asmstr,
759 InstrItinClass itin, list<dag> pattern>
760 : I<4, OL, asmstr, itin> {
763 let Pattern = pattern;
767 let Inst{16-20} = VB;
768 let Inst{21-31} = xo;
772 class VXRForm_1<bits<10> xo, dag OL, string asmstr,
773 InstrItinClass itin, list<dag> pattern>
774 : I<4, OL, asmstr, itin> {
780 let Pattern = pattern;
783 let Inst{11-15} = VA;
784 let Inst{16-20} = VB;
786 let Inst{22-31} = xo;
789 //===----------------------------------------------------------------------===//
790 class Pseudo<dag OL, string asmstr, list<dag> pattern>
791 : I<0, OL, asmstr, NoItinerary> {
793 let Pattern = pattern;