Remove argtype and argcount magic, which was used by the old asmprinter.
[oota-llvm.git] / lib / Target / PowerPC / PPCInstrFormats.td
1 //===- PowerPCInstrFormats.td - PowerPC Instruction Formats --*- tablegen -*-=//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 //
11 //===----------------------------------------------------------------------===//
12
13 class Format<bits<5> val> {
14   bits<5> Value = val;
15 }
16
17 def Pseudo: Format<0>;
18 def Gpr : Format<1>;
19 def Gpr0 : Format<2>;
20 def Simm16 : Format<3>;
21 def PCRelimm24 : Format<5>;
22 def Imm24 : Format<6>;
23 def Imm5 : Format<7>;
24 def PCRelimm14 : Format<8>;
25 def Imm14 : Format<9>;
26 def Imm2 : Format<10>;
27 def Crf : Format<11>;
28 def Imm3 : Format<12>;
29 def Imm1 : Format<13>;
30 def Fpr : Format<14>;
31 def Imm4 : Format<15>;
32 def Imm8 : Format<16>;
33 def Disimm16 : Format<17>;
34 def Disimm14 : Format<18>;
35 def Spr : Format<19>;
36 def Sgr : Format<20>;
37 def Imm15 : Format<21>;
38 def Vpr : Format<22>;
39 def Imm6 : Format<23>;
40
41 //===----------------------------------------------------------------------===//
42 //
43 // PowerPC instruction formats
44
45 class I<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr> 
46   : Instruction {
47   field bits<32> Inst;
48
49   bit PPC64 = ppc64;
50   bit VMX = vmx;
51
52   let Name = "";
53   let Namespace = "PPC";
54   let Inst{0-5} = opcode;
55   let OperandList = OL;
56   let AsmString = asmstr;
57 }
58
59 // 1.7.1 I-Form
60 class IForm<bits<6> opcode, bit aa, bit lk, bit ppc64, bit vmx,
61             dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
62   bits<24> LI;
63
64   let Inst{6-29}  = LI;
65   let Inst{30}    = aa;
66   let Inst{31}    = lk;
67 }
68
69 // 1.7.2 B-Form
70 class BForm<bits<6> opcode, bit aa, bit lk, bit ppc64, bit vmx,
71             dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
72   bits<5>  BO;
73   bits<5>  BI;
74   bits<14> BD;
75
76   let Inst{6-10}  = BO;
77   let Inst{11-15} = BI;
78   let Inst{16-29} = BD;
79   let Inst{30}    = aa;
80   let Inst{31}    = lk;
81 }
82
83 class BForm_ext<bits<6> opcode, bit aa, bit lk, bits<5> bo, bits<5> bi, 
84                 bit ppc64, bit vmx, dag OL, string asmstr>
85   : BForm<opcode, aa, lk, ppc64, vmx, OL, asmstr> {
86   let BO = bo;
87   let BI = bi;
88 }
89
90 // 1.7.4 D-Form
91 class DForm_base<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
92   : I<opcode, ppc64, vmx, OL, asmstr> {
93   bits<5>  A;
94   bits<5>  B;
95   bits<16> C;
96   
97   let Inst{6-10}  = A;
98   let Inst{11-15} = B;
99   let Inst{16-31} = C;
100 }
101
102 class DForm_1<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
103   : I<opcode, ppc64, vmx, OL, asmstr> {
104   bits<5>  A;
105   bits<16> C;
106   bits<5>  B;
107   
108   let Inst{6-10}  = A;
109   let Inst{11-15} = B;
110   let Inst{16-31} = C;
111 }
112
113 class DForm_2<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
114   : DForm_base<opcode, ppc64, vmx, OL, asmstr>;
115
116 class DForm_2_r0<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
117   : I<opcode, ppc64, vmx, OL, asmstr> {
118   bits<5>  A;
119   bits<16> B;
120   
121   let Inst{6-10}  = A;
122   let Inst{11-15} = 0;
123   let Inst{16-31} = B;
124 }
125
126 // Currently we make the use/def reg distinction in ISel, not tablegen
127 class DForm_3<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
128   : DForm_1<opcode, ppc64, vmx, OL, asmstr>;
129
130 class DForm_4<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr> 
131   : DForm_base<opcode, ppc64, vmx, OL, asmstr>;
132               
133 class DForm_4_zero<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
134   : DForm_1<opcode, ppc64, vmx, OL, asmstr> {
135   let A = 0;
136   let B = 0;
137   let C = 0;
138 }
139
140 class DForm_5<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
141   : I<opcode, ppc64, vmx, OL, asmstr> {
142   bits<3>  BF;
143   bits<1>  L;
144   bits<5>  RA;
145   bits<16> I;
146
147   let Inst{6-8}   = BF;
148   let Inst{9}     = 0;
149   let Inst{10}    = L;
150   let Inst{11-15} = RA;
151   let Inst{16-31} = I;
152 }
153
154 class DForm_5_ext<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
155   : DForm_5<opcode, ppc64, vmx, OL, asmstr> {
156   let L = ppc64;
157 }
158
159 class DForm_6<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr> 
160   : DForm_5<opcode, ppc64, vmx, OL, asmstr>;
161
162 class DForm_6_ext<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
163   : DForm_6<opcode, ppc64, vmx, OL, asmstr> {
164   let L = ppc64;
165 }
166
167 class DForm_8<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
168   : DForm_1<opcode, ppc64, vmx, OL, asmstr> {
169 }
170
171 class DForm_9<bits<6> opcode, bit ppc64, bit vmx, dag OL, string asmstr>
172   : DForm_1<opcode, ppc64, vmx, OL, asmstr> {
173 }
174
175 // 1.7.5 DS-Form
176 class DSForm_1<bits<6> opcode, bits<2> xo, bit ppc64, bit vmx,
177                dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
178   bits<5>  RST;
179   bits<14> DS;
180   bits<5>  RA;
181
182   let Inst{6-10}  = RST;
183   let Inst{11-15} = RA;
184   let Inst{16-29} = DS;
185   let Inst{30-31} = xo;
186 }
187
188 class DSForm_2<bits<6> opcode, bits<2> xo, bit ppc64, bit vmx, 
189                dag OL, string asmstr>
190   : DSForm_1<opcode, xo, ppc64, vmx, OL, asmstr>;
191
192 // 1.7.6 X-Form
193 class XForm_base_r3xo<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
194                       dag OL, string asmstr> 
195   : I<opcode, ppc64, vmx, OL, asmstr> {
196   bits<5> RST;
197   bits<5> A;
198   bits<5> B;
199
200   let Inst{6-10}  = RST;
201   let Inst{11-15} = A;
202   let Inst{16-20} = B;
203   let Inst{21-30} = xo;
204   let Inst{31}    = rc;
205 }
206
207
208 class XForm_1<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
209               dag OL, string asmstr> 
210   : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr>;
211
212 class XForm_5<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
213               dag OL, string asmstr>
214   : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
215   let A = 0;
216   let B = 0;
217 }
218
219 class XForm_6<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
220               dag OL, string asmstr> 
221   : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr>;
222
223 class XForm_8<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
224               dag OL, string asmstr> 
225   : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr>;
226
227 class XForm_10<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
228                dag OL, string asmstr> 
229   : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
230 }
231
232 class XForm_11<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
233                dag OL, string asmstr> 
234   : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
235   let B = 0;
236 }
237
238 class XForm_16<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
239                dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
240   bits<3> BF;
241   bits<1> L; 
242   bits<5> RA;
243   bits<5> RB;
244   
245   let Inst{6-8}   = BF;
246   let Inst{9}     = 0;
247   let Inst{10}    = L;
248   let Inst{11-15} = RA;
249   let Inst{16-20} = RB;
250   let Inst{21-30} = xo;
251   let Inst{31}    = 0;
252 }
253
254 class XForm_16_ext<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
255                    dag OL, string asmstr>
256   : XForm_16<opcode, xo, ppc64, vmx, OL, asmstr> {
257   let L = ppc64;
258 }
259
260 class XForm_17<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
261                dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
262   bits<3> BF;
263   bits<5> FRA;
264   bits<5> FRB;
265   
266   let Inst{6-8}   = BF;
267   let Inst{9-10}  = 0;
268   let Inst{11-15} = FRA;
269   let Inst{16-20} = FRB;
270   let Inst{21-30} = xo;
271   let Inst{31}    = 0;
272 }
273
274 class XForm_25<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
275                dag OL, string asmstr> 
276   : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
277 }
278
279 class XForm_26<bits<6> opcode, bits<10> xo, bit rc, bit ppc64, bit vmx,
280                dag OL, string asmstr> 
281   : XForm_base_r3xo<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
282   let A = 0;
283 }
284
285 class XForm_28<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
286                dag OL, string asmstr> 
287   : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
288 }
289
290 // 1.7.7 XL-Form
291 class XLForm_1<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
292                dag OL, string asmstr> 
293   : XForm_base_r3xo<opcode, xo, 0, ppc64, vmx, OL, asmstr> {
294 }
295
296 class XLForm_2<bits<6> opcode, bits<10> xo, bit lk, bit ppc64, bit vmx, 
297                dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
298   bits<5> BO;
299   bits<5> BI;
300   bits<2> BH;
301   
302   let Inst{6-10}  = BO;
303   let Inst{11-15} = BI;
304   let Inst{16-18} = 0;
305   let Inst{19-20} = BH;
306   let Inst{21-30} = xo;
307   let Inst{31}    = lk;
308 }
309
310 class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo, 
311                    bits<5> bi, bit lk, bit ppc64, bit vmx, 
312                    dag OL, string asmstr>
313   : XLForm_2<opcode, xo, lk, ppc64, vmx, OL, asmstr> {
314   let BO = bo;
315   let BI = bi;
316   let BH = 0;
317 }
318
319 // 1.7.8 XFX-Form
320 class XFXForm_1<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx, 
321                 dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
322   bits<5>  ST;
323   bits<10> SPR;
324
325   let Inst{6-10}  = ST;
326   let Inst{11-20} = SPR;
327   let Inst{21-30} = xo;
328   let Inst{31}    = 0;
329 }
330
331 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr, bit ppc64, 
332                     bit vmx, dag OL, string asmstr> 
333   : XFXForm_1<opcode, xo, ppc64, vmx, OL, asmstr> {
334   let SPR = spr;
335 }
336
337 class XFXForm_7<bits<6> opcode, bits<10> xo, bit ppc64, bit vmx,
338                 dag OL, string asmstr>
339   : XFXForm_1<opcode, xo, ppc64, vmx, OL, asmstr>;
340
341 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr, 
342                     bit ppc64, bit vmx, dag OL, string asmstr> 
343   : XFXForm_7<opcode, xo, ppc64, vmx, OL, asmstr> {
344   let SPR = spr;
345 }
346
347 // 1.7.10 XS-Form
348 class XSForm_1<bits<6> opcode, bits<9> xo, bit rc, bit ppc64, bit vmx,
349                dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
350   bits<5> RS;
351   bits<5> A;
352   bits<6> SH;
353
354   let Inst{6-10}  = RS;
355   let Inst{11-15} = A;
356   let Inst{16-20} = SH{1-5};
357   let Inst{21-29} = xo;
358   let Inst{30}    = SH{0};
359   let Inst{31}    = rc;
360 }
361
362 // 1.7.11 XO-Form
363 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, bit rc, bit ppc64, bit vmx,
364                dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
365   bits<5> RT;
366   bits<5> RA;
367   bits<5> RB;
368
369   let Inst{6-10}  = RT;
370   let Inst{11-15} = RA;
371   let Inst{16-20} = RB;
372   let Inst{21}    = oe;
373   let Inst{22-30} = xo;
374   let Inst{31}    = rc;  
375 }
376
377 class XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, bit rc, bit ppc64, bit vmx,
378                dag OL, string asmstr>
379   : XOForm_1<opcode, xo, oe, rc, ppc64, vmx, OL, asmstr> {
380   let Inst{11-15} = RB;
381   let Inst{16-20} = RA;
382 }
383
384 class XOForm_3<bits<6> opcode, bits<9> xo, bit oe, bit rc, bit ppc64, bit vmx,
385                dag OL, string asmstr>
386   : XOForm_1<opcode, xo, oe, rc, ppc64, vmx, OL, asmstr> {
387   let RB = 0;
388 }
389
390 // 1.7.12 A-Form
391 class AForm_1<bits<6> opcode, bits<5> xo, bit rc, bit ppc64, bit vmx, 
392               dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
393   bits<5> FRT;
394   bits<5> FRA;
395   bits<5> FRB;
396   bits<5> FRC;
397
398   let Inst{6-10}  = FRT;
399   let Inst{11-15} = FRA;
400   let Inst{16-20} = FRB;
401   let Inst{21-25} = FRC;
402   let Inst{26-30} = xo;
403   let Inst{31}    = rc;
404 }
405
406 class AForm_2<bits<6> opcode, bits<5> xo, bit rc, bit ppc64, bit vmx, dag OL,
407               string asmstr> 
408   : AForm_1<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
409   let FRC = 0;
410 }
411
412 class AForm_3<bits<6> opcode, bits<5> xo, bit rc, bit ppc64, bit vmx, dag OL,
413               string asmstr> 
414   : AForm_1<opcode, xo, rc, ppc64, vmx, OL, asmstr> {
415   let FRB = 0;
416 }
417
418 // 1.7.13 M-Form
419 class MForm_1<bits<6> opcode, bit rc, bit ppc64, bit vmx,
420               dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
421   bits<5> RA;
422   bits<5> RS;
423   bits<5> RB;
424   bits<5> MB;
425   bits<5> ME;
426
427   let Inst{6-10}  = RS;
428   let Inst{11-15} = RA;
429   let Inst{16-20} = RB;
430   let Inst{21-25} = MB;
431   let Inst{26-30} = ME;
432   let Inst{31}    = rc;
433 }
434
435 class MForm_2<bits<6> opcode, bit rc, bit ppc64, bit vmx, 
436               dag OL, string asmstr>
437   : MForm_1<opcode, rc, ppc64, vmx, OL, asmstr> {
438 }
439
440 // 1.7.14 MD-Form
441 class MDForm_1<bits<6> opcode, bits<3> xo, bit rc, bit ppc64, bit vmx,
442                dag OL, string asmstr> : I<opcode, ppc64, vmx, OL, asmstr> {
443   bits<5> RS;
444   bits<5> RA;
445   bits<6> SH;
446   bits<6> MBE;
447
448   let Inst{6-10}  = RS;
449   let Inst{11-15} = RA;
450   let Inst{16-20} = SH{1-5};
451   let Inst{21-26} = MBE;
452   let Inst{27-29} = xo;
453   let Inst{30}    = SH{0};
454   let Inst{31}    = rc;
455 }
456
457 //===----------------------------------------------------------------------===//
458
459 class Pseudo<dag OL, string asmstr> : I<0, 0, 0, OL, asmstr> {
460   let PPC64 = 0;
461   let VMX = 0;
462
463   let Inst{31-0} = 0;
464 }