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>;
41 //===----------------------------------------------------------------------===//
43 // PowerPC instruction formats
45 class PPC32I<string name, bits<6> opcode, bit ppc64, bit vmx> : Instruction {
58 let Namespace = "PPC32";
59 let Inst{0-5} = opcode;
63 class IForm<string name, bits<6> opcode, bit aa, bit lk, bit ppc64, bit vmx>
64 : PPC32I<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 : PPC32I<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 : PPC32I<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<string name, bits<6> opcode, bit ppc64, bit vmx>
149 : DForm_base<name, opcode, ppc64, vmx> {
150 let Arg2Type = Zimm16.Value;
153 class DForm_4_zero<string name, bits<6> opcode, bit ppc64, bit vmx>
154 : DForm_1<name, opcode, ppc64, vmx> {
164 class DForm_5<string name, bits<6> opcode, bit ppc64, bit vmx>
165 : PPC32I<name, opcode, ppc64, vmx> {
172 let Arg0Type = Imm3.Value;
173 let Arg1Type = Imm1.Value;
174 let Arg2Type = Gpr.Value;
175 let Arg3Type = Simm16.Value;
181 let Inst{11-15} = RA;
185 class DForm_5_ext<string name, bits<6> opcode, bit ppc64, bit vmx>
186 : DForm_5<name, opcode, ppc64, vmx> {
190 class DForm_6<string name, bits<6> opcode, bit ppc64, bit vmx>
191 : DForm_5<name, opcode, ppc64, vmx> {
192 let Arg3Type = Zimm16.Value;
195 class DForm_6_ext<string name, bits<6> opcode, bit ppc64, bit vmx>
196 : DForm_6<name, opcode, ppc64, vmx> {
200 class DForm_7<string name, bits<6> opcode, bit ppc64, bit vmx>
201 : DForm_base<name, opcode, ppc64, vmx> {
202 let Arg1Type = Imm5.Value;
205 class DForm_8<string name, bits<6> opcode, bit ppc64, bit vmx>
206 : DForm_1<name, opcode, ppc64, vmx> {
207 let Arg0Type = Fpr.Value;
210 class DForm_9<string name, bits<6> opcode, bit ppc64, bit vmx>
211 : DForm_1<name, opcode, ppc64, vmx> {
212 let Arg0Type = Fpr.Value;
216 class XForm_base_r3xo<string name, bits<6> opcode, bits<10> xo, bit rc,
217 bit ppc64, bit vmx> : PPC32I<name, opcode, ppc64, vmx> {
224 let Arg0Type = Gpr.Value;
225 let Arg1Type = Gpr.Value;
226 let Arg2Type = Gpr.Value;
233 let Inst{21-30} = xo;
237 class XForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64,
238 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
240 class XForm_5<string name, bits<6> opcode, bits<10> xo, bit ppc64,
241 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
249 class XForm_6<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
250 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx>;
252 class XForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
253 : XForm_base_r3xo<name, opcode, xo, 1, ppc64, vmx>;
255 class XForm_8<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
256 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
258 class XForm_10<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
259 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
260 let Arg2Type = Imm5.Value;
263 class XForm_11<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
264 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
270 class XForm_16<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
271 : PPC32I<name, opcode, ppc64, vmx> {
278 let Arg0Type = Imm3.Value;
279 let Arg1Type = Imm1.Value;
280 let Arg2Type = Gpr.Value;
281 let Arg3Type = Gpr.Value;
287 let Inst{11-15} = RA;
288 let Inst{16-20} = RB;
289 let Inst{21-30} = xo;
293 class XForm_16_ext<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
294 : XForm_16<name, opcode, xo, ppc64, vmx> {
298 class XForm_17<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
299 : PPC32I<name, opcode, ppc64, vmx> {
305 let Arg0Type = Imm3.Value;
306 let Arg1Type = Fpr.Value;
307 let Arg2Type = Fpr.Value;
313 let Inst{11-15} = FRA;
314 let Inst{16-20} = FRB;
315 let Inst{21-30} = xo;
319 class XForm_25<string name, bits<6> opcode, bits<10> xo, bit ppc64,
320 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
321 let Arg0Type = Fpr.Value;
322 let Arg1Type = Gpr0.Value;
325 class XForm_26<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
326 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
328 let Arg0Type = Fpr.Value;
329 let Arg1Type = Fpr.Value;
334 class XForm_28<string name, bits<6> opcode, bits<10> xo, bit ppc64,
335 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
336 let Arg0Type = Fpr.Value;
337 let Arg1Type = Gpr0.Value;
341 class XLForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
342 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
343 let Arg0Type = Imm5.Value;
344 let Arg1Type = Imm5.Value;
345 let Arg2Type = Imm5.Value;
348 class XLForm_2<string name, bits<6> opcode, bits<10> xo, bit lk, bit ppc64,
349 bit vmx> : PPC32I<name, opcode, ppc64, vmx> {
355 let Arg0Type = Imm5.Value;
356 let Arg1Type = Imm5.Value;
357 let Arg2Type = Imm2.Value;
362 let Inst{11-15} = BI;
364 let Inst{19-20} = BH;
365 let Inst{21-30} = xo;
369 class XLForm_2_ext<string name, bits<6> opcode, bits<10> xo, bits<5> bo,
370 bits<5> bi, bit lk, bit ppc64, bit vmx>
371 : XLForm_2<name, opcode, xo, lk, ppc64, vmx> {
382 class XFXForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
383 : PPC32I<name, opcode, ppc64, vmx> {
388 let Arg0Type = Imm5.Value;
389 let Arg1Type = Gpr.Value;
395 let Inst{11-20} = SPR;
396 let Inst{21-30} = xo;
400 class XFXForm_1_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
401 bit ppc64, bit vmx> : XFXForm_1<name,opcode,xo,ppc64,vmx> {
403 let Arg0Type = Gpr.Value;
408 class XFXForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
409 : XFXForm_1<name, opcode, xo, ppc64, vmx>;
411 class XFXForm_7_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
412 bit ppc64, bit vmx> : XFXForm_7<name,opcode,xo,ppc64,vmx> {
414 let Arg0Type = Gpr.Value;
420 class XOForm_1<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
421 bit ppc64, bit vmx> : PPC32I<name, opcode, ppc64, vmx> {
427 let Arg0Type = Gpr.Value;
428 let Arg1Type = Gpr.Value;
429 let Arg2Type = Gpr.Value;
434 let Inst{11-15} = RA;
435 let Inst{16-20} = RB;
437 let Inst{22-30} = xo;
441 // This is a reversal of the two operands, used notably by extended ops SUB*:
442 // sub x, y, z == subf x, z, y
443 // subc x, y, z == subfc x, z, y
444 class XOForm_1_rev<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
446 : XOForm_1<name, opcode, xo, oe, rc, ppc64, vmx> {
447 let Inst{11-15} = RB;
448 let Inst{16-20} = RA;
451 class XOForm_2<string name, bits<6> opcode, bits<9> xo, bit rc, bit ppc64,
452 bit vmx> : XOForm_1<name, opcode, xo, 0, rc, ppc64, vmx>;
454 class XOForm_3<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
455 bit ppc64, bit vmx> : XOForm_1<name,opcode,xo,oe,rc,ppc64,vmx> {
460 class AForm_1<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
461 bit vmx> : PPC32I<name, opcode, ppc64, vmx> {
468 let Arg0Type = Fpr.Value;
469 let Arg1Type = Fpr.Value;
470 let Arg2Type = Fpr.Value;
471 let Arg3Type = Fpr.Value;
474 let Inst{6-10} = FRT;
475 let Inst{11-15} = FRA;
476 let Inst{16-20} = FRB;
477 let Inst{21-25} = FRC;
478 let Inst{26-30} = xo;
482 class AForm_2<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
483 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
489 class AForm_3<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
490 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
496 class AForm_4<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
497 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
506 class MForm_1<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
507 : PPC32I<name, opcode, ppc64, vmx> {
515 let Arg0Type = Gpr.Value;
516 let Arg1Type = Gpr.Value;
517 let Arg2Type = Gpr.Value;
518 let Arg3Type = Imm5.Value;
519 let Arg4Type = Imm5.Value;
522 let Inst{11-15} = RA;
523 let Inst{16-20} = RB;
524 let Inst{21-25} = MB;
525 let Inst{26-30} = ME;
529 class MForm_2<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
530 : MForm_1<name, opcode, rc, ppc64, vmx> {
531 let Arg2Type = Imm5.Value;
534 //===----------------------------------------------------------------------===//
536 class Pseudo<string name> : PPC32I<name, 0, 0, 0> {
542 let Arg0Type = Pseudo.Value;
543 let Arg1Type = Pseudo.Value;
544 let Arg2Type = Pseudo.Value;
545 let Arg3Type = Pseudo.Value;