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
19 bit VMX = 0; // Default value, override with isVMX
22 let Namespace = "PPC";
23 let Inst{0-5} = opcode;
25 let AsmString = asmstr;
28 /// These fields correspond to the fields in PPCInstrInfo.h. Any changes to
29 /// these must be reflected there! See comments there for what these are.
30 bits<1> PPC970_First = 0;
31 bits<1> PPC970_Single = 0;
32 bits<1> PPC970_Cracked = 0;
33 bits<3> PPC970_Unit = 0;
36 class PPC970_DGroup_First { bits<1> PPC970_First = 1; }
37 class PPC970_DGroup_Single { bits<1> PPC970_Single = 1; }
38 class PPC970_DGroup_Cracked { bits<1> PPC970_Cracked = 1; }
39 class PPC970_MicroCode;
41 class PPC970_Unit_Pseudo { bits<3> PPC970_Unit = 0; }
42 class PPC970_Unit_FXU { bits<3> PPC970_Unit = 1; }
43 class PPC970_Unit_LSU { bits<3> PPC970_Unit = 2; }
44 class PPC970_Unit_FPU { bits<3> PPC970_Unit = 3; }
45 class PPC970_Unit_CRU { bits<3> PPC970_Unit = 4; }
46 class PPC970_Unit_VALU { bits<3> PPC970_Unit = 5; }
47 class PPC970_Unit_VPERM { bits<3> PPC970_Unit = 6; }
48 class PPC970_Unit_BRU { bits<3> PPC970_Unit = 7; }
52 class IForm<bits<6> opcode, bit aa, bit lk, dag OL, string asmstr,
53 InstrItinClass itin, list<dag> pattern>
54 : I<opcode, OL, asmstr, itin> {
55 let Pattern = pattern;
64 class BForm<bits<6> opcode, bit aa, bit lk, bits<5> bo, bits<2> bicode, dag OL,
65 string asmstr, InstrItinClass itin>
66 : I<opcode, OL, asmstr, itin> {
72 let Inst{14-15} = bicode;
79 class DForm_base<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
81 : I<opcode, OL, asmstr, itin> {
86 let Pattern = pattern;
93 class DForm_1<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
95 : I<opcode, OL, asmstr, itin> {
100 let Pattern = pattern;
107 class DForm_2<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
109 : DForm_base<opcode, OL, asmstr, itin, pattern>;
111 class DForm_2_r0<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
113 : I<opcode, OL, asmstr, itin> {
117 let Pattern = pattern;
124 // Currently we make the use/def reg distinction in ISel, not tablegen
125 class DForm_3<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
127 : DForm_1<opcode, OL, asmstr, itin, pattern>;
129 class DForm_4<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
131 : I<opcode, OL, asmstr, itin> {
136 let Pattern = pattern;
143 class DForm_4_zero<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
145 : DForm_1<opcode, OL, asmstr, itin, pattern> {
151 class DForm_5<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
152 : I<opcode, OL, asmstr, itin> {
161 let Inst{11-15} = RA;
165 class DForm_5_ext<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
166 : DForm_5<opcode, OL, asmstr, itin> {
170 class DForm_6<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
171 : DForm_5<opcode, OL, asmstr, itin>;
173 class DForm_6_ext<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
174 : DForm_6<opcode, OL, asmstr, itin> {
178 class DForm_8<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
180 : DForm_1<opcode, OL, asmstr, itin, pattern> {
183 class DForm_9<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
185 : DForm_1<opcode, OL, asmstr, itin, pattern> {
189 class DSForm_1<bits<6> opcode, bits<2> xo, dag OL, string asmstr,
190 InstrItinClass itin, list<dag> pattern>
191 : I<opcode, OL, asmstr, itin> {
196 let Pattern = pattern;
198 let Inst{6-10} = RST;
199 let Inst{11-15} = RA;
200 let Inst{16-29} = DS;
201 let Inst{30-31} = xo;
204 class DSForm_2<bits<6> opcode, bits<2> xo, dag OL, string asmstr,
205 InstrItinClass itin, list<dag> pattern>
206 : DSForm_1<opcode, xo, OL, asmstr, itin, pattern>;
209 class XForm_base_r3xo<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
210 InstrItinClass itin, list<dag> pattern>
211 : I<opcode, OL, asmstr, itin> {
216 let Pattern = pattern;
218 bit RC = 0; // set by isDOT
220 let Inst{6-10} = RST;
223 let Inst{21-30} = xo;
227 // This is the same as XForm_base_r3xo, but the first two operands are swapped
228 // when code is emitted.
229 class XForm_base_r3xo_swapped
230 <bits<6> opcode, bits<10> xo, dag OL, string asmstr,
232 : I<opcode, OL, asmstr, itin> {
237 bit RC = 0; // set by isDOT
239 let Inst{6-10} = RST;
242 let Inst{21-30} = xo;
247 class XForm_1<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_6<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_8<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
258 InstrItinClass itin, list<dag> pattern>
259 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern>;
261 class XForm_10<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
262 InstrItinClass itin, list<dag> pattern>
263 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
264 let Pattern = pattern;
267 class XForm_11<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
268 InstrItinClass itin, list<dag> pattern>
269 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
271 let Pattern = pattern;
274 class XForm_16<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
276 : I<opcode, OL, asmstr, itin> {
285 let Inst{11-15} = RA;
286 let Inst{16-20} = RB;
287 let Inst{21-30} = xo;
291 class XForm_16_ext<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
293 : XForm_16<opcode, xo, OL, asmstr, itin> {
297 class XForm_17<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
299 : I<opcode, OL, asmstr, itin> {
306 let Inst{11-15} = FRA;
307 let Inst{16-20} = FRB;
308 let Inst{21-30} = xo;
312 class XForm_25<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
313 InstrItinClass itin, list<dag> pattern>
314 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
317 class XForm_26<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
318 InstrItinClass itin, list<dag> pattern>
319 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
323 class XForm_28<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
324 InstrItinClass itin, list<dag> pattern>
325 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
328 // DSS_Form - Form X instruction, used for altivec dss* instructions.
329 class DSS_Form<bits<10> xo, dag OL, string asmstr,
330 InstrItinClass itin, list<dag> pattern>
331 : I<31, OL, asmstr, itin> {
337 let Pattern = pattern;
341 let Inst{9-10} = STRM;
344 let Inst{21-30} = xo;
349 class XLForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
351 : I<opcode, OL, asmstr, itin> {
360 let Inst{9-10} = CRDb;
361 let Inst{11-13} = CRA;
362 let Inst{14-15} = CRAb;
363 let Inst{16-18} = CRB;
364 let Inst{19-20} = CRBb;
365 let Inst{21-30} = xo;
369 class XLForm_2<bits<6> opcode, bits<10> xo, bit lk, dag OL, string asmstr,
370 InstrItinClass itin, list<dag> pattern>
371 : I<opcode, OL, asmstr, itin> {
376 let Pattern = pattern;
379 let Inst{11-15} = BI;
381 let Inst{19-20} = BH;
382 let Inst{21-30} = xo;
386 class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo, bits<5> bi, bit lk,
387 dag OL, string asmstr, InstrItinClass itin, list<dag> pattern>
388 : XLForm_2<opcode, xo, lk, OL, asmstr, itin, pattern> {
394 class XLForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
396 : I<opcode, OL, asmstr, itin> {
402 let Inst{11-13} = BFA;
405 let Inst{21-30} = xo;
410 class XFXForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
412 : I<opcode, OL, asmstr, itin> {
417 let Inst{11} = SPR{4};
418 let Inst{12} = SPR{3};
419 let Inst{13} = SPR{2};
420 let Inst{14} = SPR{1};
421 let Inst{15} = SPR{0};
422 let Inst{16} = SPR{9};
423 let Inst{17} = SPR{8};
424 let Inst{18} = SPR{7};
425 let Inst{19} = SPR{6};
426 let Inst{20} = SPR{5};
427 let Inst{21-30} = xo;
431 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
432 dag OL, string asmstr, InstrItinClass itin>
433 : XFXForm_1<opcode, xo, OL, asmstr, itin> {
437 class XFXForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
439 : I<opcode, OL, asmstr, itin> {
444 let Inst{21-30} = xo;
448 class XFXForm_5<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
450 : I<opcode, OL, asmstr, itin> {
456 let Inst{12-19} = FXM;
458 let Inst{21-30} = xo;
462 class XFXForm_5a<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
464 : I<opcode, OL, asmstr, itin> {
470 let Inst{12-19} = FXM;
472 let Inst{21-30} = xo;
476 class XFXForm_7<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
478 : XFXForm_1<opcode, xo, OL, asmstr, itin>;
480 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
481 dag OL, string asmstr, InstrItinClass itin>
482 : XFXForm_7<opcode, xo, OL, asmstr, itin> {
487 class XSForm_1<bits<6> opcode, bits<9> xo, dag OL, string asmstr,
489 : I<opcode, OL, asmstr, itin> {
494 bit RC = 0; // set by isDOT
498 let Inst{16-20} = SH{1-5};
499 let Inst{21-29} = xo;
500 let Inst{30} = SH{0};
505 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, dag OL, string asmstr,
506 InstrItinClass itin, list<dag> pattern>
507 : I<opcode, OL, asmstr, itin> {
512 let Pattern = pattern;
514 bit RC = 0; // set by isDOT
517 let Inst{11-15} = RA;
518 let Inst{16-20} = RB;
520 let Inst{22-30} = xo;
524 class XOForm_3<bits<6> opcode, bits<9> xo, bit oe,
525 dag OL, string asmstr, InstrItinClass itin, list<dag> pattern>
526 : XOForm_1<opcode, xo, oe, OL, asmstr, itin, pattern> {
531 class AForm_1<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
532 InstrItinClass itin, list<dag> pattern>
533 : I<opcode, OL, asmstr, itin> {
539 let Pattern = pattern;
541 bit RC = 0; // set by isDOT
543 let Inst{6-10} = FRT;
544 let Inst{11-15} = FRA;
545 let Inst{16-20} = FRB;
546 let Inst{21-25} = FRC;
547 let Inst{26-30} = xo;
551 class AForm_2<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
552 InstrItinClass itin, list<dag> pattern>
553 : AForm_1<opcode, xo, OL, asmstr, itin, pattern> {
557 class AForm_3<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
558 InstrItinClass itin, list<dag> pattern>
559 : AForm_1<opcode, xo, OL, asmstr, itin, pattern> {
564 class MForm_1<bits<6> opcode, dag OL, string asmstr,
565 InstrItinClass itin, list<dag> pattern>
566 : I<opcode, OL, asmstr, itin> {
573 let Pattern = pattern;
575 bit RC = 0; // set by isDOT
578 let Inst{11-15} = RA;
579 let Inst{16-20} = RB;
580 let Inst{21-25} = MB;
581 let Inst{26-30} = ME;
585 class MForm_2<bits<6> opcode, dag OL, string asmstr,
586 InstrItinClass itin, list<dag> pattern>
587 : MForm_1<opcode, OL, asmstr, itin, pattern> {
591 class MDForm_1<bits<6> opcode, bits<3> xo, dag OL, string asmstr,
592 InstrItinClass itin, list<dag> pattern>
593 : I<opcode, OL, asmstr, itin> {
599 let Pattern = pattern;
601 bit RC = 0; // set by isDOT
604 let Inst{11-15} = RA;
605 let Inst{16-20} = SH{1-5};
606 let Inst{21-26} = MBE;
607 let Inst{27-29} = xo;
608 let Inst{30} = SH{0};
616 // VAForm_1 - DACB ordering.
617 class VAForm_1<bits<6> xo, dag OL, string asmstr,
618 InstrItinClass itin, list<dag> pattern>
619 : I<4, OL, asmstr, itin> {
625 let Pattern = pattern;
628 let Inst{11-15} = VA;
629 let Inst{16-20} = VB;
630 let Inst{21-25} = VC;
631 let Inst{26-31} = xo;
634 // VAForm_1a - DABC ordering.
635 class VAForm_1a<bits<6> xo, dag OL, string asmstr,
636 InstrItinClass itin, list<dag> pattern>
637 : I<4, OL, asmstr, itin> {
643 let Pattern = pattern;
646 let Inst{11-15} = VA;
647 let Inst{16-20} = VB;
648 let Inst{21-25} = VC;
649 let Inst{26-31} = xo;
652 class VAForm_2<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;
666 let Inst{22-25} = SH;
667 let Inst{26-31} = xo;
671 class VXForm_1<bits<11> xo, dag OL, string asmstr,
672 InstrItinClass itin, list<dag> pattern>
673 : I<4, OL, asmstr, itin> {
678 let Pattern = pattern;
681 let Inst{11-15} = VA;
682 let Inst{16-20} = VB;
683 let Inst{21-31} = xo;
686 class VXForm_setzero<bits<11> xo, dag OL, string asmstr,
687 InstrItinClass itin, list<dag> pattern>
688 : VXForm_1<xo, OL, asmstr, itin, pattern> {
694 class VXForm_2<bits<11> xo, dag OL, string asmstr,
695 InstrItinClass itin, list<dag> pattern>
696 : I<4, OL, asmstr, itin> {
700 let Pattern = pattern;
704 let Inst{16-20} = VB;
705 let Inst{21-31} = xo;
708 class VXForm_3<bits<11> xo, dag OL, string asmstr,
709 InstrItinClass itin, list<dag> pattern>
710 : I<4, OL, asmstr, itin> {
714 let Pattern = pattern;
717 let Inst{11-15} = IMM;
719 let Inst{21-31} = xo;
722 /// VXForm_4 - VX instructions with "VD,0,0" register fields, like mfvscr.
723 class VXForm_4<bits<11> xo, dag OL, string asmstr,
724 InstrItinClass itin, list<dag> pattern>
725 : I<4, OL, asmstr, itin> {
728 let Pattern = pattern;
733 let Inst{21-31} = xo;
736 /// VXForm_5 - VX instructions with "0,0,VB" register fields, like mtvscr.
737 class VXForm_5<bits<11> xo, dag OL, string asmstr,
738 InstrItinClass itin, list<dag> pattern>
739 : I<4, OL, asmstr, itin> {
742 let Pattern = pattern;
746 let Inst{16-20} = VB;
747 let Inst{21-31} = xo;
751 class VXRForm_1<bits<10> xo, dag OL, string asmstr,
752 InstrItinClass itin, list<dag> pattern>
753 : I<4, OL, asmstr, itin> {
759 let Pattern = pattern;
762 let Inst{11-15} = VA;
763 let Inst{16-20} = VB;
765 let Inst{22-31} = xo;
768 //===----------------------------------------------------------------------===//
769 class Pseudo<dag OL, string asmstr, list<dag> pattern>
770 : I<0, OL, asmstr, NoItinerary> {
773 let Pattern = pattern;