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 class Format<bits<5> val> {
17 def Pseudo: Format<0>;
20 def Simm16 : Format<3>;
21 def PCRelimm24 : Format<5>;
22 def Imm24 : Format<6>;
24 def PCRelimm14 : Format<8>;
25 def Imm14 : Format<9>;
26 def Imm2 : Format<10>;
28 def Imm3 : Format<12>;
29 def Imm1 : Format<13>;
31 def Imm4 : Format<15>;
32 def Imm8 : Format<16>;
33 def Disimm16 : Format<17>;
34 def Disimm14 : Format<18>;
37 def Imm15 : Format<21>;
39 def Imm6 : Format<23>;
41 //===----------------------------------------------------------------------===//
43 // PowerPC instruction formats
45 class I<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
59 let Namespace = "PPC";
60 let Inst{0-5} = opcode;
62 let AsmString = asmstr;
66 class IForm<bits<6> opcode, bit aa, bit lk, bit ppc64, bit vmx,
67 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
71 let Arg0Type = Imm24.Value;
83 class BForm<bits<6> opcode, bit aa, bit lk, bit ppc64, bit vmx,
84 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
90 let Arg0Type = Imm5.Value;
91 let Arg1Type = Imm5.Value;
92 let Arg2Type = PCRelimm14.Value;
103 class BForm_ext<bits<6> opcode, bit aa, bit lk, bits<5> bo, bits<5> bi,
104 bit ppc64, bit vmx, dag OL, string asmstr>
105 : BForm<opcode, aa, lk, ppc64, vmx, OL, asmstr> {
107 let Arg2Type = Imm5.Value;
108 let Arg1Type = PCRelimm14.Value;
115 class DForm_base<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
116 : I<opcode, ppc64, vmx, OL, asmstr> {
122 let Arg0Type = Gpr.Value;
123 let Arg1Type = Gpr.Value;
124 let Arg2Type = Simm16.Value;
133 class DForm_1<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
134 : DForm_base<opcode, ppc64, vmx, OL, asmstr> {
135 let Arg1Type = Disimm16.Value;
136 let Arg2Type = Gpr.Value;
139 class DForm_2<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
140 : DForm_base<opcode, ppc64, vmx, OL, asmstr>;
142 class DForm_2_r0<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
143 : I<opcode, ppc64, vmx, OL, asmstr> {
148 let Arg0Type = Gpr.Value;
149 let Arg1Type = Simm16.Value;
159 // Currently we make the use/def reg distinction in ISel, not tablegen
160 class DForm_3<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
161 : DForm_1<opcode, ppc64, vmx, OL, asmstr>;
163 class DForm_4<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
164 : DForm_base<opcode, ppc64, vmx, OL, asmstr>;
166 class DForm_4_zero<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
167 : DForm_1<opcode, ppc64, vmx, OL, asmstr> {
177 class DForm_5<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
178 : I<opcode, ppc64, vmx, OL, asmstr> {
185 let Arg0Type = Imm3.Value;
186 let Arg1Type = Imm1.Value;
187 let Arg2Type = Gpr.Value;
188 let Arg3Type = Simm16.Value;
194 let Inst{11-15} = RA;
198 class DForm_5_ext<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
199 : DForm_5<opcode, ppc64, vmx, OL, asmstr> {
202 let Arg0Type = Imm3.Value;
203 let Arg1Type = Gpr.Value;
204 let Arg2Type = Simm16.Value;
208 class DForm_6<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
209 : DForm_5<opcode, ppc64, vmx, OL, asmstr>;
211 class DForm_6_ext<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
212 : DForm_6<opcode, ppc64, vmx, OL, asmstr> {
215 let Arg0Type = Imm3.Value;
216 let Arg1Type = Gpr.Value;
217 let Arg2Type = Simm16.Value;
221 class DForm_8<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
222 : DForm_1<opcode, ppc64, vmx, OL, asmstr> {
223 let Arg0Type = Fpr.Value;
226 class DForm_9<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
227 : DForm_1<opcode, ppc64, vmx, OL, asmstr> {
228 let Arg0Type = Fpr.Value;
232 class DSForm_1<bits<6> opcode, bits<2> xo, bit ppc64, bit vmx,
233 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
239 let Arg0Type = Gpr.Value;
240 let Arg1Type = Disimm14.Value;
241 let Arg2Type = Gpr.Value;
245 let Inst{6-10} = RST;
246 let Inst{11-15} = RA;
247 let Inst{16-29} = DS;
248 let Inst{30-31} = xo;
251 class DSForm_2<bits<6> opcode, bits<2> xo, bit ppc64, bit vmx,
252 dag OL, string asmstr>
253 : DSForm_1<opcode, xo, ppc64, vmx, OL, asmstr>;
256 class XForm_base_r3xo<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
257 dag OL, string asmstr>
258 : I<opcode, ppc64, vmx, OL, asmstr> {
264 let Arg0Type = Gpr.Value;
265 let Arg1Type = Gpr.Value;
266 let Arg2Type = Gpr.Value;
270 let Inst{6-10} = RST;
273 let Inst{21-30} = xo;
278 class XForm_1<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
279 dag OL, string asmstr>
280 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr>;
282 class XForm_5<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
283 dag OL, string asmstr>
284 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
292 class XForm_6<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
293 dag OL, string asmstr>
294 : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr>;
296 class XForm_8<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
297 dag OL, string asmstr>
298 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr>;
300 class XForm_10<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
301 dag OL, string asmstr>
302 : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
303 let Arg2Type = Imm5.Value;
306 class XForm_11<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
307 dag OL, string asmstr>
308 : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
314 class XForm_16<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
315 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
322 let Arg0Type = Imm3.Value;
323 let Arg1Type = Imm1.Value;
324 let Arg2Type = Gpr.Value;
325 let Arg3Type = Gpr.Value;
331 let Inst{11-15} = RA;
332 let Inst{16-20} = RB;
333 let Inst{21-30} = xo;
337 class XForm_16_ext<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
338 dag OL, string asmstr>
339 : XForm_16<opcode, xo, ppc64, vmx, OL, asmstr> {
341 let Arg1Type = Gpr.Value;
342 let Arg2Type = Gpr.Value;
347 class XForm_17<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
348 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
354 let Arg0Type = Imm3.Value;
355 let Arg1Type = Fpr.Value;
356 let Arg2Type = Fpr.Value;
362 let Inst{11-15} = FRA;
363 let Inst{16-20} = FRB;
364 let Inst{21-30} = xo;
368 class XForm_25<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
369 dag OL, string asmstr>
370 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
371 let Arg0Type = Fpr.Value;
372 let Arg1Type = Gpr0.Value;
375 class XForm_26<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
376 dag OL, string asmstr>
377 : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
379 let Arg0Type = Fpr.Value;
380 let Arg1Type = Fpr.Value;
385 class XForm_28<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
386 dag OL, string asmstr>
387 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
388 let Arg0Type = Fpr.Value;
389 let Arg1Type = Gpr0.Value;
393 class XLForm_1<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
394 dag OL, string asmstr>
395 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
396 let Arg0Type = Imm5.Value;
397 let Arg1Type = Imm5.Value;
398 let Arg2Type = Imm5.Value;
401 class XLForm_2<bits<6> opcode, bits<10> xo, bit lk, bit ppc64, bit vmx,
402 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
408 let Arg0Type = Imm5.Value;
409 let Arg1Type = Imm5.Value;
410 let Arg2Type = Imm2.Value;
415 let Inst{11-15} = BI;
417 let Inst{19-20} = BH;
418 let Inst{21-30} = xo;
422 class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo,
423 bits<5> bi, bit lk, bit ppc64, bit vmx,
424 dag OL, string asmstr>
425 : XLForm_2<opcode, xo, lk, ppc64, vmx, OL, asmstr> {
436 class XFXForm_1<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
437 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
442 let Arg0Type = Imm5.Value;
443 let Arg1Type = Gpr.Value;
449 let Inst{11-20} = SPR;
450 let Inst{21-30} = xo;
454 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr, bit ppc64,
455 bit vmx, dag OL, string asmstr>
456 : XFXForm_1<opcode, xo, ppc64, vmx, OL, asmstr> {
458 let Arg0Type = Gpr.Value;
463 class XFXForm_7<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
464 dag OL, string asmstr>
465 : XFXForm_1<opcode, xo, ppc64, vmx, OL, asmstr>;
467 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
468 bit ppc64, bit vmx, dag OL, string asmstr>
469 : XFXForm_7<opcode, xo, ppc64, vmx, OL, asmstr> {
471 let Arg0Type = Gpr.Value;
477 class XSForm_1<bits<6> opcode, bits<9> xo, bit rc, bit ppc64, bit vmx,
478 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
484 let Arg0Type = Gpr.Value;
485 let Arg1Type = Gpr.Value;
486 let Arg2Type = Imm6.Value;
492 let Inst{16-20} = SH{1-5};
493 let Inst{21-29} = xo;
494 let Inst{30} = SH{0};
499 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, bit rc, bit ppc64, bit vmx,
500 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
506 let Arg0Type = Gpr.Value;
507 let Arg1Type = Gpr.Value;
508 let Arg2Type = Gpr.Value;
513 let Inst{11-15} = RA;
514 let Inst{16-20} = RB;
516 let Inst{22-30} = xo;
520 class XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, bit rc, bit ppc64, bit vmx,
521 dag OL, string asmstr>
522 : XOForm_1<opcode, xo, oe, rc, ppc64, vmx, OL, asmstr> {
523 let Inst{11-15} = RB;
524 let Inst{16-20} = RA;
527 class XOForm_3<bits<6> opcode, bits<9> xo, bit oe, bit rc, bit ppc64, bit vmx,
528 dag OL, string asmstr>
529 : XOForm_1<opcode, xo, oe, rc, ppc64, vmx, OL, asmstr> {
535 class AForm_1<bits<6> opcode, bits<5> xo, bit rc, bit ppc64, bit vmx,
536 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
543 let Arg0Type = Fpr.Value;
544 let Arg1Type = Fpr.Value;
545 let Arg2Type = Fpr.Value;
546 let Arg3Type = Fpr.Value;
549 let Inst{6-10} = FRT;
550 let Inst{11-15} = FRA;
551 let Inst{16-20} = FRB;
552 let Inst{21-25} = FRC;
553 let Inst{26-30} = xo;
557 class AForm_2<bits<6> opcode, bits<5> xo, bit rc, bit ppc64, bit vmx, dag OL,
559 : AForm_1<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
565 class AForm_3<bits<6> opcode, bits<5> xo, bit rc, bit ppc64, bit vmx, dag OL,
567 : AForm_1<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
574 class MForm_1<bits<6> opcode, bit rc, bit ppc64, bit vmx,
575 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
583 let Arg0Type = Gpr.Value;
584 let Arg1Type = Gpr.Value;
585 let Arg2Type = Gpr.Value;
586 let Arg3Type = Imm5.Value;
587 let Arg4Type = Imm5.Value;
590 let Inst{11-15} = RA;
591 let Inst{16-20} = RB;
592 let Inst{21-25} = MB;
593 let Inst{26-30} = ME;
597 class MForm_2<bits<6> opcode, bit rc, bit ppc64, bit vmx,
598 dag OL, string asmstr>
599 : MForm_1<opcode, rc, ppc64, vmx, OL, asmstr> {
600 let Arg2Type = Imm5.Value;
604 class MDForm_1<bits<6> opcode, bits<3> xo, bit rc, bit ppc64, bit vmx,
605 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
612 let Arg0Type = Gpr.Value;
613 let Arg1Type = Gpr.Value;
614 let Arg2Type = Imm6.Value;
615 let Arg3Type = Imm6.Value;
619 let Inst{11-15} = RA;
620 let Inst{16-20} = SH{1-5};
621 let Inst{21-26} = MBE;
622 let Inst{27-29} = xo;
623 let Inst{30} = SH{0};
627 //===----------------------------------------------------------------------===//
629 class Pseudo<dag OL, string asmstr> : I<0, 0, 0, OL, asmstr> {
634 let Arg0Type = Pseudo.Value;
635 let Arg1Type = Pseudo.Value;
636 let Arg2Type = Pseudo.Value;
637 let Arg3Type = Pseudo.Value;