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<bits<6> opcode, bit ppc64, bit vmx,
150 dag OL, string asmstr> : DForm_base<"", opcode, ppc64, vmx> {
151 let OperandList = OL;
152 let AsmString = asmstr;
155 class DForm_4_zero<string name, bits<6> opcode, bit ppc64, bit vmx>
156 : DForm_1<name, opcode, ppc64, vmx> {
166 class DForm_5<string name, bits<6> opcode, bit ppc64, bit vmx>
167 : I<name, opcode, ppc64, vmx> {
174 let Arg0Type = Imm3.Value;
175 let Arg1Type = Imm1.Value;
176 let Arg2Type = Gpr.Value;
177 let Arg3Type = Simm16.Value;
183 let Inst{11-15} = RA;
187 class DForm_5_ext<string name, bits<6> opcode, bit ppc64, bit vmx>
188 : DForm_5<name, opcode, ppc64, vmx> {
191 let Arg0Type = Imm3.Value;
192 let Arg1Type = Gpr.Value;
193 let Arg2Type = Simm16.Value;
197 class DForm_6<string name, bits<6> opcode, bit ppc64, bit vmx>
198 : DForm_5<name, opcode, ppc64, vmx> {
199 let Arg3Type = Zimm16.Value;
202 class DForm_6_ext<string name, bits<6> opcode, bit ppc64, bit vmx>
203 : DForm_6<name, opcode, ppc64, vmx> {
206 let Arg0Type = Imm3.Value;
207 let Arg1Type = Gpr.Value;
208 let Arg2Type = Simm16.Value;
212 class DForm_7<string name, bits<6> opcode, bit ppc64, bit vmx>
213 : DForm_base<name, opcode, ppc64, vmx> {
214 let Arg1Type = Imm5.Value;
217 class DForm_8<string name, bits<6> opcode, bit ppc64, bit vmx>
218 : DForm_1<name, opcode, ppc64, vmx> {
219 let Arg0Type = Fpr.Value;
222 class DForm_9<string name, bits<6> opcode, bit ppc64, bit vmx>
223 : DForm_1<name, opcode, ppc64, vmx> {
224 let Arg0Type = Fpr.Value;
228 class DSForm_1<string name, bits<6> opcode, bits<2> xo, bit ppc64, bit vmx>
229 : I<name, opcode, ppc64, vmx> {
235 let Arg0Type = Gpr.Value;
236 let Arg1Type = Disimm14.Value;
237 let Arg2Type = Gpr.Value;
241 let Inst{6-10} = RST;
242 let Inst{11-15} = RA;
243 let Inst{16-29} = DS;
244 let Inst{30-31} = xo;
247 class DSForm_2<string name, bits<6> opcode, bits<2> xo, bit ppc64, bit vmx>
248 : DSForm_1<name, opcode, xo, ppc64, vmx>;
251 class XForm_base_r3xo<string name, bits<6> opcode, bits<10> xo, bit rc,
252 bit ppc64, bit vmx> : I<name, opcode, ppc64, vmx> {
258 let Arg0Type = Gpr.Value;
259 let Arg1Type = Gpr.Value;
260 let Arg2Type = Gpr.Value;
264 let Inst{6-10} = RST;
267 let Inst{21-30} = xo;
272 class XForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64,
273 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
275 class XForm_5<string name, bits<6> opcode, bits<10> xo, bit ppc64,
276 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
284 class XForm_6<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
285 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx>;
287 class XForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
288 : XForm_base_r3xo<name, opcode, xo, 1, ppc64, vmx>;
290 class XForm_8<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
291 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
293 class XForm_10<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
294 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
295 let Arg2Type = Imm5.Value;
298 class XForm_11<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
299 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
305 class XForm_16<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
306 : I<name, opcode, ppc64, vmx> {
313 let Arg0Type = Imm3.Value;
314 let Arg1Type = Imm1.Value;
315 let Arg2Type = Gpr.Value;
316 let Arg3Type = Gpr.Value;
322 let Inst{11-15} = RA;
323 let Inst{16-20} = RB;
324 let Inst{21-30} = xo;
328 class XForm_16_ext<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
329 : XForm_16<name, opcode, xo, ppc64, vmx> {
333 class XForm_17<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
334 : I<name, opcode, ppc64, vmx> {
340 let Arg0Type = Imm3.Value;
341 let Arg1Type = Fpr.Value;
342 let Arg2Type = Fpr.Value;
348 let Inst{11-15} = FRA;
349 let Inst{16-20} = FRB;
350 let Inst{21-30} = xo;
354 class XForm_25<string name, bits<6> opcode, bits<10> xo, bit ppc64,
355 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
356 let Arg0Type = Fpr.Value;
357 let Arg1Type = Gpr0.Value;
360 class XForm_26<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
361 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
363 let Arg0Type = Fpr.Value;
364 let Arg1Type = Fpr.Value;
369 class XForm_28<string name, bits<6> opcode, bits<10> xo, bit ppc64,
370 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
371 let Arg0Type = Fpr.Value;
372 let Arg1Type = Gpr0.Value;
376 class XLForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
377 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
378 let Arg0Type = Imm5.Value;
379 let Arg1Type = Imm5.Value;
380 let Arg2Type = Imm5.Value;
383 class XLForm_2<string name, bits<6> opcode, bits<10> xo, bit lk, bit ppc64,
384 bit vmx> : I<name, opcode, ppc64, vmx> {
390 let Arg0Type = Imm5.Value;
391 let Arg1Type = Imm5.Value;
392 let Arg2Type = Imm2.Value;
397 let Inst{11-15} = BI;
399 let Inst{19-20} = BH;
400 let Inst{21-30} = xo;
404 class XLForm_2_ext<string name, bits<6> opcode, bits<10> xo, bits<5> bo,
405 bits<5> bi, bit lk, bit ppc64, bit vmx>
406 : XLForm_2<name, opcode, xo, lk, ppc64, vmx> {
417 class XFXForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
418 : I<name, opcode, ppc64, vmx> {
423 let Arg0Type = Imm5.Value;
424 let Arg1Type = Gpr.Value;
430 let Inst{11-20} = SPR;
431 let Inst{21-30} = xo;
435 class XFXForm_1_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
436 bit ppc64, bit vmx> : XFXForm_1<name,opcode,xo,ppc64,vmx> {
438 let Arg0Type = Gpr.Value;
443 class XFXForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
444 : XFXForm_1<name, opcode, xo, ppc64, vmx>;
446 class XFXForm_7_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
447 bit ppc64, bit vmx> : XFXForm_7<name,opcode,xo,ppc64,vmx> {
449 let Arg0Type = Gpr.Value;
455 class XSForm_1<string name, bits<6> opcode, bits<9> xo, bit rc,
456 bit ppc64, bit vmx> : I<name, opcode, ppc64, vmx> {
462 let Arg0Type = Gpr.Value;
463 let Arg1Type = Gpr.Value;
464 let Arg2Type = Imm6.Value;
470 let Inst{16-20} = SH{1-5};
471 let Inst{21-29} = xo;
472 let Inst{30} = SH{0};
477 class XOForm_1<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
478 bit ppc64, bit vmx> : I<name, opcode, ppc64, vmx> {
484 let Arg0Type = Gpr.Value;
485 let Arg1Type = Gpr.Value;
486 let Arg2Type = Gpr.Value;
491 let Inst{11-15} = RA;
492 let Inst{16-20} = RB;
494 let Inst{22-30} = xo;
498 // This is a reversal of the two operands, used notably by extended ops SUB*:
499 // sub x, y, z == subf x, z, y
500 // subc x, y, z == subfc x, z, y
501 class XOForm_1_rev<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
503 : XOForm_1<name, opcode, xo, oe, rc, ppc64, vmx> {
504 let Inst{11-15} = RB;
505 let Inst{16-20} = RA;
508 class XOForm_2<string name, bits<6> opcode, bits<9> xo, bit rc, bit ppc64,
509 bit vmx> : XOForm_1<name, opcode, xo, 0, rc, ppc64, vmx>;
511 class XOForm_3<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
512 bit ppc64, bit vmx> : XOForm_1<name,opcode,xo,oe,rc,ppc64,vmx> {
517 class AForm_1<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
518 bit vmx> : I<name, opcode, ppc64, vmx> {
525 let Arg0Type = Fpr.Value;
526 let Arg1Type = Fpr.Value;
527 let Arg2Type = Fpr.Value;
528 let Arg3Type = Fpr.Value;
531 let Inst{6-10} = FRT;
532 let Inst{11-15} = FRA;
533 let Inst{16-20} = FRB;
534 let Inst{21-25} = FRC;
535 let Inst{26-30} = xo;
539 class AForm_2<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
540 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
546 class AForm_3<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
547 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
553 class AForm_4<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
554 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
563 class MForm_1<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
564 : I<name, opcode, ppc64, vmx> {
572 let Arg0Type = Gpr.Value;
573 let Arg1Type = Gpr.Value;
574 let Arg2Type = Gpr.Value;
575 let Arg3Type = Imm5.Value;
576 let Arg4Type = Imm5.Value;
579 let Inst{11-15} = RA;
580 let Inst{16-20} = RB;
581 let Inst{21-25} = MB;
582 let Inst{26-30} = ME;
586 class MForm_2<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
587 : MForm_1<name, opcode, rc, ppc64, vmx> {
588 let Arg2Type = Imm5.Value;
592 class MDForm_1<string name, bits<6> opcode, bits<3> xo, bit rc, bit ppc64, bit vmx>
593 : I<name, opcode, ppc64, vmx> {
600 let Arg0Type = Gpr.Value;
601 let Arg1Type = Gpr.Value;
602 let Arg2Type = Imm6.Value;
603 let Arg3Type = Imm6.Value;
607 let Inst{11-15} = RA;
608 let Inst{16-20} = SH{1-5};
609 let Inst{21-26} = MBE;
610 let Inst{27-29} = xo;
611 let Inst{30} = SH{0};
615 //===----------------------------------------------------------------------===//
617 class Pseudo<string name> : I<name, 0, 0, 0> {
623 let Arg0Type = Pseudo.Value;
624 let Arg1Type = Pseudo.Value;
625 let Arg2Type = Pseudo.Value;
626 let Arg3Type = Pseudo.Value;