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 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<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 : I<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> {
189 let Arg0Type = Imm3.Value;
190 let Arg1Type = Gpr.Value;
191 let Arg2Type = Simm16.Value;
195 class DForm_6<string name, bits<6> opcode, bit ppc64, bit vmx>
196 : DForm_5<name, opcode, ppc64, vmx> {
197 let Arg3Type = Zimm16.Value;
200 class DForm_6_ext<string name, bits<6> opcode, bit ppc64, bit vmx>
201 : DForm_6<name, opcode, ppc64, vmx> {
204 let Arg0Type = Imm3.Value;
205 let Arg1Type = Gpr.Value;
206 let Arg2Type = Simm16.Value;
210 class DForm_7<string name, bits<6> opcode, bit ppc64, bit vmx>
211 : DForm_base<name, opcode, ppc64, vmx> {
212 let Arg1Type = Imm5.Value;
215 class DForm_8<string name, bits<6> opcode, bit ppc64, bit vmx>
216 : DForm_1<name, opcode, ppc64, vmx> {
217 let Arg0Type = Fpr.Value;
220 class DForm_9<string name, bits<6> opcode, bit ppc64, bit vmx>
221 : DForm_1<name, opcode, ppc64, vmx> {
222 let Arg0Type = Fpr.Value;
226 class DSForm_1<string name, bits<6> opcode, bits<2> xo, bit ppc64, bit vmx>
227 : I<name, opcode, ppc64, vmx> {
233 let Arg0Type = Gpr.Value;
234 let Arg1Type = Disimm14.Value;
235 let Arg2Type = Gpr.Value;
239 let Inst{6-10} = RST;
240 let Inst{11-15} = RA;
241 let Inst{16-29} = DS;
242 let Inst{30-31} = xo;
245 class DSForm_2<string name, bits<6> opcode, bits<2> xo, bit ppc64, bit vmx>
246 : DSForm_1<name, opcode, xo, ppc64, vmx>;
249 class XForm_base_r3xo<string name, bits<6> opcode, bits<10> xo, bit rc,
250 bit ppc64, bit vmx> : I<name, opcode, ppc64, vmx> {
256 let Arg0Type = Gpr.Value;
257 let Arg1Type = Gpr.Value;
258 let Arg2Type = Gpr.Value;
262 let Inst{6-10} = RST;
265 let Inst{21-30} = xo;
269 class XForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64,
270 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
272 class XForm_5<string name, bits<6> opcode, bits<10> xo, bit ppc64,
273 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
281 class XForm_6<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
282 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx>;
284 class XForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
285 : XForm_base_r3xo<name, opcode, xo, 1, ppc64, vmx>;
287 class XForm_8<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
288 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx>;
290 class XForm_10<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
291 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
292 let Arg2Type = Imm5.Value;
295 class XForm_11<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
296 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
302 class XForm_16<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
303 : I<name, opcode, ppc64, vmx> {
310 let Arg0Type = Imm3.Value;
311 let Arg1Type = Imm1.Value;
312 let Arg2Type = Gpr.Value;
313 let Arg3Type = Gpr.Value;
319 let Inst{11-15} = RA;
320 let Inst{16-20} = RB;
321 let Inst{21-30} = xo;
325 class XForm_16_ext<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
326 : XForm_16<name, opcode, xo, ppc64, vmx> {
330 class XForm_17<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
331 : I<name, opcode, ppc64, vmx> {
337 let Arg0Type = Imm3.Value;
338 let Arg1Type = Fpr.Value;
339 let Arg2Type = Fpr.Value;
345 let Inst{11-15} = FRA;
346 let Inst{16-20} = FRB;
347 let Inst{21-30} = xo;
351 class XForm_25<string name, bits<6> opcode, bits<10> xo, bit ppc64,
352 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
353 let Arg0Type = Fpr.Value;
354 let Arg1Type = Gpr0.Value;
357 class XForm_26<string name, bits<6> opcode, bits<10> xo, bit rc, bit ppc64,
358 bit vmx> : XForm_base_r3xo<name, opcode, xo, rc, ppc64, vmx> {
360 let Arg0Type = Fpr.Value;
361 let Arg1Type = Fpr.Value;
366 class XForm_28<string name, bits<6> opcode, bits<10> xo, bit ppc64,
367 bit vmx> : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
368 let Arg0Type = Fpr.Value;
369 let Arg1Type = Gpr0.Value;
373 class XLForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
374 : XForm_base_r3xo<name, opcode, xo, 0, ppc64, vmx> {
375 let Arg0Type = Imm5.Value;
376 let Arg1Type = Imm5.Value;
377 let Arg2Type = Imm5.Value;
380 class XLForm_2<string name, bits<6> opcode, bits<10> xo, bit lk, bit ppc64,
381 bit vmx> : I<name, opcode, ppc64, vmx> {
387 let Arg0Type = Imm5.Value;
388 let Arg1Type = Imm5.Value;
389 let Arg2Type = Imm2.Value;
394 let Inst{11-15} = BI;
396 let Inst{19-20} = BH;
397 let Inst{21-30} = xo;
401 class XLForm_2_ext<string name, bits<6> opcode, bits<10> xo, bits<5> bo,
402 bits<5> bi, bit lk, bit ppc64, bit vmx>
403 : XLForm_2<name, opcode, xo, lk, ppc64, vmx> {
414 class XFXForm_1<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
415 : I<name, opcode, ppc64, vmx> {
420 let Arg0Type = Imm5.Value;
421 let Arg1Type = Gpr.Value;
427 let Inst{11-20} = SPR;
428 let Inst{21-30} = xo;
432 class XFXForm_1_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
433 bit ppc64, bit vmx> : XFXForm_1<name,opcode,xo,ppc64,vmx> {
435 let Arg0Type = Gpr.Value;
440 class XFXForm_7<string name, bits<6> opcode, bits<10> xo, bit ppc64, bit vmx>
441 : XFXForm_1<name, opcode, xo, ppc64, vmx>;
443 class XFXForm_7_ext<string name, bits<6> opcode, bits<10> xo, bits<10> spr,
444 bit ppc64, bit vmx> : XFXForm_7<name,opcode,xo,ppc64,vmx> {
446 let Arg0Type = Gpr.Value;
452 class XOForm_1<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
453 bit ppc64, bit vmx> : I<name, opcode, ppc64, vmx> {
459 let Arg0Type = Gpr.Value;
460 let Arg1Type = Gpr.Value;
461 let Arg2Type = Gpr.Value;
466 let Inst{11-15} = RA;
467 let Inst{16-20} = RB;
469 let Inst{22-30} = xo;
473 // This is a reversal of the two operands, used notably by extended ops SUB*:
474 // sub x, y, z == subf x, z, y
475 // subc x, y, z == subfc x, z, y
476 class XOForm_1_rev<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
478 : XOForm_1<name, opcode, xo, oe, rc, ppc64, vmx> {
479 let Inst{11-15} = RB;
480 let Inst{16-20} = RA;
483 class XOForm_2<string name, bits<6> opcode, bits<9> xo, bit rc, bit ppc64,
484 bit vmx> : XOForm_1<name, opcode, xo, 0, rc, ppc64, vmx>;
486 class XOForm_3<string name, bits<6> opcode, bits<9> xo, bit oe, bit rc,
487 bit ppc64, bit vmx> : XOForm_1<name,opcode,xo,oe,rc,ppc64,vmx> {
492 class AForm_1<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
493 bit vmx> : I<name, opcode, ppc64, vmx> {
500 let Arg0Type = Fpr.Value;
501 let Arg1Type = Fpr.Value;
502 let Arg2Type = Fpr.Value;
503 let Arg3Type = Fpr.Value;
506 let Inst{6-10} = FRT;
507 let Inst{11-15} = FRA;
508 let Inst{16-20} = FRB;
509 let Inst{21-25} = FRC;
510 let Inst{26-30} = xo;
514 class AForm_2<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
515 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
521 class AForm_3<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
522 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
528 class AForm_4<string name, bits<6> opcode, bits<5> xo, bit rc, bit ppc64,
529 bit vmx> : AForm_1<name, opcode, xo, rc, ppc64, vmx> {
538 class MForm_1<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
539 : I<name, opcode, ppc64, vmx> {
547 let Arg0Type = Gpr.Value;
548 let Arg1Type = Gpr.Value;
549 let Arg2Type = Gpr.Value;
550 let Arg3Type = Imm5.Value;
551 let Arg4Type = Imm5.Value;
554 let Inst{11-15} = RA;
555 let Inst{16-20} = RB;
556 let Inst{21-25} = MB;
557 let Inst{26-30} = ME;
561 class MForm_2<string name, bits<6> opcode, bit rc, bit ppc64, bit vmx>
562 : MForm_1<name, opcode, rc, ppc64, vmx> {
563 let Arg2Type = Imm5.Value;
566 //===----------------------------------------------------------------------===//
568 class Pseudo<string name> : I<name, 0, 0, 0> {
574 let Arg0Type = Pseudo.Value;
575 let Arg1Type = Pseudo.Value;
576 let Arg2Type = Pseudo.Value;
577 let Arg3Type = Pseudo.Value;