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 //===----------------------------------------------------------------------===//
15 // PowerPC instruction formats
17 class I<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
21 bit PPC64 = 0; // Default value, override with isPPC64
22 bit VMX = 0; // Default value, override with isVMX
25 let Namespace = "PPC";
26 let Inst{0-5} = opcode;
28 let AsmString = asmstr;
31 /// These fields correspond to the fields in PPCInstrInfo.h. Any changes to
32 /// these must be reflected there! See comments there for what these are.
33 bits<1> PPC970_First = 0;
34 bits<1> PPC970_Single = 0;
35 bits<3> PPC970_Unit = 0;
38 class PPC970_DGroup_First { bits<1> PPC970_First = 1; }
39 class PPC970_DGroup_Single { bits<1> PPC970_Single = 1; }
40 class PPC970_MicroCode;
42 class PPC970_Unit_Pseudo { bits<3> PPC970_Unit = 0; }
43 class PPC970_Unit_FXU { bits<3> PPC970_Unit = 1; }
44 class PPC970_Unit_LSU { bits<3> PPC970_Unit = 2; }
45 class PPC970_Unit_FPU { bits<3> PPC970_Unit = 3; }
46 class PPC970_Unit_CRU { bits<3> PPC970_Unit = 4; }
47 class PPC970_Unit_VALU { bits<3> PPC970_Unit = 5; }
48 class PPC970_Unit_VPERM { bits<3> PPC970_Unit = 6; }
49 class PPC970_Unit_BRU { bits<3> PPC970_Unit = 7; }
53 class IForm<bits<6> opcode, bit aa, bit lk, dag OL, string asmstr,
54 InstrItinClass itin, list<dag> pattern>
55 : I<opcode, OL, asmstr, itin> {
56 let Pattern = pattern;
65 class BForm<bits<6> opcode, bit aa, bit lk, bits<5> bo, bits<2> bicode, dag OL,
66 string asmstr, InstrItinClass itin>
67 : I<opcode, OL, asmstr, itin> {
73 let Inst{14-15} = bicode;
80 class DForm_base<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
82 : I<opcode, OL, asmstr, itin> {
87 let Pattern = pattern;
94 class DForm_1<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
96 : I<opcode, OL, asmstr, itin> {
101 let Pattern = pattern;
108 class DForm_2<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
110 : DForm_base<opcode, OL, asmstr, itin, pattern>;
112 class DForm_2_r0<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
114 : I<opcode, OL, asmstr, itin> {
118 let Pattern = pattern;
125 // Currently we make the use/def reg distinction in ISel, not tablegen
126 class DForm_3<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
128 : DForm_1<opcode, OL, asmstr, itin, pattern>;
130 class DForm_4<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
132 : I<opcode, OL, asmstr, itin> {
137 let Pattern = pattern;
144 class DForm_4_zero<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
146 : DForm_1<opcode, OL, asmstr, itin, pattern> {
152 class DForm_5<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
153 : I<opcode, OL, asmstr, itin> {
162 let Inst{11-15} = RA;
166 class DForm_5_ext<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
167 : DForm_5<opcode, OL, asmstr, itin> {
171 class DForm_6<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
172 : DForm_5<opcode, OL, asmstr, itin>;
174 class DForm_6_ext<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
175 : DForm_6<opcode, OL, asmstr, itin> {
179 class DForm_8<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
181 : DForm_1<opcode, OL, asmstr, itin, pattern> {
184 class DForm_9<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
186 : DForm_1<opcode, OL, asmstr, itin, pattern> {
190 class DSForm_1<bits<6> opcode, bits<2> xo, dag OL, string asmstr,
191 InstrItinClass itin, list<dag> pattern>
192 : I<opcode, OL, asmstr, itin> {
197 let Pattern = pattern;
199 let Inst{6-10} = RST;
200 let Inst{11-15} = RA;
201 let Inst{16-29} = DS;
202 let Inst{30-31} = xo;
205 class DSForm_2<bits<6> opcode, bits<2> xo, dag OL, string asmstr,
206 InstrItinClass itin, list<dag> pattern>
207 : DSForm_1<opcode, xo, OL, asmstr, itin, pattern>;
210 class XForm_base_r3xo<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
211 InstrItinClass itin, list<dag> pattern>
212 : I<opcode, OL, asmstr, itin> {
217 let Pattern = pattern;
219 bit RC = 0; // set by isDOT
221 let Inst{6-10} = RST;
224 let Inst{21-30} = xo;
228 // This is the same as XForm_base_r3xo, but the first two operands are swapped
229 // when code is emitted.
230 class XForm_base_r3xo_swapped
231 <bits<6> opcode, bits<10> xo, dag OL, string asmstr,
233 : I<opcode, OL, asmstr, itin> {
238 bit RC = 0; // set by isDOT
240 let Inst{6-10} = RST;
243 let Inst{21-30} = xo;
248 class XForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
249 InstrItinClass itin, list<dag> pattern>
250 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern>;
252 class XForm_6<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
253 InstrItinClass itin, list<dag> pattern>
254 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
255 let Pattern = pattern;
258 class XForm_8<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
259 InstrItinClass itin, list<dag> pattern>
260 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern>;
262 class XForm_10<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
263 InstrItinClass itin, list<dag> pattern>
264 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
265 let Pattern = pattern;
268 class XForm_11<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
269 InstrItinClass itin, list<dag> pattern>
270 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
272 let Pattern = pattern;
275 class XForm_16<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
277 : I<opcode, OL, asmstr, itin> {
286 let Inst{11-15} = RA;
287 let Inst{16-20} = RB;
288 let Inst{21-30} = xo;
292 class XForm_16_ext<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
294 : XForm_16<opcode, xo, OL, asmstr, itin> {
298 class XForm_17<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
300 : I<opcode, OL, asmstr, itin> {
307 let Inst{11-15} = FRA;
308 let Inst{16-20} = FRB;
309 let Inst{21-30} = xo;
313 class XForm_25<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 class XForm_26<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
319 InstrItinClass itin, list<dag> pattern>
320 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
324 class XForm_28<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
325 InstrItinClass itin, list<dag> pattern>
326 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
330 class XLForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
332 : I<opcode, OL, asmstr, itin> {
341 let Inst{9-10} = CRDb;
342 let Inst{11-13} = CRA;
343 let Inst{14-15} = CRAb;
344 let Inst{16-18} = CRB;
345 let Inst{19-20} = CRBb;
346 let Inst{21-30} = xo;
350 class XLForm_2<bits<6> opcode, bits<10> xo, bit lk, dag OL, string asmstr,
351 InstrItinClass itin, list<dag> pattern>
352 : I<opcode, OL, asmstr, itin> {
357 let Pattern = pattern;
360 let Inst{11-15} = BI;
362 let Inst{19-20} = BH;
363 let Inst{21-30} = xo;
367 class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo, bits<5> bi, bit lk,
368 dag OL, string asmstr, InstrItinClass itin, list<dag> pattern>
369 : XLForm_2<opcode, xo, lk, OL, asmstr, itin, pattern> {
375 class XLForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
377 : I<opcode, OL, asmstr, itin> {
383 let Inst{11-13} = BFA;
386 let Inst{21-30} = xo;
391 class XFXForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
393 : I<opcode, OL, asmstr, itin> {
398 let Inst{11} = SPR{4};
399 let Inst{12} = SPR{3};
400 let Inst{13} = SPR{2};
401 let Inst{14} = SPR{1};
402 let Inst{15} = SPR{0};
403 let Inst{16} = SPR{9};
404 let Inst{17} = SPR{8};
405 let Inst{18} = SPR{7};
406 let Inst{19} = SPR{6};
407 let Inst{20} = SPR{5};
408 let Inst{21-30} = xo;
412 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
413 dag OL, string asmstr, InstrItinClass itin>
414 : XFXForm_1<opcode, xo, OL, asmstr, itin> {
418 class XFXForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
420 : I<opcode, OL, asmstr, itin> {
425 let Inst{21-30} = xo;
429 class XFXForm_5<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
431 : I<opcode, OL, asmstr, itin> {
437 let Inst{12-19} = FXM;
439 let Inst{21-30} = xo;
443 class XFXForm_5a<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
445 : I<opcode, OL, asmstr, itin> {
451 let Inst{12-19} = FXM;
453 let Inst{21-30} = xo;
457 class XFXForm_7<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
459 : XFXForm_1<opcode, xo, OL, asmstr, itin>;
461 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
462 dag OL, string asmstr, InstrItinClass itin>
463 : XFXForm_7<opcode, xo, OL, asmstr, itin> {
468 class XSForm_1<bits<6> opcode, bits<9> xo, dag OL, string asmstr,
470 : I<opcode, OL, asmstr, itin> {
475 bit RC = 0; // set by isDOT
479 let Inst{16-20} = SH{1-5};
480 let Inst{21-29} = xo;
481 let Inst{30} = SH{0};
486 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, dag OL, string asmstr,
487 InstrItinClass itin, list<dag> pattern>
488 : I<opcode, OL, asmstr, itin> {
493 let Pattern = pattern;
495 bit RC = 0; // set by isDOT
498 let Inst{11-15} = RA;
499 let Inst{16-20} = RB;
501 let Inst{22-30} = xo;
505 class XOForm_3<bits<6> opcode, bits<9> xo, bit oe,
506 dag OL, string asmstr, InstrItinClass itin, list<dag> pattern>
507 : XOForm_1<opcode, xo, oe, OL, asmstr, itin, pattern> {
512 class AForm_1<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
513 InstrItinClass itin, list<dag> pattern>
514 : I<opcode, OL, asmstr, itin> {
520 let Pattern = pattern;
522 bit RC = 0; // set by isDOT
524 let Inst{6-10} = FRT;
525 let Inst{11-15} = FRA;
526 let Inst{16-20} = FRB;
527 let Inst{21-25} = FRC;
528 let Inst{26-30} = xo;
532 class AForm_2<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
533 InstrItinClass itin, list<dag> pattern>
534 : AForm_1<opcode, xo, OL, asmstr, itin, pattern> {
538 class AForm_3<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
539 InstrItinClass itin, list<dag> pattern>
540 : AForm_1<opcode, xo, OL, asmstr, itin, pattern> {
545 class MForm_1<bits<6> opcode, dag OL, string asmstr,
546 InstrItinClass itin, list<dag> pattern>
547 : I<opcode, OL, asmstr, itin> {
554 let Pattern = pattern;
556 bit RC = 0; // set by isDOT
559 let Inst{11-15} = RA;
560 let Inst{16-20} = RB;
561 let Inst{21-25} = MB;
562 let Inst{26-30} = ME;
566 class MForm_2<bits<6> opcode, dag OL, string asmstr,
567 InstrItinClass itin, list<dag> pattern>
568 : MForm_1<opcode, OL, asmstr, itin, pattern> {
572 class MDForm_1<bits<6> opcode, bits<3> xo, dag OL, string asmstr,
573 InstrItinClass itin, list<dag> pattern>
574 : I<opcode, OL, asmstr, itin> {
580 let Pattern = pattern;
582 bit RC = 0; // set by isDOT
585 let Inst{11-15} = RA;
586 let Inst{16-20} = SH{1-5};
587 let Inst{21-26} = MBE;
588 let Inst{27-29} = xo;
589 let Inst{30} = SH{0};
594 class VAForm_1<bits<6> xo, dag OL, string asmstr,
595 InstrItinClass itin, list<dag> pattern>
596 : I<4, OL, asmstr, itin> {
602 let Pattern = pattern;
605 let Inst{11-15} = VA;
606 let Inst{16-20} = VB;
607 let Inst{21-25} = VC;
608 let Inst{26-31} = xo;
612 class VXForm_1<bits<11> xo, dag OL, string asmstr,
613 InstrItinClass itin, list<dag> pattern>
614 : I<4, OL, asmstr, itin> {
619 let Pattern = pattern;
622 let Inst{11-15} = VA;
623 let Inst{16-20} = VB;
624 let Inst{21-31} = xo;
627 class VXForm_setzero<bits<11> xo, dag OL, string asmstr,
628 InstrItinClass itin, list<dag> pattern>
629 : VXForm_1<xo, OL, asmstr, itin, pattern> {
635 class VXForm_2<bits<11> xo, dag OL, string asmstr,
636 InstrItinClass itin, list<dag> pattern>
637 : I<4, OL, asmstr, itin> {
641 let Pattern = pattern;
645 let Inst{16-20} = VB;
646 let Inst{21-31} = xo;
650 class VXRForm_1<bits<10> xo, bit rc, dag OL, string asmstr,
651 InstrItinClass itin, list<dag> pattern>
652 : I<4, OL, asmstr, itin> {
657 let Pattern = pattern;
660 let Inst{11-15} = VA;
661 let Inst{16-20} = VB;
663 let Inst{22-31} = xo;
666 //===----------------------------------------------------------------------===//
667 class Pseudo<dag OL, string asmstr, list<dag> pattern>
668 : I<0, OL, asmstr, NoItinerary> {
671 let Pattern = pattern;