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