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<string name, bits<6> opcode, bit ppc64, bit vmx> : Instruction {
58 let Namespace = "PPC";
59 let Inst{0-5} = opcode;
63 class IForm<string name, bits<6> opcode, bit aa, bit lk, bit ppc64, bit vmx>
64 : I<name, opcode, ppc64, vmx> {
68 let Arg0Type = Imm24.Value;
80 class BForm<string name, bits<6> opcode, bit aa, bit lk, bit ppc64, bit vmx>
81 : I<name, opcode, ppc64, vmx> {
87 let Arg0Type = Imm5.Value;
88 let Arg1Type = Imm5.Value;
89 let Arg2Type = PCRelimm14.Value;
100 class BForm_ext<string name, bits<6> opcode, bit aa, bit lk, bits<5> bo,
101 bits<5> bi, bit ppc64, bit vmx>
102 : BForm<name, opcode, aa, lk, ppc64, vmx> {
104 let Arg2Type = Imm5.Value;
105 let Arg1Type = PCRelimm14.Value;
112 class DForm_base<string name, bits<6> opcode, bit ppc64, bit vmx>
113 : I<name, opcode, ppc64, vmx> {
119 let Arg0Type = Gpr.Value;
120 let Arg1Type = Gpr.Value;
121 let Arg2Type = Simm16.Value;
130 class DForm_1<string name, bits<6> opcode, bit ppc64, bit vmx>
131 : DForm_base<name, opcode, ppc64, vmx> {
132 let Arg1Type = Disimm16.Value;
133 let Arg2Type = Gpr0.Value;
136 class DForm_2<string name, bits<6> opcode, bit ppc64, bit vmx>
137 : DForm_base<name, opcode, ppc64, vmx>;
139 class DForm_2_r0<string name, bits<6> opcode, bit ppc64, bit vmx>
140 : DForm_base<name, opcode, ppc64, vmx> {
141 let Arg1Type = Gpr0.Value;
144 // Currently we make the use/def reg distinction in ISel, not tablegen
145 class DForm_3<string name, bits<6> opcode, bit ppc64, bit vmx>
146 : DForm_1<name, opcode, ppc64, vmx>;
148 class DForm_4<bits<6> opcode, bit ppc64, bit vmx,
149 dag OL, string asmstr> : DForm_base<"", opcode, ppc64, vmx> {
150 let OperandList = OL;
151 let AsmString = asmstr;
154 class DForm_4_zero<string name, bits<6> opcode, bit ppc64, bit vmx,
155 dag OL, string asmstr> : DForm_1<"", opcode, ppc64, vmx> {
163 let OperandList = OL;
164 let AsmString = asmstr;
167 class DForm_5<string name, bits<6> opcode, bit ppc64, bit vmx>
168 : I<name, opcode, ppc64, vmx> {
175 let Arg0Type = Imm3.Value;
176 let Arg1Type = Imm1.Value;
177 let Arg2Type = Gpr.Value;
178 let Arg3Type = Simm16.Value;
184 let Inst{11-15} = RA;
188 class DForm_5_ext<string name, bits<6> opcode, bit ppc64, bit vmx>
189 : DForm_5<name, opcode, ppc64, vmx> {
192 let Arg0Type = Imm3.Value;
193 let Arg1Type = Gpr.Value;
194 let Arg2Type = Simm16.Value;
198 class DForm_6<bits<6> opcode, bit ppc64, bit vmx,
199 dag OL, string asmstr>
200 : DForm_5<"", opcode, ppc64, vmx> {
201 let OperandList = OL;
202 let AsmString = asmstr;
205 class DForm_6_ext<bits<6> opcode, bit ppc64, bit vmx,
206 dag OL, string asmstr>
207 : DForm_6<opcode, ppc64, vmx, OL, asmstr> {
210 let Arg0Type = Imm3.Value;
211 let Arg1Type = Gpr.Value;
212 let Arg2Type = Simm16.Value;
216 class DForm_7<string name, bits<6> opcode, bit ppc64, bit vmx>
217 : DForm_base<name, opcode, ppc64, vmx> {
218 let Arg1Type = Imm5.Value;
221 class DForm_8<string name, bits<6> opcode, bit ppc64, bit vmx>
222 : DForm_1<name, opcode, ppc64, vmx> {
223 let Arg0Type = Fpr.Value;
226 class DForm_9<string name, bits<6> opcode, bit ppc64, bit vmx>
227 : DForm_1<name, opcode, ppc64, vmx> {
228 let Arg0Type = Fpr.Value;
232 class DSForm_1<string name, bits<6> opcode, bits<2> xo, bit ppc64, bit vmx>
233 : I<name, opcode, ppc64, vmx> {
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<string name, bits<6> opcode, bits<2> xo, bit ppc64, bit vmx>
252 : DSForm_1<name, opcode, xo, ppc64, vmx>;
255 class XForm_base_r3xo<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
256 dag OL, string asmstr> : I<"", opcode, ppc64, vmx> {
262 let Arg0Type = Gpr.Value;
263 let Arg1Type = Gpr.Value;
264 let Arg2Type = Gpr.Value;
268 let Inst{6-10} = RST;
271 let Inst{21-30} = xo;
273 let OperandList = OL;
274 let AsmString = asmstr;
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<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
315 : I<name, opcode, ppc64, vmx> {
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<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
338 : XForm_16<name, opcode, xo, ppc64, vmx> {
342 class XForm_17<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
343 : I<name, opcode, ppc64, vmx> {
349 let Arg0Type = Imm3.Value;
350 let Arg1Type = Fpr.Value;
351 let Arg2Type = Fpr.Value;
357 let Inst{11-15} = FRA;
358 let Inst{16-20} = FRB;
359 let Inst{21-30} = xo;
363 class XForm_25<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
364 dag OL, string asmstr>
365 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
366 let Arg0Type = Fpr.Value;
367 let Arg1Type = Gpr0.Value;
370 class XForm_26<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
371 dag OL, string asmstr>
372 : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
374 let Arg0Type = Fpr.Value;
375 let Arg1Type = Fpr.Value;
380 class XForm_28<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;
388 class XLForm_1<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
389 dag OL, string asmstr>
390 : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
391 let Arg0Type = Imm5.Value;
392 let Arg1Type = Imm5.Value;
393 let Arg2Type = Imm5.Value;
396 class XLForm_2<string name, bits<6> opcode, bits<10> xo, bit lk, bit ppc64,
397 bit vmx> : I<name, opcode, ppc64, vmx> {
403 let Arg0Type = Imm5.Value;
404 let Arg1Type = Imm5.Value;
405 let Arg2Type = Imm2.Value;
410 let Inst{11-15} = BI;
412 let Inst{19-20} = BH;
413 let Inst{21-30} = xo;
417 class XLForm_2_ext<string name, bits<6> opcode, bits<10> xo, bits<5> bo,
418 bits<5> bi, bit lk, bit ppc64, bit vmx>
419 : XLForm_2<name, opcode, xo, lk, ppc64, vmx> {
430 class XFXForm_1<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
431 dag OL, string asmstr> : I<"", opcode, ppc64, vmx> {
436 let Arg0Type = Imm5.Value;
437 let Arg1Type = Gpr.Value;
443 let Inst{11-20} = SPR;
444 let Inst{21-30} = xo;
446 let OperandList = OL;
447 let AsmString = asmstr;
450 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr, bit ppc64,
451 bit vmx, dag OL, string asmstr>
452 : XFXForm_1<opcode, xo, ppc64, vmx, OL, asmstr> {
454 let Arg0Type = Gpr.Value;
459 class XFXForm_7<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
460 dag OL, string asmstr>
461 : XFXForm_1<opcode, xo, ppc64, vmx, OL, asmstr>;
463 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
464 bit ppc64, bit vmx, dag OL, string asmstr>
465 : XFXForm_7<opcode, xo, ppc64, vmx, OL, asmstr> {
467 let Arg0Type = Gpr.Value;
473 class XSForm_1<bits<6> opcode, bits<9> xo, bit rc, bit ppc64, bit vmx,
474 dag OL, string asmstr> : I<"", opcode, ppc64, vmx> {
480 let Arg0Type = Gpr.Value;
481 let Arg1Type = Gpr.Value;
482 let Arg2Type = Imm6.Value;
488 let Inst{16-20} = SH{1-5};
489 let Inst{21-29} = xo;
490 let Inst{30} = SH{0};
492 let OperandList = OL;
493 let AsmString = asmstr;
497 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, bit rc, bit ppc64, bit vmx,
498 dag OL, string asmstr> : I<"", opcode, ppc64, vmx> {
504 let Arg0Type = Gpr.Value;
505 let Arg1Type = Gpr.Value;
506 let Arg2Type = Gpr.Value;
511 let Inst{11-15} = RA;
512 let Inst{16-20} = RB;
514 let Inst{22-30} = xo;
516 let OperandList = OL;
517 let AsmString = asmstr;
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> {
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;
555 let OperandList = OL;
556 let AsmString = asmstr;
559 class AForm_2<bits<6> opcode, bits<5> xo, bit rc, bit ppc64, bit vmx, dag OL,
561 : AForm_1<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
567 class AForm_3<bits<6> opcode, bits<5> xo, bit rc, bit ppc64, bit vmx, dag OL,
569 : AForm_1<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
576 class MForm_1<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
577 : I<name, opcode, ppc64, vmx> {
585 let Arg0Type = Gpr.Value;
586 let Arg1Type = Gpr.Value;
587 let Arg2Type = Gpr.Value;
588 let Arg3Type = Imm5.Value;
589 let Arg4Type = Imm5.Value;
592 let Inst{11-15} = RA;
593 let Inst{16-20} = RB;
594 let Inst{21-25} = MB;
595 let Inst{26-30} = ME;
599 class MForm_2<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
600 : MForm_1<name, opcode, rc, ppc64, vmx> {
601 let Arg2Type = Imm5.Value;
605 class MDForm_1<string name, bits<6> opcode, bits<3> xo, bit rc, bit ppc64, bit vmx>
606 : I<name, opcode, ppc64, vmx> {
613 let Arg0Type = Gpr.Value;
614 let Arg1Type = Gpr.Value;
615 let Arg2Type = Imm6.Value;
616 let Arg3Type = Imm6.Value;
620 let Inst{11-15} = RA;
621 let Inst{16-20} = SH{1-5};
622 let Inst{21-26} = MBE;
623 let Inst{27-29} = xo;
624 let Inst{30} = SH{0};
628 //===----------------------------------------------------------------------===//
630 class Pseudo<string name> : I<name, 0, 0, 0> {
636 let Arg0Type = Pseudo.Value;
637 let Arg1Type = Pseudo.Value;
638 let Arg2Type = Pseudo.Value;
639 let Arg3Type = Pseudo.Value;