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;
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_1<name, opcode, ppc64, vmx>;
152 class DForm_4_zero<string name, bits<6> opcode, bit ppc64, bit vmx>
153 : DForm_1<name, opcode, ppc64, vmx> {
163 class DForm_5<string name, bits<6> opcode, bit ppc64, bit vmx>
164 : PPC32I<name, opcode, ppc64, vmx> {
171 let Arg0Type = Imm3.Value;
172 let Arg1Type = Imm1.Value;
173 let Arg2Type = Gpr.Value;
174 let Arg3Type = Simm16.Value;
180 let Inst{11-15} = RA;
184 class DForm_5_ext<string name, bits<6> opcode, bit ppc64, bit vmx>
185 : DForm_5<name, opcode, ppc64, vmx> {
189 class DForm_6<string name, bits<6> opcode, bit ppc64, bit vmx>
190 : DForm_5<name, opcode, ppc64, vmx> {
191 let Arg3Type = Zimm16.Value;
194 class DForm_6_ext<string name, bits<6> opcode, bit ppc64, bit vmx>
195 : DForm_6<name, opcode, ppc64, vmx> {
199 class DForm_7<string name, bits<6> opcode, bit ppc64, bit vmx>
200 : DForm_base<name, opcode, ppc64, vmx> {
201 let Arg1Type = Imm5.Value;
204 class DForm_8<string name, bits<6> opcode, bit ppc64, bit vmx>
205 : DForm_1<name, opcode, ppc64, vmx> {
206 let Arg0Type = Fpr.Value;
209 class DForm_9<string name, bits<6> opcode, bit ppc64, bit vmx>
210 : DForm_1<name, opcode, ppc64, vmx> {
211 let Arg0Type = Fpr.Value;
215 class XForm_base_r3xo<string name, bits<6> opcode, bits<10> xo, bit rc,
216 bit ppc64, bit vmx> : PPC32I<name, opcode, ppc64, vmx> {
223 let Arg0Type = Gpr.Value;
224 let Arg1Type = Gpr.Value;
225 let Arg2Type = Gpr.Value;
232 let Inst{21-30} = xo;
236 class XForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64,
237 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
239 class XForm_5<string name, bits<6> opcode, bits<10> xo, bit ppc64,
240 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
248 class XForm_6<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
249 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx>;
251 class XForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
252 : XForm_base_r3xo<name, opcode, xo, 1, ppc64, vmx>;
254 class XForm_8<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
255 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
257 class XForm_10<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
258 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
259 let Arg2Type = Imm5.Value;
262 class XForm_11<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
263 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
269 class XForm_16<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
270 : PPC32I<name, opcode, ppc64, vmx> {
277 let Arg0Type = Imm3.Value;
278 let Arg1Type = Imm1.Value;
279 let Arg2Type = Gpr.Value;
280 let Arg3Type = Gpr.Value;
286 let Inst{11-15} = RA;
287 let Inst{16-20} = RB;
288 let Inst{21-30} = xo;
292 class XForm_16_ext<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
293 : XForm_16<name, opcode, xo, ppc64, vmx> {
297 class XForm_17<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
298 : PPC32I<name, opcode, ppc64, vmx> {
304 let Arg0Type = Imm3.Value;
305 let Arg1Type = Fpr.Value;
306 let Arg2Type = Fpr.Value;
312 let Inst{11-15} = FRA;
313 let Inst{16-20} = FRB;
314 let Inst{21-30} = xo;
318 class XForm_25<string name, bits<6> opcode, bits<10> xo, bit ppc64,
319 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
320 let Arg0Type = Fpr.Value;
321 let Arg1Type = Gpr0.Value;
324 class XForm_26<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
325 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
327 let Arg0Type = Fpr.Value;
328 let Arg1Type = Fpr.Value;
333 class XForm_28<string name, bits<6> opcode, bits<10> xo, bit ppc64,
334 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
335 let Arg0Type = Fpr.Value;
336 let Arg1Type = Gpr0.Value;
340 class XLForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
341 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
342 let Arg0Type = Imm5.Value;
343 let Arg1Type = Imm5.Value;
344 let Arg2Type = Imm5.Value;
347 class XLForm_2<string name, bits<6> opcode, bits<10> xo, bit lk, bit ppc64,
348 bit vmx> : PPC32I<name, opcode, ppc64, vmx> {
354 let Arg0Type = Imm5.Value;
355 let Arg1Type = Imm5.Value;
356 let Arg2Type = Imm2.Value;
361 let Inst{11-15} = BI;
363 let Inst{19-20} = BH;
364 let Inst{21-30} = xo;
368 class XLForm_2_ext<string name, bits<6> opcode, bits<10> xo, bits<5> bo,
369 bits<5> bi, bit lk, bit ppc64, bit vmx>
370 : XLForm_2<name, opcode, xo, lk, ppc64, vmx> {
381 class XFXForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
382 : PPC32I<name, opcode, ppc64, vmx> {
387 let Arg0Type = Imm5.Value;
388 let Arg1Type = Gpr.Value;
394 let Inst{11-20} = SPR;
395 let Inst{21-30} = xo;
399 class XFXForm_1_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
400 bit ppc64, bit vmx> : XFXForm_1<name,opcode,xo,ppc64,vmx> {
402 let Arg0Type = Gpr.Value;
407 class XFXForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
408 : XFXForm_1<name, opcode, xo, ppc64, vmx>;
410 class XFXForm_7_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
411 bit ppc64, bit vmx> : XFXForm_7<name,opcode,xo,ppc64,vmx> {
413 let Arg0Type = Gpr.Value;
419 class XOForm_1<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
420 bit ppc64, bit vmx> : PPC32I<name, opcode, ppc64, vmx> {
426 let Arg0Type = Gpr.Value;
427 let Arg1Type = Gpr.Value;
428 let Arg2Type = Gpr.Value;
433 let Inst{11-15} = RA;
434 let Inst{16-20} = RB;
436 let Inst{22-30} = xo;
440 // This is a reversal of the two operands, used notably by extended ops SUB*:
441 // sub x, y, z == subf x, z, y
442 // subc x, y, z == subfc x, z, y
443 class XOForm_1_rev<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
445 : XOForm_1<name, opcode, xo, oe, rc, ppc64, vmx> {
446 let Inst{11-15} = RB;
447 let Inst{16-20} = RA;
450 class XOForm_2<string name, bits<6> opcode, bits<9> xo, bit rc, bit ppc64,
451 bit vmx> : XOForm_1<name, opcode, xo, 0, rc, ppc64, vmx>;
453 class XOForm_3<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
454 bit ppc64, bit vmx> : XOForm_1<name,opcode,xo,oe,rc,ppc64,vmx> {
459 class AForm_1<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
460 bit vmx> : PPC32I<name, opcode, ppc64, vmx> {
467 let Arg0Type = Fpr.Value;
468 let Arg1Type = Fpr.Value;
469 let Arg2Type = Fpr.Value;
470 let Arg3Type = Fpr.Value;
473 let Inst{6-10} = FRT;
474 let Inst{11-15} = FRA;
475 let Inst{16-20} = FRB;
476 let Inst{21-25} = FRC;
477 let Inst{26-30} = xo;
481 class AForm_2<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
482 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
488 class AForm_3<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
489 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
495 class AForm_4<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
496 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
505 class MForm_1<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
506 : PPC32I<name, opcode, ppc64, vmx> {
514 let Arg0Type = Gpr.Value;
515 let Arg1Type = Gpr.Value;
516 let Arg2Type = Gpr.Value;
517 let Arg3Type = Imm5.Value;
518 let Arg4Type = Imm5.Value;
521 let Inst{11-15} = RA;
522 let Inst{16-20} = RB;
523 let Inst{21-25} = MB;
524 let Inst{26-30} = ME;
528 class MForm_2<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
529 : MForm_1<name, opcode, rc, ppc64, vmx> {
530 let Arg2Type = Imm5.Value;
533 //===----------------------------------------------------------------------===//
535 class Pseudo<string name> : PPC32I<name, 0, 0, 0> {
541 let Arg0Type = Pseudo.Value;
542 let Arg1Type = Pseudo.Value;
543 let Arg2Type = Pseudo.Value;
544 let Arg3Type = Pseudo.Value;