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<string name, bits<6> opcode, bits<10> xo, bit rc,
256 bit ppc64, bit vmx> : I<name, 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;
276 class XForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64,
277 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
279 class XForm_5<string name, bits<6> opcode, bits<10> xo, bit ppc64,
280 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
288 class XForm_6<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
289 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx>;
291 class XForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
292 : XForm_base_r3xo<name, opcode, xo, 1, ppc64, vmx>;
294 class XForm_8<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
295 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
297 class XForm_10<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
298 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
299 let Arg2Type = Imm5.Value;
302 class XForm_11<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
303 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
309 class XForm_16<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
310 : I<name, opcode, ppc64, vmx> {
317 let Arg0Type = Imm3.Value;
318 let Arg1Type = Imm1.Value;
319 let Arg2Type = Gpr.Value;
320 let Arg3Type = Gpr.Value;
326 let Inst{11-15} = RA;
327 let Inst{16-20} = RB;
328 let Inst{21-30} = xo;
332 class XForm_16_ext<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
333 : XForm_16<name, opcode, xo, ppc64, vmx> {
337 class XForm_17<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
338 : I<name, opcode, ppc64, vmx> {
344 let Arg0Type = Imm3.Value;
345 let Arg1Type = Fpr.Value;
346 let Arg2Type = Fpr.Value;
352 let Inst{11-15} = FRA;
353 let Inst{16-20} = FRB;
354 let Inst{21-30} = xo;
358 class XForm_25<string name, bits<6> opcode, bits<10> xo, bit ppc64,
359 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
360 let Arg0Type = Fpr.Value;
361 let Arg1Type = Gpr0.Value;
364 class XForm_26<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
365 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
367 let Arg0Type = Fpr.Value;
368 let Arg1Type = Fpr.Value;
373 class XForm_28<string name, bits<6> opcode, bits<10> xo, bit ppc64,
374 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
375 let Arg0Type = Fpr.Value;
376 let Arg1Type = Gpr0.Value;
380 class XLForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
381 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
382 let Arg0Type = Imm5.Value;
383 let Arg1Type = Imm5.Value;
384 let Arg2Type = Imm5.Value;
387 class XLForm_2<string name, bits<6> opcode, bits<10> xo, bit lk, bit ppc64,
388 bit vmx> : I<name, opcode, ppc64, vmx> {
394 let Arg0Type = Imm5.Value;
395 let Arg1Type = Imm5.Value;
396 let Arg2Type = Imm2.Value;
401 let Inst{11-15} = BI;
403 let Inst{19-20} = BH;
404 let Inst{21-30} = xo;
408 class XLForm_2_ext<string name, bits<6> opcode, bits<10> xo, bits<5> bo,
409 bits<5> bi, bit lk, bit ppc64, bit vmx>
410 : XLForm_2<name, opcode, xo, lk, ppc64, vmx> {
421 class XFXForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
422 : I<name, opcode, ppc64, vmx> {
427 let Arg0Type = Imm5.Value;
428 let Arg1Type = Gpr.Value;
434 let Inst{11-20} = SPR;
435 let Inst{21-30} = xo;
439 class XFXForm_1_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
440 bit ppc64, bit vmx> : XFXForm_1<name,opcode,xo,ppc64,vmx> {
442 let Arg0Type = Gpr.Value;
447 class XFXForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
448 : XFXForm_1<name, opcode, xo, ppc64, vmx>;
450 class XFXForm_7_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
451 bit ppc64, bit vmx> : XFXForm_7<name,opcode,xo,ppc64,vmx> {
453 let Arg0Type = Gpr.Value;
459 class XSForm_1<string name, bits<6> opcode, bits<9> xo, bit rc,
460 bit ppc64, bit vmx> : I<name, opcode, ppc64, vmx> {
466 let Arg0Type = Gpr.Value;
467 let Arg1Type = Gpr.Value;
468 let Arg2Type = Imm6.Value;
474 let Inst{16-20} = SH{1-5};
475 let Inst{21-29} = xo;
476 let Inst{30} = SH{0};
481 class XOForm_1<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
482 bit ppc64, bit vmx> : I<name, opcode, ppc64, vmx> {
488 let Arg0Type = Gpr.Value;
489 let Arg1Type = Gpr.Value;
490 let Arg2Type = Gpr.Value;
495 let Inst{11-15} = RA;
496 let Inst{16-20} = RB;
498 let Inst{22-30} = xo;
502 // This is a reversal of the two operands, used notably by extended ops SUB*:
503 // sub x, y, z == subf x, z, y
504 // subc x, y, z == subfc x, z, y
505 class XOForm_1_rev<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
507 : XOForm_1<name, opcode, xo, oe, rc, ppc64, vmx> {
508 let Inst{11-15} = RB;
509 let Inst{16-20} = RA;
512 class XOForm_2<string name, bits<6> opcode, bits<9> xo, bit rc, bit ppc64,
513 bit vmx> : XOForm_1<name, opcode, xo, 0, rc, ppc64, vmx>;
515 class XOForm_3<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
516 bit ppc64, bit vmx> : XOForm_1<name,opcode,xo,oe,rc,ppc64,vmx> {
521 class AForm_1<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
522 bit vmx> : I<name, opcode, ppc64, vmx> {
529 let Arg0Type = Fpr.Value;
530 let Arg1Type = Fpr.Value;
531 let Arg2Type = Fpr.Value;
532 let Arg3Type = Fpr.Value;
535 let Inst{6-10} = FRT;
536 let Inst{11-15} = FRA;
537 let Inst{16-20} = FRB;
538 let Inst{21-25} = FRC;
539 let Inst{26-30} = xo;
543 class AForm_2<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
544 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
550 class AForm_3<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
551 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
557 class AForm_4<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
558 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
567 class MForm_1<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
568 : I<name, opcode, ppc64, vmx> {
576 let Arg0Type = Gpr.Value;
577 let Arg1Type = Gpr.Value;
578 let Arg2Type = Gpr.Value;
579 let Arg3Type = Imm5.Value;
580 let Arg4Type = Imm5.Value;
583 let Inst{11-15} = RA;
584 let Inst{16-20} = RB;
585 let Inst{21-25} = MB;
586 let Inst{26-30} = ME;
590 class MForm_2<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
591 : MForm_1<name, opcode, rc, ppc64, vmx> {
592 let Arg2Type = Imm5.Value;
596 class MDForm_1<string name, bits<6> opcode, bits<3> xo, bit rc, bit ppc64, bit vmx>
597 : I<name, opcode, ppc64, vmx> {
604 let Arg0Type = Gpr.Value;
605 let Arg1Type = Gpr.Value;
606 let Arg2Type = Imm6.Value;
607 let Arg3Type = Imm6.Value;
611 let Inst{11-15} = RA;
612 let Inst{16-20} = SH{1-5};
613 let Inst{21-26} = MBE;
614 let Inst{27-29} = xo;
615 let Inst{30} = SH{0};
619 //===----------------------------------------------------------------------===//
621 class Pseudo<string name> : I<name, 0, 0, 0> {
627 let Arg0Type = Pseudo.Value;
628 let Arg1Type = Pseudo.Value;
629 let Arg2Type = Pseudo.Value;
630 let Arg3Type = Pseudo.Value;