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 Zimm16 : Format<4>;
22 def PCRelimm24 : Format<5>;
23 def Imm24 : Format<6>;
25 def PCRelimm14 : Format<8>;
26 def Imm14 : Format<9>;
27 def Imm2 : Format<10>;
29 def Imm3 : Format<12>;
30 def Imm1 : Format<13>;
32 def Imm4 : Format<15>;
33 def Imm8 : Format<16>;
34 def Disimm16 : Format<17>;
35 def Disimm14 : Format<18>;
38 def Imm15 : Format<21>;
40 def Imm6 : Format<23>;
42 //===----------------------------------------------------------------------===//
44 // PowerPC instruction formats
46 class I<string name, bits<6> opcode, bit ppc64, bit vmx> : Instruction {
59 let Namespace = "PPC";
60 let Inst{0-5} = opcode;
64 class IForm<string name, bits<6> opcode, bit aa, bit lk, bit ppc64, bit vmx>
65 : I<name, opcode, ppc64, vmx> {
69 let Arg0Type = Imm24.Value;
81 class BForm<string name, bits<6> opcode, bit aa, bit lk, bit ppc64, bit vmx>
82 : I<name, opcode, ppc64, vmx> {
88 let Arg0Type = Imm5.Value;
89 let Arg1Type = Imm5.Value;
90 let Arg2Type = PCRelimm14.Value;
101 class BForm_ext<string name, bits<6> opcode, bit aa, bit lk, bits<5> bo,
102 bits<5> bi, bit ppc64, bit vmx>
103 : BForm<name, opcode, aa, lk, ppc64, vmx> {
105 let Arg2Type = Imm5.Value;
106 let Arg1Type = PCRelimm14.Value;
113 class DForm_base<string name, bits<6> opcode, bit ppc64, bit vmx>
114 : I<name, opcode, ppc64, vmx> {
120 let Arg0Type = Gpr.Value;
121 let Arg1Type = Gpr.Value;
122 let Arg2Type = Simm16.Value;
131 class DForm_1<string name, bits<6> opcode, bit ppc64, bit vmx>
132 : DForm_base<name, opcode, ppc64, vmx> {
133 let Arg1Type = Disimm16.Value;
134 let Arg2Type = Gpr0.Value;
137 class DForm_2<string name, bits<6> opcode, bit ppc64, bit vmx>
138 : DForm_base<name, opcode, ppc64, vmx>;
140 class DForm_2_r0<string name, bits<6> opcode, bit ppc64, bit vmx>
141 : DForm_base<name, opcode, ppc64, vmx> {
142 let Arg1Type = Gpr0.Value;
145 // Currently we make the use/def reg distinction in ISel, not tablegen
146 class DForm_3<string name, bits<6> opcode, bit ppc64, bit vmx>
147 : DForm_1<name, opcode, ppc64, vmx>;
149 class DForm_4<string name, bits<6> opcode, bit ppc64, bit vmx>
150 : DForm_base<name, opcode, ppc64, vmx> {
151 let Arg2Type = Zimm16.Value;
154 class DForm_4_zero<string name, bits<6> opcode, bit ppc64, bit vmx>
155 : DForm_1<name, opcode, ppc64, vmx> {
165 class DForm_5<string name, bits<6> opcode, bit ppc64, bit vmx>
166 : I<name, opcode, ppc64, vmx> {
173 let Arg0Type = Imm3.Value;
174 let Arg1Type = Imm1.Value;
175 let Arg2Type = Gpr.Value;
176 let Arg3Type = Simm16.Value;
182 let Inst{11-15} = RA;
186 class DForm_5_ext<string name, bits<6> opcode, bit ppc64, bit vmx>
187 : DForm_5<name, opcode, ppc64, vmx> {
190 let Arg0Type = Imm3.Value;
191 let Arg1Type = Gpr.Value;
192 let Arg2Type = Simm16.Value;
196 class DForm_6<string name, bits<6> opcode, bit ppc64, bit vmx>
197 : DForm_5<name, opcode, ppc64, vmx> {
198 let Arg3Type = Zimm16.Value;
201 class DForm_6_ext<string name, bits<6> opcode, bit ppc64, bit vmx>
202 : DForm_6<name, opcode, ppc64, vmx> {
205 let Arg0Type = Imm3.Value;
206 let Arg1Type = Gpr.Value;
207 let Arg2Type = Simm16.Value;
211 class DForm_7<string name, bits<6> opcode, bit ppc64, bit vmx>
212 : DForm_base<name, opcode, ppc64, vmx> {
213 let Arg1Type = Imm5.Value;
216 class DForm_8<string name, bits<6> opcode, bit ppc64, bit vmx>
217 : DForm_1<name, opcode, ppc64, vmx> {
218 let Arg0Type = Fpr.Value;
221 class DForm_9<string name, bits<6> opcode, bit ppc64, bit vmx>
222 : DForm_1<name, opcode, ppc64, vmx> {
223 let Arg0Type = Fpr.Value;
227 class DSForm_1<string name, bits<6> opcode, bits<2> xo, bit ppc64, bit vmx>
228 : I<name, opcode, ppc64, vmx> {
234 let Arg0Type = Gpr.Value;
235 let Arg1Type = Disimm14.Value;
236 let Arg2Type = Gpr.Value;
240 let Inst{6-10} = RST;
241 let Inst{11-15} = RA;
242 let Inst{16-29} = DS;
243 let Inst{30-31} = xo;
246 class DSForm_2<string name, bits<6> opcode, bits<2> xo, bit ppc64, bit vmx>
247 : DSForm_1<name, opcode, xo, ppc64, vmx>;
250 class XForm_base_r3xo<string name, bits<6> opcode, bits<10> xo, bit rc,
251 bit ppc64, bit vmx> : I<name, opcode, ppc64, vmx> {
257 let Arg0Type = Gpr.Value;
258 let Arg1Type = Gpr.Value;
259 let Arg2Type = Gpr.Value;
263 let Inst{6-10} = RST;
266 let Inst{21-30} = xo;
271 class XForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64,
272 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
274 class XForm_5<string name, bits<6> opcode, bits<10> xo, bit ppc64,
275 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
283 class XForm_6<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
284 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx>;
286 class XForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
287 : XForm_base_r3xo<name, opcode, xo, 1, ppc64, vmx>;
289 class XForm_8<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
290 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
292 class XForm_10<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
293 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
294 let Arg2Type = Imm5.Value;
297 class XForm_11<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
298 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
304 class XForm_16<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
305 : I<name, opcode, ppc64, vmx> {
312 let Arg0Type = Imm3.Value;
313 let Arg1Type = Imm1.Value;
314 let Arg2Type = Gpr.Value;
315 let Arg3Type = Gpr.Value;
321 let Inst{11-15} = RA;
322 let Inst{16-20} = RB;
323 let Inst{21-30} = xo;
327 class XForm_16_ext<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
328 : XForm_16<name, opcode, xo, ppc64, vmx> {
332 class XForm_17<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
333 : I<name, opcode, ppc64, vmx> {
339 let Arg0Type = Imm3.Value;
340 let Arg1Type = Fpr.Value;
341 let Arg2Type = Fpr.Value;
347 let Inst{11-15} = FRA;
348 let Inst{16-20} = FRB;
349 let Inst{21-30} = xo;
353 class XForm_25<string name, bits<6> opcode, bits<10> xo, bit ppc64,
354 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
355 let Arg0Type = Fpr.Value;
356 let Arg1Type = Gpr0.Value;
359 class XForm_26<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
360 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
362 let Arg0Type = Fpr.Value;
363 let Arg1Type = Fpr.Value;
368 class XForm_28<string name, bits<6> opcode, bits<10> xo, bit ppc64,
369 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
370 let Arg0Type = Fpr.Value;
371 let Arg1Type = Gpr0.Value;
375 class XLForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
376 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
377 let Arg0Type = Imm5.Value;
378 let Arg1Type = Imm5.Value;
379 let Arg2Type = Imm5.Value;
382 class XLForm_2<string name, bits<6> opcode, bits<10> xo, bit lk, bit ppc64,
383 bit vmx> : I<name, opcode, ppc64, vmx> {
389 let Arg0Type = Imm5.Value;
390 let Arg1Type = Imm5.Value;
391 let Arg2Type = Imm2.Value;
396 let Inst{11-15} = BI;
398 let Inst{19-20} = BH;
399 let Inst{21-30} = xo;
403 class XLForm_2_ext<string name, bits<6> opcode, bits<10> xo, bits<5> bo,
404 bits<5> bi, bit lk, bit ppc64, bit vmx>
405 : XLForm_2<name, opcode, xo, lk, ppc64, vmx> {
416 class XFXForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
417 : I<name, opcode, ppc64, vmx> {
422 let Arg0Type = Imm5.Value;
423 let Arg1Type = Gpr.Value;
429 let Inst{11-20} = SPR;
430 let Inst{21-30} = xo;
434 class XFXForm_1_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
435 bit ppc64, bit vmx> : XFXForm_1<name,opcode,xo,ppc64,vmx> {
437 let Arg0Type = Gpr.Value;
442 class XFXForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
443 : XFXForm_1<name, opcode, xo, ppc64, vmx>;
445 class XFXForm_7_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
446 bit ppc64, bit vmx> : XFXForm_7<name,opcode,xo,ppc64,vmx> {
448 let Arg0Type = Gpr.Value;
454 class XSForm_1<string name, bits<6> opcode, bits<9> xo, bit rc,
455 bit ppc64, bit vmx> : I<name, opcode, ppc64, vmx> {
461 let Arg0Type = Gpr.Value;
462 let Arg1Type = Gpr.Value;
463 let Arg2Type = Imm6.Value;
469 let Inst{16-20} = SH{1-5};
470 let Inst{21-29} = xo;
471 let Inst{30} = SH{0};
476 class XOForm_1<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
477 bit ppc64, bit vmx> : I<name, opcode, ppc64, vmx> {
483 let Arg0Type = Gpr.Value;
484 let Arg1Type = Gpr.Value;
485 let Arg2Type = Gpr.Value;
490 let Inst{11-15} = RA;
491 let Inst{16-20} = RB;
493 let Inst{22-30} = xo;
497 // This is a reversal of the two operands, used notably by extended ops SUB*:
498 // sub x, y, z == subf x, z, y
499 // subc x, y, z == subfc x, z, y
500 class XOForm_1_rev<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
502 : XOForm_1<name, opcode, xo, oe, rc, ppc64, vmx> {
503 let Inst{11-15} = RB;
504 let Inst{16-20} = RA;
507 class XOForm_2<string name, bits<6> opcode, bits<9> xo, bit rc, bit ppc64,
508 bit vmx> : XOForm_1<name, opcode, xo, 0, rc, ppc64, vmx>;
510 class XOForm_3<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
511 bit ppc64, bit vmx> : XOForm_1<name,opcode,xo,oe,rc,ppc64,vmx> {
516 class AForm_1<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
517 bit vmx> : I<name, opcode, ppc64, vmx> {
524 let Arg0Type = Fpr.Value;
525 let Arg1Type = Fpr.Value;
526 let Arg2Type = Fpr.Value;
527 let Arg3Type = Fpr.Value;
530 let Inst{6-10} = FRT;
531 let Inst{11-15} = FRA;
532 let Inst{16-20} = FRB;
533 let Inst{21-25} = FRC;
534 let Inst{26-30} = xo;
538 class AForm_2<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
539 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
545 class AForm_3<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
546 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
552 class AForm_4<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
553 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
562 class MForm_1<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
563 : I<name, opcode, ppc64, vmx> {
571 let Arg0Type = Gpr.Value;
572 let Arg1Type = Gpr.Value;
573 let Arg2Type = Gpr.Value;
574 let Arg3Type = Imm5.Value;
575 let Arg4Type = Imm5.Value;
578 let Inst{11-15} = RA;
579 let Inst{16-20} = RB;
580 let Inst{21-25} = MB;
581 let Inst{26-30} = ME;
585 class MForm_2<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
586 : MForm_1<name, opcode, rc, ppc64, vmx> {
587 let Arg2Type = Imm5.Value;
591 class MDForm_1<string name, bits<6> opcode, bits<3> xo, bit rc, bit ppc64, bit vmx>
592 : I<name, opcode, ppc64, vmx> {
599 let Arg0Type = Gpr.Value;
600 let Arg1Type = Gpr.Value;
601 let Arg2Type = Imm6.Value;
602 let Arg3Type = Imm6.Value;
606 let Inst{11-15} = RA;
607 let Inst{16-20} = SH{1-5};
608 let Inst{21-26} = MBE;
609 let Inst{27-29} = xo;
610 let Inst{30} = SH{0};
614 //===----------------------------------------------------------------------===//
616 class Pseudo<string name> : I<name, 0, 0, 0> {
622 let Arg0Type = Pseudo.Value;
623 let Arg1Type = Pseudo.Value;
624 let Arg2Type = Pseudo.Value;
625 let Arg3Type = Pseudo.Value;