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 : I<opcode, ppc64, vmx, OL, asmstr> {
140 let Arg0Type = Gpr.Value;
141 let Arg1Type = Disimm16.Value;
142 let Arg2Type = Gpr.Value;
151 class DForm_2<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
152 : DForm_base<opcode, ppc64, vmx, OL, asmstr>;
154 class DForm_2_r0<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
155 : I<opcode, ppc64, vmx, OL, asmstr> {
160 let Arg0Type = Gpr.Value;
161 let Arg1Type = Simm16.Value;
171 // Currently we make the use/def reg distinction in ISel, not tablegen
172 class DForm_3<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
173 : DForm_1<opcode, ppc64, vmx, OL, asmstr>;
175 class DForm_4<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
176 : DForm_base<opcode, ppc64, vmx, OL, asmstr>;
178 class DForm_4_zero<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
179 : DForm_1<opcode, ppc64, vmx, OL, asmstr> {
189 class DForm_5<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
190 : I<opcode, ppc64, vmx, OL, asmstr> {
197 let Arg0Type = Imm3.Value;
198 let Arg1Type = Imm1.Value;
199 let Arg2Type = Gpr.Value;
200 let Arg3Type = Simm16.Value;
206 let Inst{11-15} = RA;
210 class DForm_5_ext<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
211 : DForm_5<opcode, ppc64, vmx, OL, asmstr> {
214 let Arg0Type = Imm3.Value;
215 let Arg1Type = Gpr.Value;
216 let Arg2Type = Simm16.Value;
220 class DForm_6<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
221 : DForm_5<opcode, ppc64, vmx, OL, asmstr>;
223 class DForm_6_ext<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
224 : DForm_6<opcode, ppc64, vmx, OL, asmstr> {
227 let Arg0Type = Imm3.Value;
228 let Arg1Type = Gpr.Value;
229 let Arg2Type = Simm16.Value;
233 class DForm_8<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
234 : DForm_1<opcode, ppc64, vmx, OL, asmstr> {
235 let Arg0Type = Fpr.Value;
238 class DForm_9<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
239 : DForm_1<opcode, ppc64, vmx, OL, asmstr> {
240 let Arg0Type = Fpr.Value;
244 class DSForm_1<bits<6> opcode, bits<2> xo, bit ppc64, bit vmx,
245 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
251 let Arg0Type = Gpr.Value;
252 let Arg1Type = Disimm14.Value;
253 let Arg2Type = Gpr.Value;
257 let Inst{6-10} = RST;
258 let Inst{11-15} = RA;
259 let Inst{16-29} = DS;
260 let Inst{30-31} = xo;
263 class DSForm_2<bits<6> opcode, bits<2> xo, bit ppc64, bit vmx,
264 dag OL, string asmstr>
265 : DSForm_1<opcode, xo, ppc64, vmx, OL, asmstr>;
268 class XForm_base_r3xo<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
269 dag OL, string asmstr>
270 : I<opcode, ppc64, vmx, OL, asmstr> {
276 let Arg0Type = Gpr.Value;
277 let Arg1Type = Gpr.Value;
278 let Arg2Type = Gpr.Value;
282 let Inst{6-10} = RST;
285 let Inst{21-30} = xo;
290 class XForm_1<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
291 dag OL, string asmstr>
292 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr>;
294 class XForm_5<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
295 dag OL, string asmstr>
296 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
304 class XForm_6<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
305 dag OL, string asmstr>
306 : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr>;
308 class XForm_8<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
309 dag OL, string asmstr>
310 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr>;
312 class XForm_10<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
313 dag OL, string asmstr>
314 : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
315 let Arg2Type = Imm5.Value;
318 class XForm_11<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
319 dag OL, string asmstr>
320 : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
326 class XForm_16<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
327 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
334 let Arg0Type = Imm3.Value;
335 let Arg1Type = Imm1.Value;
336 let Arg2Type = Gpr.Value;
337 let Arg3Type = Gpr.Value;
343 let Inst{11-15} = RA;
344 let Inst{16-20} = RB;
345 let Inst{21-30} = xo;
349 class XForm_16_ext<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
350 dag OL, string asmstr>
351 : XForm_16<opcode, xo, ppc64, vmx, OL, asmstr> {
353 let Arg1Type = Gpr.Value;
354 let Arg2Type = Gpr.Value;
359 class XForm_17<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
360 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
366 let Arg0Type = Imm3.Value;
367 let Arg1Type = Fpr.Value;
368 let Arg2Type = Fpr.Value;
374 let Inst{11-15} = FRA;
375 let Inst{16-20} = FRB;
376 let Inst{21-30} = xo;
380 class XForm_25<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
381 dag OL, string asmstr>
382 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
383 let Arg0Type = Fpr.Value;
384 let Arg1Type = Gpr0.Value;
387 class XForm_26<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
388 dag OL, string asmstr>
389 : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
391 let Arg0Type = Fpr.Value;
392 let Arg1Type = Fpr.Value;
397 class XForm_28<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
398 dag OL, string asmstr>
399 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
400 let Arg0Type = Fpr.Value;
401 let Arg1Type = Gpr0.Value;
405 class XLForm_1<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
406 dag OL, string asmstr>
407 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
408 let Arg0Type = Imm5.Value;
409 let Arg1Type = Imm5.Value;
410 let Arg2Type = Imm5.Value;
413 class XLForm_2<bits<6> opcode, bits<10> xo, bit lk, bit ppc64, bit vmx,
414 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
420 let Arg0Type = Imm5.Value;
421 let Arg1Type = Imm5.Value;
422 let Arg2Type = Imm2.Value;
427 let Inst{11-15} = BI;
429 let Inst{19-20} = BH;
430 let Inst{21-30} = xo;
434 class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo,
435 bits<5> bi, bit lk, bit ppc64, bit vmx,
436 dag OL, string asmstr>
437 : XLForm_2<opcode, xo, lk, ppc64, vmx, OL, asmstr> {
448 class XFXForm_1<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
449 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
454 let Arg0Type = Imm5.Value;
455 let Arg1Type = Gpr.Value;
461 let Inst{11-20} = SPR;
462 let Inst{21-30} = xo;
466 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr, bit ppc64,
467 bit vmx, dag OL, string asmstr>
468 : XFXForm_1<opcode, xo, ppc64, vmx, OL, asmstr> {
470 let Arg0Type = Gpr.Value;
475 class XFXForm_7<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
476 dag OL, string asmstr>
477 : XFXForm_1<opcode, xo, ppc64, vmx, OL, asmstr>;
479 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
480 bit ppc64, bit vmx, dag OL, string asmstr>
481 : XFXForm_7<opcode, xo, ppc64, vmx, OL, asmstr> {
483 let Arg0Type = Gpr.Value;
489 class XSForm_1<bits<6> opcode, bits<9> xo, bit rc, bit ppc64, bit vmx,
490 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
496 let Arg0Type = Gpr.Value;
497 let Arg1Type = Gpr.Value;
498 let Arg2Type = Imm6.Value;
504 let Inst{16-20} = SH{1-5};
505 let Inst{21-29} = xo;
506 let Inst{30} = SH{0};
511 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, bit rc, bit ppc64, bit vmx,
512 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
518 let Arg0Type = Gpr.Value;
519 let Arg1Type = Gpr.Value;
520 let Arg2Type = Gpr.Value;
525 let Inst{11-15} = RA;
526 let Inst{16-20} = RB;
528 let Inst{22-30} = xo;
532 class XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, bit rc, bit ppc64, bit vmx,
533 dag OL, string asmstr>
534 : XOForm_1<opcode, xo, oe, rc, ppc64, vmx, OL, asmstr> {
535 let Inst{11-15} = RB;
536 let Inst{16-20} = RA;
539 class XOForm_3<bits<6> opcode, bits<9> xo, bit oe, bit rc, bit ppc64, bit vmx,
540 dag OL, string asmstr>
541 : XOForm_1<opcode, xo, oe, rc, ppc64, vmx, OL, asmstr> {
547 class AForm_1<bits<6> opcode, bits<5> xo, bit rc, bit ppc64, bit vmx,
548 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
555 let Arg0Type = Fpr.Value;
556 let Arg1Type = Fpr.Value;
557 let Arg2Type = Fpr.Value;
558 let Arg3Type = Fpr.Value;
561 let Inst{6-10} = FRT;
562 let Inst{11-15} = FRA;
563 let Inst{16-20} = FRB;
564 let Inst{21-25} = FRC;
565 let Inst{26-30} = xo;
569 class AForm_2<bits<6> opcode, bits<5> xo, bit rc, bit ppc64, bit vmx, dag OL,
571 : AForm_1<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
577 class AForm_3<bits<6> opcode, bits<5> xo, bit rc, bit ppc64, bit vmx, dag OL,
579 : AForm_1<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
586 class MForm_1<bits<6> opcode, bit rc, bit ppc64, bit vmx,
587 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
595 let Arg0Type = Gpr.Value;
596 let Arg1Type = Gpr.Value;
597 let Arg2Type = Gpr.Value;
598 let Arg3Type = Imm5.Value;
599 let Arg4Type = Imm5.Value;
602 let Inst{11-15} = RA;
603 let Inst{16-20} = RB;
604 let Inst{21-25} = MB;
605 let Inst{26-30} = ME;
609 class MForm_2<bits<6> opcode, bit rc, bit ppc64, bit vmx,
610 dag OL, string asmstr>
611 : MForm_1<opcode, rc, ppc64, vmx, OL, asmstr> {
612 let Arg2Type = Imm5.Value;
616 class MDForm_1<bits<6> opcode, bits<3> xo, bit rc, bit ppc64, bit vmx,
617 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
624 let Arg0Type = Gpr.Value;
625 let Arg1Type = Gpr.Value;
626 let Arg2Type = Imm6.Value;
627 let Arg3Type = Imm6.Value;
631 let Inst{11-15} = RA;
632 let Inst{16-20} = SH{1-5};
633 let Inst{21-26} = MBE;
634 let Inst{27-29} = xo;
635 let Inst{30} = SH{0};
639 //===----------------------------------------------------------------------===//
641 class Pseudo<dag OL, string asmstr> : I<0, 0, 0, OL, asmstr> {
646 let Arg0Type = Pseudo.Value;
647 let Arg1Type = Pseudo.Value;
648 let Arg2Type = Pseudo.Value;
649 let Arg3Type = Pseudo.Value;