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 PCRelimm24 : Format<5>;
22 def Imm24 : Format<6>;
24 def PCRelimm14 : Format<8>;
25 def Imm14 : Format<9>;
26 def Imm2 : Format<10>;
28 def Imm3 : Format<12>;
29 def Imm1 : Format<13>;
31 def Imm4 : Format<15>;
32 def Imm8 : Format<16>;
33 def Disimm16 : Format<17>;
34 def Disimm14 : Format<18>;
37 def Imm15 : Format<21>;
39 def Imm6 : Format<23>;
41 //===----------------------------------------------------------------------===//
43 // PowerPC instruction formats
45 class I<bits<6> opcode, dag OL, string asmstr> : Instruction {
48 bit PPC64 = 0; // Default value, override with isPPC64
49 bit VMX = 0; // Default value, override with isVMX
52 let Namespace = "PPC";
53 let Inst{0-5} = opcode;
55 let AsmString = asmstr;
59 class IForm<bits<6> opcode, bit aa, bit lk, dag OL, string asmstr>
60 : I<opcode, OL, asmstr> {
69 class BForm<bits<6> opcode, bit aa, bit lk, bits<5> bo, bits<2> bicode, dag OL,
71 : I<opcode, OL, asmstr> {
77 let Inst{14-15} = bicode;
84 class DForm_base<bits<6> opcode, dag OL, string asmstr> : I<opcode, OL, asmstr>{
94 class DForm_1<bits<6> opcode, dag OL, string asmstr> : I<opcode, OL, asmstr> {
104 class DForm_2<bits<6> opcode, dag OL, string asmstr>
105 : DForm_base<opcode, OL, asmstr>;
107 class DForm_2_r0<bits<6> opcode, dag OL, string asmstr>
108 : I<opcode, OL, asmstr> {
117 // Currently we make the use/def reg distinction in ISel, not tablegen
118 class DForm_3<bits<6> opcode, dag OL, string asmstr>
119 : DForm_1<opcode, OL, asmstr>;
121 class DForm_4<bits<6> opcode, dag OL, string asmstr> : I<opcode, OL, asmstr> {
131 class DForm_4_zero<bits<6> opcode, dag OL, string asmstr>
132 : DForm_1<opcode, OL, asmstr> {
138 class DForm_5<bits<6> opcode, dag OL, string asmstr> : I<opcode, OL, asmstr> {
147 let Inst{11-15} = RA;
151 class DForm_5_ext<bits<6> opcode, dag OL, string asmstr>
152 : DForm_5<opcode, OL, asmstr> {
156 class DForm_6<bits<6> opcode, dag OL, string asmstr>
157 : DForm_5<opcode, OL, asmstr>;
159 class DForm_6_ext<bits<6> opcode, dag OL, string asmstr>
160 : DForm_6<opcode, OL, asmstr> {
164 class DForm_8<bits<6> opcode, dag OL, string asmstr>
165 : DForm_1<opcode, OL, asmstr> {
168 class DForm_9<bits<6> opcode, dag OL, string asmstr>
169 : DForm_1<opcode, OL, asmstr> {
173 class DSForm_1<bits<6> opcode, bits<2> xo, dag OL, string asmstr>
174 : I<opcode, OL, asmstr> {
179 let Inst{6-10} = RST;
180 let Inst{11-15} = RA;
181 let Inst{16-29} = DS;
182 let Inst{30-31} = xo;
185 class DSForm_2<bits<6> opcode, bits<2> xo, dag OL, string asmstr>
186 : DSForm_1<opcode, xo, OL, asmstr>;
189 class XForm_base_r3xo<bits<6> opcode, bits<10> xo,
190 dag OL, string asmstr> : I<opcode, OL, asmstr> {
195 bit RC = 0; // set by isDOT
197 let Inst{6-10} = RST;
200 let Inst{21-30} = xo;
204 // This is the same as XForm_base_r3xo, but the first two operands are swapped
205 // when code is emitted.
206 class XForm_base_r3xo_swapped
207 <bits<6> opcode, bits<10> xo, dag OL, string asmstr>
208 : I<opcode, OL, asmstr> {
213 bit RC = 0; // set by isDOT
215 let Inst{6-10} = RST;
218 let Inst{21-30} = xo;
223 class XForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
224 : XForm_base_r3xo<opcode, xo, OL, asmstr>;
226 class XForm_6<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
227 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr>;
229 class XForm_8<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
230 : XForm_base_r3xo<opcode, xo, OL, asmstr>;
232 class XForm_10<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
233 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr> {
236 class XForm_11<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
237 : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr> {
241 class XForm_16<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
242 : I<opcode, OL, asmstr> {
251 let Inst{11-15} = RA;
252 let Inst{16-20} = RB;
253 let Inst{21-30} = xo;
257 class XForm_16_ext<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
258 : XForm_16<opcode, xo, OL, asmstr> {
262 class XForm_17<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
263 : I<opcode, OL, asmstr> {
270 let Inst{11-15} = FRA;
271 let Inst{16-20} = FRB;
272 let Inst{21-30} = xo;
276 class XForm_25<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
277 : XForm_base_r3xo<opcode, xo, OL, asmstr> {
280 class XForm_26<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
281 : XForm_base_r3xo<opcode, xo, OL, asmstr> {
285 class XForm_28<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
286 : XForm_base_r3xo<opcode, xo, OL, asmstr> {
290 class XLForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
291 : I<opcode, OL, asmstr> {
300 let Inst{9-10} = CRDb;
301 let Inst{11-13} = CRA;
302 let Inst{14-15} = CRAb;
303 let Inst{16-18} = CRB;
304 let Inst{19-20} = CRBb;
305 let Inst{21-30} = xo;
309 class XLForm_2<bits<6> opcode, bits<10> xo, bit lk,
310 dag OL, string asmstr> : I<opcode, OL, asmstr> {
316 let Inst{11-15} = BI;
318 let Inst{19-20} = BH;
319 let Inst{21-30} = xo;
323 class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo,
324 bits<5> bi, bit lk, dag OL, string asmstr>
325 : XLForm_2<opcode, xo, lk, OL, asmstr> {
331 class XLForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
332 : I<opcode, OL, asmstr> {
338 let Inst{11-13} = BFA;
341 let Inst{21-30} = xo;
346 class XFXForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
347 : I<opcode, OL, asmstr> {
352 let Inst{11-20} = SPR;
353 let Inst{21-30} = xo;
357 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
358 dag OL, string asmstr>
359 : XFXForm_1<opcode, xo, OL, asmstr> {
363 class XFXForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
364 : I<opcode, OL, asmstr> {
369 let Inst{21-30} = xo;
373 class XFXForm_5<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
374 : I<opcode, OL, asmstr> {
380 let Inst{12-19} = FXM;
382 let Inst{21-30} = xo;
386 class XFXForm_5a<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
387 : I<opcode, OL, asmstr> {
393 let Inst{12-19} = FXM;
395 let Inst{21-30} = xo;
400 class XFXForm_7<bits<6> opcode, bits<10> xo, dag OL, string asmstr>
401 : XFXForm_1<opcode, xo, OL, asmstr>;
403 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr,
404 dag OL, string asmstr>
405 : XFXForm_7<opcode, xo, OL, asmstr> {
410 class XSForm_1<bits<6> opcode, bits<9> xo, dag OL, string asmstr>
411 : I<opcode, OL, asmstr> {
416 bit RC = 0; // set by isDOT
420 let Inst{16-20} = SH{1-5};
421 let Inst{21-29} = xo;
422 let Inst{30} = SH{0};
427 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, dag OL, string asmstr,
429 : I<opcode, OL, asmstr> {
434 let Pattern = pattern;
436 bit RC = 0; // set by isDOT
439 let Inst{11-15} = RA;
440 let Inst{16-20} = RB;
442 let Inst{22-30} = xo;
446 class XOForm_3<bits<6> opcode, bits<9> xo, bit oe,
447 dag OL, string asmstr>
448 : XOForm_1<opcode, xo, oe, OL, asmstr, []> {
453 class AForm_1<bits<6> opcode, bits<5> xo, dag OL, string asmstr>
454 : I<opcode, OL, asmstr> {
460 bit RC = 0; // set by isDOT
462 let Inst{6-10} = FRT;
463 let Inst{11-15} = FRA;
464 let Inst{16-20} = FRB;
465 let Inst{21-25} = FRC;
466 let Inst{26-30} = xo;
470 class AForm_2<bits<6> opcode, bits<5> xo, dag OL, string asmstr>
471 : AForm_1<opcode, xo, OL, asmstr> {
475 class AForm_3<bits<6> opcode, bits<5> xo, dag OL, string asmstr>
476 : AForm_1<opcode, xo, OL, asmstr> {
481 class MForm_1<bits<6> opcode, dag OL, string asmstr> : I<opcode, OL, asmstr> {
488 bit RC = 0; // set by isDOT
491 let Inst{11-15} = RA;
492 let Inst{16-20} = RB;
493 let Inst{21-25} = MB;
494 let Inst{26-30} = ME;
498 class MForm_2<bits<6> opcode, dag OL, string asmstr>
499 : MForm_1<opcode, OL, asmstr> {
503 class MDForm_1<bits<6> opcode, bits<3> xo, dag OL, string asmstr>
504 : I<opcode, OL, asmstr> {
510 bit RC = 0; // set by isDOT
513 let Inst{11-15} = RA;
514 let Inst{16-20} = SH{1-5};
515 let Inst{21-26} = MBE;
516 let Inst{27-29} = xo;
517 let Inst{30} = SH{0};
521 //===----------------------------------------------------------------------===//
523 class Pseudo<dag OL, string asmstr> : I<0, OL, asmstr> {