Add support for fmul node of type v4f32.
[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 //===----------------------------------------------------------------------===//
14 //
15 // PowerPC instruction formats
16
17 class I<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
18         : Instruction {
19   field bits<32> Inst;
20
21   bit PPC64 = 0;  // Default value, override with isPPC64
22   bit VMX = 0;    // Default value, override with isVMX
23
24   let Name = "";
25   let Namespace = "PPC";
26   let Inst{0-5} = opcode;
27   let OperandList = OL;
28   let AsmString = asmstr;
29   let Itinerary = itin;
30 }
31
32 // 1.7.1 I-Form
33 class IForm<bits<6> opcode, bit aa, bit lk, dag OL, string asmstr,
34             InstrItinClass itin, list<dag> pattern>
35          : I<opcode, OL, asmstr, itin> {
36   let Pattern = pattern;
37   bits<24> LI;
38
39   let Inst{6-29}  = LI;
40   let Inst{30}    = aa;
41   let Inst{31}    = lk;
42 }
43
44 // 1.7.2 B-Form
45 class BForm<bits<6> opcode, bit aa, bit lk, bits<5> bo, bits<2> bicode, dag OL, 
46             string asmstr, InstrItinClass itin>
47   : I<opcode, OL, asmstr, itin> {
48   bits<3>  CR;
49   bits<14> BD;
50
51   let Inst{6-10}  = bo;
52   let Inst{11-13} = CR;
53   let Inst{14-15} = bicode;
54   let Inst{16-29} = BD;
55   let Inst{30}    = aa;
56   let Inst{31}    = lk;
57 }
58
59 // 1.7.4 D-Form
60 class DForm_base<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
61                  list<dag> pattern> 
62   : I<opcode, OL, asmstr, itin> {
63   bits<5>  A;
64   bits<5>  B;
65   bits<16> C;
66
67   let Pattern = pattern;
68   
69   let Inst{6-10}  = A;
70   let Inst{11-15} = B;
71   let Inst{16-31} = C;
72 }
73
74 class DForm_1<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
75               list<dag> pattern>
76   : I<opcode, OL, asmstr, itin> {
77   bits<5>  A;
78   bits<16> C;
79   bits<5>  B;
80
81   let Pattern = pattern;
82   
83   let Inst{6-10}  = A;
84   let Inst{11-15} = B;
85   let Inst{16-31} = C;
86 }
87
88 class DForm_2<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
89               list<dag> pattern>
90   : DForm_base<opcode, OL, asmstr, itin, pattern>;
91
92 class DForm_2_r0<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
93                  list<dag> pattern>
94   : I<opcode, OL, asmstr, itin> {
95   bits<5>  A;
96   bits<16> B;
97   
98   let Pattern = pattern;
99   
100   let Inst{6-10}  = A;
101   let Inst{11-15} = 0;
102   let Inst{16-31} = B;
103 }
104
105 // Currently we make the use/def reg distinction in ISel, not tablegen
106 class DForm_3<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
107               list<dag> pattern>
108   : DForm_1<opcode, OL, asmstr, itin, pattern>;
109
110 class DForm_4<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
111               list<dag> pattern>
112   : I<opcode, OL, asmstr, itin> {
113   bits<5>  B;
114   bits<5>  A;
115   bits<16> C;
116   
117   let Pattern = pattern;
118   
119   let Inst{6-10}  = A;
120   let Inst{11-15} = B;
121   let Inst{16-31} = C;
122 }
123               
124 class DForm_4_zero<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
125                    list<dag> pattern>
126   : DForm_1<opcode, OL, asmstr, itin, pattern> {
127   let A = 0;
128   let B = 0;
129   let C = 0;
130 }
131
132 class DForm_5<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
133   : I<opcode, OL, asmstr, itin> {
134   bits<3>  BF;
135   bits<1>  L;
136   bits<5>  RA;
137   bits<16> I;
138
139   let Inst{6-8}   = BF;
140   let Inst{9}     = 0;
141   let Inst{10}    = L;
142   let Inst{11-15} = RA;
143   let Inst{16-31} = I;
144 }
145
146 class DForm_5_ext<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
147   : DForm_5<opcode, OL, asmstr, itin> {
148   let L = PPC64;
149 }
150
151 class DForm_6<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin> 
152   : DForm_5<opcode, OL, asmstr, itin>;
153
154 class DForm_6_ext<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin>
155   : DForm_6<opcode, OL, asmstr, itin> {
156   let L = PPC64;
157 }
158
159 class DForm_8<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
160               list<dag> pattern>
161   : DForm_1<opcode, OL, asmstr, itin, pattern> {
162 }
163
164 class DForm_9<bits<6> opcode, dag OL, string asmstr, InstrItinClass itin,
165               list<dag> pattern>
166   : DForm_1<opcode, OL, asmstr, itin, pattern> {
167 }
168
169 // 1.7.5 DS-Form
170 class DSForm_1<bits<6> opcode, bits<2> xo, dag OL, string asmstr,
171                InstrItinClass itin, list<dag> pattern>
172          : I<opcode, OL, asmstr, itin> {
173   bits<5>  RST;
174   bits<14> DS;
175   bits<5>  RA;
176
177   let Pattern = pattern;
178   
179   let Inst{6-10}  = RST;
180   let Inst{11-15} = RA;
181   let Inst{16-29} = DS;
182   let Inst{30-31} = xo;
183 }
184
185 class DSForm_2<bits<6> opcode, bits<2> xo, dag OL, string asmstr,
186                InstrItinClass itin, list<dag> pattern>
187   : DSForm_1<opcode, xo, OL, asmstr, itin, pattern>;
188
189 // 1.7.6 X-Form
190 class XForm_base_r3xo<bits<6> opcode, bits<10> xo, dag OL, string asmstr, 
191                       InstrItinClass itin, list<dag> pattern>
192   : I<opcode, OL, asmstr, itin> {
193   bits<5> RST;
194   bits<5> A;
195   bits<5> B;
196
197   let Pattern = pattern;
198
199   bit RC = 0;    // set by isDOT
200
201   let Inst{6-10}  = RST;
202   let Inst{11-15} = A;
203   let Inst{16-20} = B;
204   let Inst{21-30} = xo;
205   let Inst{31}    = RC;
206 }
207
208 // This is the same as XForm_base_r3xo, but the first two operands are swapped
209 // when code is emitted.
210 class XForm_base_r3xo_swapped
211         <bits<6> opcode, bits<10> xo, dag OL, string asmstr,
212         InstrItinClass itin> 
213   : I<opcode, OL, asmstr, itin> {
214   bits<5> A;
215   bits<5> RST;
216   bits<5> B;
217
218   bit RC = 0;    // set by isDOT
219
220   let Inst{6-10}  = RST;
221   let Inst{11-15} = A;
222   let Inst{16-20} = B;
223   let Inst{21-30} = xo;
224   let Inst{31}    = RC;
225 }
226
227
228 class XForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
229               InstrItinClass itin, list<dag> pattern> 
230   : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern>;
231
232 class XForm_6<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
233               InstrItinClass itin, list<dag> pattern> 
234   : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
235   let Pattern = pattern;
236 }
237
238 class XForm_8<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
239               InstrItinClass itin, list<dag> pattern> 
240   : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern>;
241
242 class XForm_10<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
243                InstrItinClass itin, list<dag> pattern> 
244   : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
245     let Pattern = pattern;
246 }
247
248 class XForm_11<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
249                InstrItinClass itin, list<dag> pattern> 
250   : XForm_base_r3xo_swapped<opcode, xo, OL, asmstr, itin> {
251   let B = 0;
252   let Pattern = pattern;
253 }
254
255 class XForm_16<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
256                InstrItinClass itin>
257          : I<opcode, OL, asmstr, itin> {
258   bits<3> BF;
259   bits<1> L; 
260   bits<5> RA;
261   bits<5> RB;
262   
263   let Inst{6-8}   = BF;
264   let Inst{9}     = 0;
265   let Inst{10}    = L;
266   let Inst{11-15} = RA;
267   let Inst{16-20} = RB;
268   let Inst{21-30} = xo;
269   let Inst{31}    = 0;
270 }
271
272 class XForm_16_ext<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
273                    InstrItinClass itin>
274   : XForm_16<opcode, xo, OL, asmstr, itin> {
275   let L = PPC64;
276 }
277
278 class XForm_17<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
279                InstrItinClass itin>
280          : I<opcode, OL, asmstr, itin> {
281   bits<3> BF;
282   bits<5> FRA;
283   bits<5> FRB;
284   
285   let Inst{6-8}   = BF;
286   let Inst{9-10}  = 0;
287   let Inst{11-15} = FRA;
288   let Inst{16-20} = FRB;
289   let Inst{21-30} = xo;
290   let Inst{31}    = 0;
291 }
292
293 class XForm_25<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
294                InstrItinClass itin, list<dag> pattern> 
295   : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
296 }
297
298 class XForm_26<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
299                InstrItinClass itin, list<dag> pattern>
300   : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
301   let A = 0;
302 }
303
304 class XForm_28<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
305                InstrItinClass itin, list<dag> pattern> 
306   : XForm_base_r3xo<opcode, xo, OL, asmstr, itin, pattern> {
307 }
308
309 // 1.7.7 XL-Form
310 class XLForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
311                InstrItinClass itin>
312     : I<opcode, OL, asmstr, itin> {
313   bits<3> CRD;
314   bits<2> CRDb;
315   bits<3> CRA;
316   bits<2> CRAb;
317   bits<3> CRB;
318   bits<2> CRBb;
319   
320   let Inst{6-8}   = CRD;
321   let Inst{9-10}  = CRDb;
322   let Inst{11-13} = CRA;
323   let Inst{14-15} = CRAb;
324   let Inst{16-18} = CRB;
325   let Inst{19-20} = CRBb;
326   let Inst{21-30} = xo;
327   let Inst{31}    = 0;
328 }
329
330 class XLForm_2<bits<6> opcode, bits<10> xo, bit lk, dag OL, string asmstr, 
331                InstrItinClass itin>
332     : I<opcode, OL, asmstr, itin> {
333   bits<5> BO;
334   bits<5> BI;
335   bits<2> BH;
336   
337   let Inst{6-10}  = BO;
338   let Inst{11-15} = BI;
339   let Inst{16-18} = 0;
340   let Inst{19-20} = BH;
341   let Inst{21-30} = xo;
342   let Inst{31}    = lk;
343 }
344
345 class XLForm_2_ext<bits<6> opcode, bits<10> xo, bits<5> bo,  bits<5> bi, bit lk,
346                   dag OL, string asmstr, InstrItinClass itin>
347   : XLForm_2<opcode, xo, lk, OL, asmstr, itin> {
348   let BO = bo;
349   let BI = bi;
350   let BH = 0;
351 }
352
353 class XLForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
354                InstrItinClass itin>
355          : I<opcode, OL, asmstr, itin> {
356   bits<3> BF;
357   bits<3> BFA;
358   
359   let Inst{6-8}   = BF;
360   let Inst{9-10}  = 0;
361   let Inst{11-13} = BFA;
362   let Inst{14-15} = 0;
363   let Inst{16-20} = 0;
364   let Inst{21-30} = xo;
365   let Inst{31}    = 0;
366 }
367
368 // 1.7.8 XFX-Form
369 class XFXForm_1<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
370                 InstrItinClass itin>
371          : I<opcode, OL, asmstr, itin> {
372   bits<5>  RT;
373   bits<10> SPR;
374
375   let Inst{6-10}  = RT;
376   let Inst{11}    = SPR{4};
377   let Inst{12}    = SPR{3};
378   let Inst{13}    = SPR{2};
379   let Inst{14}    = SPR{1};
380   let Inst{15}    = SPR{0};
381   let Inst{16}    = SPR{9};
382   let Inst{17}    = SPR{8};
383   let Inst{18}    = SPR{7};
384   let Inst{19}    = SPR{6};
385   let Inst{20}    = SPR{5};
386   let Inst{21-30} = xo;
387   let Inst{31}    = 0;
388 }
389
390 class XFXForm_1_ext<bits<6> opcode, bits<10> xo, bits<10> spr, 
391                    dag OL, string asmstr, InstrItinClass itin> 
392   : XFXForm_1<opcode, xo, OL, asmstr, itin> {
393   let SPR = spr;
394 }
395
396 class XFXForm_3<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
397                 InstrItinClass itin>
398          : I<opcode, OL, asmstr, itin> {
399   bits<5>  RT;
400    
401   let Inst{6-10}  = RT;
402   let Inst{11-20} = 0;
403   let Inst{21-30} = xo;
404   let Inst{31}    = 0;
405 }
406
407 class XFXForm_5<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
408                 InstrItinClass itin> 
409   : I<opcode, OL, asmstr, itin> {
410   bits<8>  FXM;
411   bits<5>  ST;
412    
413   let Inst{6-10}  = ST;
414   let Inst{11}    = 0;
415   let Inst{12-19} = FXM;
416   let Inst{20}    = 0;
417   let Inst{21-30} = xo;
418   let Inst{31}    = 0;
419 }
420
421 class XFXForm_5a<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
422                  InstrItinClass itin> 
423   : I<opcode, OL, asmstr, itin> {
424   bits<5>  ST;
425   bits<8>  FXM;
426    
427   let Inst{6-10}  = ST;
428   let Inst{11}    = 1;
429   let Inst{12-19} = FXM;
430   let Inst{20}    = 0;
431   let Inst{21-30} = xo;
432   let Inst{31}    = 0;
433 }
434
435 class XFXForm_7<bits<6> opcode, bits<10> xo, dag OL, string asmstr,
436                 InstrItinClass itin>
437   : XFXForm_1<opcode, xo, OL, asmstr, itin>;
438
439 class XFXForm_7_ext<bits<6> opcode, bits<10> xo, bits<10> spr, 
440                     dag OL, string asmstr, InstrItinClass itin> 
441   : XFXForm_7<opcode, xo, OL, asmstr, itin> {
442   let SPR = spr;
443 }
444
445 // 1.7.10 XS-Form
446 class XSForm_1<bits<6> opcode, bits<9> xo, dag OL, string asmstr,
447                InstrItinClass itin>
448          : I<opcode, OL, asmstr, itin> {
449   bits<5> RS;
450   bits<5> A;
451   bits<6> SH;
452
453   bit RC = 0;    // set by isDOT
454
455   let Inst{6-10}  = RS;
456   let Inst{11-15} = A;
457   let Inst{16-20} = SH{1-5};
458   let Inst{21-29} = xo;
459   let Inst{30}    = SH{0};
460   let Inst{31}    = RC;
461 }
462
463 // 1.7.11 XO-Form
464 class XOForm_1<bits<6> opcode, bits<9> xo, bit oe, dag OL, string asmstr,
465                InstrItinClass itin, list<dag> pattern>
466          : I<opcode, OL, asmstr, itin> {
467   bits<5> RT;
468   bits<5> RA;
469   bits<5> RB;
470
471   let Pattern = pattern;
472
473   bit RC = 0;    // set by isDOT
474
475   let Inst{6-10}  = RT;
476   let Inst{11-15} = RA;
477   let Inst{16-20} = RB;
478   let Inst{21}    = oe;
479   let Inst{22-30} = xo;
480   let Inst{31}    = RC;  
481 }
482
483 class XOForm_3<bits<6> opcode, bits<9> xo, bit oe, 
484                dag OL, string asmstr, InstrItinClass itin, list<dag> pattern>
485   : XOForm_1<opcode, xo, oe, OL, asmstr, itin, pattern> {
486   let RB = 0;
487 }
488
489 // 1.7.12 A-Form
490 class AForm_1<bits<6> opcode, bits<5> xo, dag OL, string asmstr, 
491               InstrItinClass itin, list<dag> pattern>
492          : I<opcode, OL, asmstr, itin> {
493   bits<5> FRT;
494   bits<5> FRA;
495   bits<5> FRC;
496   bits<5> FRB;
497
498   let Pattern = pattern;
499
500   bit RC = 0;    // set by isDOT
501
502   let Inst{6-10}  = FRT;
503   let Inst{11-15} = FRA;
504   let Inst{16-20} = FRB;
505   let Inst{21-25} = FRC;
506   let Inst{26-30} = xo;
507   let Inst{31}    = RC;
508 }
509
510 class AForm_2<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
511               InstrItinClass itin, list<dag> pattern>
512   : AForm_1<opcode, xo, OL, asmstr, itin, pattern> {
513   let FRC = 0;
514 }
515
516 class AForm_3<bits<6> opcode, bits<5> xo, dag OL, string asmstr,
517               InstrItinClass itin, list<dag> pattern> 
518   : AForm_1<opcode, xo, OL, asmstr, itin, pattern> {
519   let FRB = 0;
520 }
521
522 // 1.7.13 M-Form
523 class MForm_1<bits<6> opcode, dag OL, string asmstr,
524               InstrItinClass itin, list<dag> pattern>
525     : I<opcode, OL, asmstr, itin> {
526   bits<5> RA;
527   bits<5> RS;
528   bits<5> RB;
529   bits<5> MB;
530   bits<5> ME;
531
532   let Pattern = pattern;
533
534   bit RC = 0;    // set by isDOT
535
536   let Inst{6-10}  = RS;
537   let Inst{11-15} = RA;
538   let Inst{16-20} = RB;
539   let Inst{21-25} = MB;
540   let Inst{26-30} = ME;
541   let Inst{31}    = RC;
542 }
543
544 class MForm_2<bits<6> opcode, dag OL, string asmstr,
545               InstrItinClass itin, list<dag> pattern>
546   : MForm_1<opcode, OL, asmstr, itin, pattern> {
547 }
548
549 // 1.7.14 MD-Form
550 class MDForm_1<bits<6> opcode, bits<3> xo, dag OL, string asmstr,
551                InstrItinClass itin, list<dag> pattern>
552     : I<opcode, OL, asmstr, itin> {
553   bits<5> RS;
554   bits<5> RA;
555   bits<6> SH;
556   bits<6> MBE;
557
558   let Pattern = pattern;
559
560   bit RC = 0;    // set by isDOT
561
562   let Inst{6-10}  = RS;
563   let Inst{11-15} = RA;
564   let Inst{16-20} = SH{1-5};
565   let Inst{21-26} = MBE;
566   let Inst{27-29} = xo;
567   let Inst{30}    = SH{0};
568   let Inst{31}    = RC;
569 }
570
571 // E-1 VA-Form
572 class VAForm_1<bits<6> xo, dag OL, string asmstr,
573                InstrItinClass itin, list<dag> pattern>
574     : I<4, OL, asmstr, itin> {
575   bits<5> VD;
576   bits<5> VA;
577   bits<5> VB;
578   bits<5> VC;
579
580   let Pattern = pattern;
581   
582   let Inst{6-10}  = VD;
583   let Inst{11-15} = VA;
584   let Inst{16-20} = VB;
585   let Inst{21-25} = VC;
586   let Inst{26-31} = xo;
587 }
588
589 // E-2 VX-Form
590 class VXForm_1<bits<11> xo, dag OL, string asmstr,
591                InstrItinClass itin, list<dag> pattern>
592     : I<4, OL, asmstr, itin> {
593   bits<5> VD;
594   bits<5> VA;
595   bits<5> VB;
596   
597   let Pattern = pattern;
598   
599   let Inst{6-10}  = VD;
600   let Inst{11-15} = VA;
601   let Inst{16-20} = VB;
602   let Inst{21-31} = xo;
603 }
604
605 class VXForm_setzero<bits<11> xo, dag OL, string asmstr,
606                InstrItinClass itin, list<dag> pattern>
607     : VXForm_1<xo, OL, asmstr, itin, pattern> {
608   let VA = VD;
609   let VB = VD;
610 }
611
612
613 class VXForm_2<bits<11> xo, dag OL, string asmstr,
614                InstrItinClass itin, list<dag> pattern>
615     : I<4, OL, asmstr, itin> {
616   bits<5> VD;
617   bits<5> VB;
618   
619   let Pattern = pattern;
620   
621   let Inst{6-10}  = VD;
622   let Inst{11-15} = 0;
623   let Inst{16-20} = VB;
624   let Inst{21-31} = xo;
625 }
626
627 // E-4 VXR-Form
628 class VXRForm_1<bits<10> xo, bit rc, dag OL, string asmstr,
629                InstrItinClass itin, list<dag> pattern>
630     : I<4, OL, asmstr, itin> {
631   bits<5> VD;
632   bits<5> VA;
633   bits<5> VB;
634   
635   let Pattern = pattern;
636   
637   let Inst{6-10}  = VD;
638   let Inst{11-15} = VA;
639   let Inst{16-20} = VB;
640   let Inst{21}    = rc;
641   let Inst{22-31} = xo;
642 }
643
644 //===----------------------------------------------------------------------===//
645 def NoItin : InstrItinClass;
646 class Pseudo<dag OL, string asmstr, list<dag> pattern>
647     : I<0, OL, asmstr, NoItin> {
648   let PPC64 = 0;
649   let VMX = 0;
650   let Pattern = pattern;
651   let Inst{31-0} = 0;
652 }