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;
33 class IForm<bits<6> opcode, bit aa, bit lk, dag OL, string asmstr,
34 InstrItinClass itin, list<dag> pattern>
35 : I<opcode, OL, asmstr, itin> {
36 let Pattern = pattern;
45 class BForm<bits<6> opcode, bit aa, bit lk, bits<5> bo, bits<2> bicode, dag OL,
46 string asmstr, InstrItinClass itin>
47 : I<opcode, OL, asmstr, itin> {
53 let Inst{14-15} = bicode;
60 class DForm_base<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
62 : I<opcode, OL, asmstr, itin> {
67 let Pattern = pattern;
74 class DForm_1<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
76 : I<opcode, OL, asmstr, itin> {
81 let Pattern = pattern;
88 class DForm_2<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
90 : DForm_base<opcode, OL, asmstr, itin, pattern>;
92 class DForm_2_r0<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
94 : I<opcode, OL, asmstr, itin> {
98 let Pattern = pattern;
105 // Currently we make the use/def reg distinction in ISel, not tablegen
106 class DForm_3<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
108 : DForm_1<opcode, OL, asmstr, itin, pattern>;
110 class DForm_4<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
112 : I<opcode, OL, asmstr, itin> {
117 let Pattern = pattern;
124 class DForm_4_zero<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
126 : DForm_1<opcode, OL, asmstr, itin, pattern> {
132 class DForm_5<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
133 : I<opcode, OL, asmstr, itin> {
142 let Inst{11-15} = RA;
146 class DForm_5_ext<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
147 : DForm_5<opcode, OL, asmstr, itin> {
151 class DForm_6<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
152 : DForm_5<opcode, OL, asmstr, itin>;
154 class DForm_6_ext<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
155 : DForm_6<opcode, OL, asmstr, itin> {
159 class DForm_8<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
161 : DForm_1<opcode, OL, asmstr, itin, pattern> {
164 class DForm_9<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
166 : DForm_1<opcode, OL, asmstr, itin, pattern> {
170 class DSForm_1<bits<6> opcode, bits<2> xo, dag OL, string asmstr,
171 InstrItinClass itin, list<dag> pattern>
172 : I<opcode, OL, asmstr, itin> {
177 let Pattern = pattern;
179 let Inst{6-10} = RST;
180 let Inst{11-15} = RA;
181 let Inst{16-29} = DS;
182 let Inst{30-31} = xo;
185 class DSForm_2<bits<6> opcode, bits<2> xo, dag OL, string asmstr,
186 InstrItinClass itin, list<dag> pattern>
187 : DSForm_1<opcode, xo, OL, asmstr, itin, pattern>;
190 class XForm_base_r3xo<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
191 InstrItinClass itin, list<dag> pattern>
192 : I<opcode, OL, asmstr, itin> {
197 let Pattern = pattern;
199 bit RC = 0; // set by isDOT
201 let Inst{6-10} = RST;
204 let Inst{21-30} = xo;
208 // This is the same as XForm_base_r3xo, but the first two operands are swapped
209 // when code is emitted.
210 class XForm_base_r3xo_swapped
211 <bits<6> opcode, bits<10> xo, dag OL, string asmstr,
213 : I<opcode, OL, asmstr, itin> {
218 bit RC = 0; // set by isDOT
220 let Inst{6-10} = RST;
223 let Inst{21-30} = xo;
228 class XForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
229 InstrItinClass itin, list<dag> pattern>
230 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern>;
232 class XForm_6<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
233 InstrItinClass itin, list<dag> pattern>
234 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
235 let Pattern = pattern;
238 class XForm_8<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
239 InstrItinClass itin, list<dag> pattern>
240 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern>;
242 class XForm_10<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
243 InstrItinClass itin, list<dag> pattern>
244 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
245 let Pattern = pattern;
248 class XForm_11<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
249 InstrItinClass itin, list<dag> pattern>
250 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
252 let Pattern = pattern;
255 class XForm_16<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
257 : I<opcode, OL, asmstr, itin> {
266 let Inst{11-15} = RA;
267 let Inst{16-20} = RB;
268 let Inst{21-30} = xo;
272 class XForm_16_ext<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
274 : XForm_16<opcode, xo, OL, asmstr, itin> {
278 class XForm_17<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
280 : I<opcode, OL, asmstr, itin> {
287 let Inst{11-15} = FRA;
288 let Inst{16-20} = FRB;
289 let Inst{21-30} = xo;
293 class XForm_25<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
294 InstrItinClass itin, list<dag> pattern>
295 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
298 class XForm_26<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> {
304 class XForm_28<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
305 InstrItinClass itin, list<dag> pattern>
306 : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
310 class XLForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
312 : I<opcode, OL, asmstr, itin> {
321 let Inst{9-10} = CRDb;
322 let Inst{11-13} = CRA;
323 let Inst{14-15} = CRAb;
324 let Inst{16-18} = CRB;
325 let Inst{19-20} = CRBb;
326 let Inst{21-30} = xo;
330 class XLForm_2<bits<6> opcode, bits<10> xo, bit lk, dag OL, string asmstr,
332 : I<opcode, OL, asmstr, itin> {
338 let Inst{11-15} = BI;
340 let Inst{19-20} = BH;
341 let Inst{21-30} = xo;
345 class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo, bits<5> bi, bit lk,
346 dag OL, string asmstr, InstrItinClass itin>
347 : XLForm_2<opcode, xo, lk, OL, asmstr, itin> {
353 class XLForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
355 : I<opcode, OL, asmstr, itin> {
361 let Inst{11-13} = BFA;
364 let Inst{21-30} = xo;
369 class XFXForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
371 : I<opcode, OL, asmstr, itin> {
376 let Inst{11} = SPR{4};
377 let Inst{12} = SPR{3};
378 let Inst{13} = SPR{2};
379 let Inst{14} = SPR{1};
380 let Inst{15} = SPR{0};
381 let Inst{16} = SPR{9};
382 let Inst{17} = SPR{8};
383 let Inst{18} = SPR{7};
384 let Inst{19} = SPR{6};
385 let Inst{20} = SPR{5};
386 let Inst{21-30} = xo;
390 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
391 dag OL, string asmstr, InstrItinClass itin>
392 : XFXForm_1<opcode, xo, OL, asmstr, itin> {
396 class XFXForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
398 : I<opcode, OL, asmstr, itin> {
403 let Inst{21-30} = xo;
407 class XFXForm_5<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
409 : I<opcode, OL, asmstr, itin> {
415 let Inst{12-19} = FXM;
417 let Inst{21-30} = xo;
421 class XFXForm_5a<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
423 : I<opcode, OL, asmstr, itin> {
429 let Inst{12-19} = FXM;
431 let Inst{21-30} = xo;
435 class XFXForm_7<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
437 : XFXForm_1<opcode, xo, OL, asmstr, itin>;
439 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
440 dag OL, string asmstr, InstrItinClass itin>
441 : XFXForm_7<opcode, xo, OL, asmstr, itin> {
446 class XSForm_1<bits<6> opcode, bits<9> xo, dag OL, string asmstr,
448 : I<opcode, OL, asmstr, itin> {
453 bit RC = 0; // set by isDOT
457 let Inst{16-20} = SH{1-5};
458 let Inst{21-29} = xo;
459 let Inst{30} = SH{0};
464 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, dag OL, string asmstr,
465 InstrItinClass itin, list<dag> pattern>
466 : I<opcode, OL, asmstr, itin> {
471 let Pattern = pattern;
473 bit RC = 0; // set by isDOT
476 let Inst{11-15} = RA;
477 let Inst{16-20} = RB;
479 let Inst{22-30} = xo;
483 class XOForm_3<bits<6> opcode, bits<9> xo, bit oe,
484 dag OL, string asmstr, InstrItinClass itin, list<dag> pattern>
485 : XOForm_1<opcode, xo, oe, OL, asmstr, itin, pattern> {
490 class AForm_1<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
491 InstrItinClass itin, list<dag> pattern>
492 : I<opcode, OL, asmstr, itin> {
498 let Pattern = pattern;
500 bit RC = 0; // set by isDOT
502 let Inst{6-10} = FRT;
503 let Inst{11-15} = FRA;
504 let Inst{16-20} = FRB;
505 let Inst{21-25} = FRC;
506 let Inst{26-30} = xo;
510 class AForm_2<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
511 InstrItinClass itin, list<dag> pattern>
512 : AForm_1<opcode, xo, OL, asmstr, itin, pattern> {
516 class AForm_3<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
517 InstrItinClass itin, list<dag> pattern>
518 : AForm_1<opcode, xo, OL, asmstr, itin, pattern> {
523 class MForm_1<bits<6> opcode, dag OL, string asmstr,
524 InstrItinClass itin, list<dag> pattern>
525 : I<opcode, OL, asmstr, itin> {
532 let Pattern = pattern;
534 bit RC = 0; // set by isDOT
537 let Inst{11-15} = RA;
538 let Inst{16-20} = RB;
539 let Inst{21-25} = MB;
540 let Inst{26-30} = ME;
544 class MForm_2<bits<6> opcode, dag OL, string asmstr,
545 InstrItinClass itin, list<dag> pattern>
546 : MForm_1<opcode, OL, asmstr, itin, pattern> {
550 class MDForm_1<bits<6> opcode, bits<3> xo, dag OL, string asmstr,
551 InstrItinClass itin, list<dag> pattern>
552 : I<opcode, OL, asmstr, itin> {
558 let Pattern = pattern;
560 bit RC = 0; // set by isDOT
563 let Inst{11-15} = RA;
564 let Inst{16-20} = SH{1-5};
565 let Inst{21-26} = MBE;
566 let Inst{27-29} = xo;
567 let Inst{30} = SH{0};
572 class VAForm_1<bits<6> xo, dag OL, string asmstr,
573 InstrItinClass itin, list<dag> pattern>
574 : I<4, OL, asmstr, itin> {
580 let Pattern = pattern;
583 let Inst{11-15} = VA;
584 let Inst{16-20} = VB;
585 let Inst{21-25} = VC;
586 let Inst{26-31} = xo;
590 class VXForm_1<bits<11> xo, dag OL, string asmstr,
591 InstrItinClass itin, list<dag> pattern>
592 : I<4, OL, asmstr, itin> {
597 let Pattern = pattern;
600 let Inst{11-15} = VA;
601 let Inst{16-20} = VB;
602 let Inst{21-31} = xo;
605 class VXForm_setzero<bits<11> xo, dag OL, string asmstr,
606 InstrItinClass itin, list<dag> pattern>
607 : VXForm_1<xo, OL, asmstr, itin, pattern> {
613 class VXForm_2<bits<11> xo, dag OL, string asmstr,
614 InstrItinClass itin, list<dag> pattern>
615 : I<4, OL, asmstr, itin> {
619 let Pattern = pattern;
623 let Inst{16-20} = VB;
624 let Inst{21-31} = xo;
628 class VXRForm_1<bits<10> xo, bit rc, dag OL, string asmstr,
629 InstrItinClass itin, list<dag> pattern>
630 : I<4, OL, asmstr, itin> {
635 let Pattern = pattern;
638 let Inst{11-15} = VA;
639 let Inst{16-20} = VB;
641 let Inst{22-31} = xo;
644 //===----------------------------------------------------------------------===//
645 def NoItin : InstrItinClass;
646 class Pseudo<dag OL, string asmstr, list<dag> pattern>
647 : I<0, OL, asmstr, NoItin> {
650 let Pattern = pattern;