[mips][microMIPS] Implement ADDIUS5 instruction
[oota-llvm.git] / lib / Target / Mips / MicroMipsInstrFormats.td
1 //===----------------------------------------------------------------------===//
2 // MicroMIPS Base Classes
3 //===----------------------------------------------------------------------===//
4
5 //
6 // Base class for MicroMips instructions.
7 // This class does not depend on the instruction size.
8 //
9 class MicroMipsInstBase<dag outs, dag ins, string asmstr, list<dag> pattern,
10                         InstrItinClass itin, Format f> : Instruction
11 {
12   let Namespace = "Mips";
13   let DecoderNamespace = "MicroMips";
14
15   let OutOperandList = outs;
16   let InOperandList  = ins;
17
18   let AsmString   = asmstr;
19   let Pattern     = pattern;
20   let Itinerary   = itin;
21
22   let Predicates = [InMicroMips];
23
24   Format Form = f;
25 }
26
27 //
28 // Base class for MicroMIPS 16-bit instructions.
29 //
30 class MicroMipsInst16<dag outs, dag ins, string asmstr, list<dag> pattern,
31                InstrItinClass itin, Format f> :
32   MicroMipsInstBase<outs, ins, asmstr, pattern, itin, f>
33 {
34   let Size = 2;
35   field bits<16> Inst;
36   field bits<16> SoftFail = 0;
37   bits<6> Opcode = 0x0;
38 }
39
40 //===----------------------------------------------------------------------===//
41 // MicroMIPS 16-bit Instruction Formats
42 //===----------------------------------------------------------------------===//
43
44 class ADDIUS5_FM_MM16 {
45   bits<5> rd;
46   bits<4> imm;
47
48   bits<16> Inst;
49
50   let Inst{15-10} = 0x13;
51   let Inst{9-5}   = rd;
52   let Inst{4-1}   = imm;
53   let Inst{0}     = 0;
54 }
55
56 class MOVE_FM_MM16<bits<6> funct> {
57   bits<5> rs;
58   bits<5> rd;
59
60   bits<16> Inst;
61
62   let Inst{15-10} = funct;
63   let Inst{9-5}   = rd;
64   let Inst{4-0}   = rs;
65 }
66
67 class JALR_FM_MM16<bits<5> op> {
68   bits<5> rs;
69
70   bits<16> Inst;
71
72   let Inst{15-10} = 0x11;
73   let Inst{9-5}   = op;
74   let Inst{4-0}   = rs;
75 }
76
77 class MFHILO_FM_MM16<bits<5> funct> {
78   bits<5> rd;
79
80   bits<16> Inst;
81
82   let Inst{15-10} = 0x11;
83   let Inst{9-5}   = funct;
84   let Inst{4-0}   = rd;
85 }
86
87 class JRADDIUSP_FM_MM16<bits<5> op> {
88   bits<5> rs;
89   bits<5> imm;
90
91   bits<16> Inst;
92
93   let Inst{15-10} = 0x11;
94   let Inst{9-5}   = op;
95   let Inst{4-0}   = imm;
96 }
97
98 //===----------------------------------------------------------------------===//
99 // MicroMIPS 32-bit Instruction Formats
100 //===----------------------------------------------------------------------===//
101
102 class MMArch {
103   string Arch = "micromips";
104   list<dag> Pattern = [];
105 }
106
107 class ADD_FM_MM<bits<6> op, bits<10> funct> : MMArch {
108   bits<5> rt;
109   bits<5> rs;
110   bits<5> rd;
111
112   bits<32> Inst;
113
114   let Inst{31-26} = op;
115   let Inst{25-21} = rt;
116   let Inst{20-16} = rs;
117   let Inst{15-11} = rd;
118   let Inst{10}    = 0;
119   let Inst{9-0}   = funct;
120 }
121
122 class ADDI_FM_MM<bits<6> op> : MMArch {
123   bits<5>  rs;
124   bits<5>  rt;
125   bits<16> imm16;
126
127   bits<32> Inst;
128
129   let Inst{31-26} = op;
130   let Inst{25-21} = rt;
131   let Inst{20-16} = rs;
132   let Inst{15-0}  = imm16;
133 }
134
135 class SLTI_FM_MM<bits<6> op> : MMArch {
136   bits<5> rt;
137   bits<5> rs;
138   bits<16> imm16;
139
140   bits<32> Inst;
141
142   let Inst{31-26} = op;
143   let Inst{25-21} = rt;
144   let Inst{20-16} = rs;
145   let Inst{15-0}  = imm16;
146 }
147
148 class LUI_FM_MM : MMArch {
149   bits<5> rt;
150   bits<16> imm16;
151
152   bits<32> Inst;
153
154   let Inst{31-26} = 0x10;
155   let Inst{25-21} = 0xd;
156   let Inst{20-16} = rt;
157   let Inst{15-0}  = imm16;
158 }
159
160 class MULT_FM_MM<bits<10> funct> : MMArch {
161   bits<5>  rs;
162   bits<5>  rt;
163
164   bits<32> Inst;
165
166   let Inst{31-26} = 0x00;
167   let Inst{25-21} = rt;
168   let Inst{20-16} = rs;
169   let Inst{15-6}  = funct;
170   let Inst{5-0}   = 0x3c;
171 }
172
173 class SRA_FM_MM<bits<10> funct, bit rotate> : MMArch {
174   bits<5> rd;
175   bits<5> rt;
176   bits<5> shamt;
177
178   bits<32> Inst;
179
180   let Inst{31-26} = 0;
181   let Inst{25-21} = rd;
182   let Inst{20-16} = rt;
183   let Inst{15-11} = shamt;
184   let Inst{10}    = rotate;
185   let Inst{9-0}   = funct;
186 }
187
188 class SRLV_FM_MM<bits<10> funct, bit rotate> : MMArch {
189   bits<5> rd;
190   bits<5> rt;
191   bits<5> rs;
192
193   bits<32> Inst;
194
195   let Inst{31-26} = 0;
196   let Inst{25-21} = rt;
197   let Inst{20-16} = rs;
198   let Inst{15-11} = rd;
199   let Inst{10}    = rotate;
200   let Inst{9-0}   = funct;
201 }
202
203 class LW_FM_MM<bits<6> op> : MMArch {
204   bits<5> rt;
205   bits<21> addr;
206
207   bits<32> Inst;
208
209   let Inst{31-26} = op;
210   let Inst{25-21} = rt;
211   let Inst{20-16} = addr{20-16};
212   let Inst{15-0}  = addr{15-0};
213 }
214
215 class LWL_FM_MM<bits<4> funct> {
216   bits<5> rt;
217   bits<21> addr;
218
219   bits<32> Inst;
220
221   let Inst{31-26} = 0x18;
222   let Inst{25-21} = rt;
223   let Inst{20-16} = addr{20-16};
224   let Inst{15-12} = funct;
225   let Inst{11-0}  = addr{11-0};
226 }
227
228 class CMov_F_I_FM_MM<bits<7> func> : MMArch {
229   bits<5> rd;
230   bits<5> rs;
231   bits<3> fcc;
232
233   bits<32> Inst;
234
235   let Inst{31-26} = 0x15;
236   let Inst{25-21} = rd;
237   let Inst{20-16} = rs;
238   let Inst{15-13} = fcc;
239   let Inst{12-6}  = func;
240   let Inst{5-0}   = 0x3b;
241 }
242
243 class MTLO_FM_MM<bits<10> funct> : MMArch {
244   bits<5> rs;
245
246   bits<32> Inst;
247
248   let Inst{31-26} = 0x00;
249   let Inst{25-21} = 0x00;
250   let Inst{20-16} = rs;
251   let Inst{15-6}  = funct;
252   let Inst{5-0}   = 0x3c;
253 }
254
255 class MFLO_FM_MM<bits<10> funct> : MMArch {
256   bits<5> rd;
257
258   bits<32> Inst;
259
260   let Inst{31-26} = 0x00;
261   let Inst{25-21} = 0x00;
262   let Inst{20-16} = rd;
263   let Inst{15-6}  = funct;
264   let Inst{5-0}   = 0x3c;
265 }
266
267 class CLO_FM_MM<bits<10> funct> : MMArch {
268   bits<5> rd;
269   bits<5> rs;
270
271   bits<32> Inst;
272
273   let Inst{31-26} = 0x00;
274   let Inst{25-21} = rd;
275   let Inst{20-16} = rs;
276   let Inst{15-6}  = funct;
277   let Inst{5-0}   = 0x3c;
278 }
279
280 class SEB_FM_MM<bits<10> funct> : MMArch {
281   bits<5> rd;
282   bits<5> rt;
283
284   bits<32> Inst;
285
286   let Inst{31-26} = 0x00;
287   let Inst{25-21} = rd;
288   let Inst{20-16} = rt;
289   let Inst{15-6}  = funct;
290   let Inst{5-0}   = 0x3c;
291 }
292
293 class EXT_FM_MM<bits<6> funct> : MMArch {
294   bits<5> rt;
295   bits<5> rs;
296   bits<5> pos;
297   bits<5> size;
298
299   bits<32> Inst;
300
301   let Inst{31-26} = 0x00;
302   let Inst{25-21} = rt;
303   let Inst{20-16} = rs;
304   let Inst{15-11} = size;
305   let Inst{10-6}  = pos;
306   let Inst{5-0}   = funct;
307 }
308
309 class J_FM_MM<bits<6> op> : MMArch {
310   bits<26> target;
311
312   bits<32> Inst;
313
314   let Inst{31-26} = op;
315   let Inst{25-0}  = target;
316 }
317
318 class JR_FM_MM<bits<8> funct> : MMArch {
319   bits<5> rs;
320
321   bits<32> Inst;
322
323   let Inst{31-21} = 0x00;
324   let Inst{20-16} = rs;
325   let Inst{15-14} = 0x0;
326   let Inst{13-6}  = funct;
327   let Inst{5-0}   = 0x3c;
328 }
329
330 class JALR_FM_MM<bits<10> funct> {
331   bits<5> rs;
332   bits<5> rd;
333
334   bits<32> Inst;
335
336   let Inst{31-26} = 0x00;
337   let Inst{25-21} = rd;
338   let Inst{20-16} = rs;
339   let Inst{15-6}  = funct;
340   let Inst{5-0}   = 0x3c;
341 }
342
343 class BEQ_FM_MM<bits<6> op> : MMArch {
344   bits<5>  rs;
345   bits<5>  rt;
346   bits<16> offset;
347
348   bits<32> Inst;
349
350   let Inst{31-26} = op;
351   let Inst{25-21} = rt;
352   let Inst{20-16} = rs;
353   let Inst{15-0}  = offset;
354 }
355
356 class BGEZ_FM_MM<bits<5> funct> : MMArch {
357   bits<5>  rs;
358   bits<16> offset;
359
360   bits<32> Inst;
361
362   let Inst{31-26} = 0x10;
363   let Inst{25-21} = funct;
364   let Inst{20-16} = rs;
365   let Inst{15-0}  = offset;
366 }
367
368 class BGEZAL_FM_MM<bits<5> funct> : MMArch {
369   bits<5>  rs;
370   bits<16> offset;
371
372   bits<32> Inst;
373
374   let Inst{31-26} = 0x10;
375   let Inst{25-21} = funct;
376   let Inst{20-16} = rs;
377   let Inst{15-0}  = offset;
378 }
379
380 class SYNC_FM_MM : MMArch {
381   bits<5> stype;
382
383   bits<32> Inst;
384
385   let Inst{31-26} = 0x00;
386   let Inst{25-21} = 0x0;
387   let Inst{20-16} = stype;
388   let Inst{15-6}  = 0x1ad;
389   let Inst{5-0}   = 0x3c;
390 }
391
392 class BRK_FM_MM : MMArch {
393   bits<10> code_1;
394   bits<10> code_2;
395   bits<32> Inst;
396   let Inst{31-26} = 0x0;
397   let Inst{25-16} = code_1;
398   let Inst{15-6}  = code_2;
399   let Inst{5-0}   = 0x07;
400 }
401
402 class SYS_FM_MM : MMArch {
403   bits<10> code_;
404   bits<32> Inst;
405   let Inst{31-26} = 0x0;
406   let Inst{25-16} = code_;
407   let Inst{15-6}  = 0x22d;
408   let Inst{5-0}   = 0x3c;
409 }
410
411 class WAIT_FM_MM {
412   bits<10> code_;
413   bits<32> Inst;
414
415   let Inst{31-26} = 0x00;
416   let Inst{25-16} = code_;
417   let Inst{15-6}  = 0x24d;
418   let Inst{5-0}   = 0x3c;
419 }
420
421 class ER_FM_MM<bits<10> funct> : MMArch {
422   bits<32> Inst;
423
424   let Inst{31-26} = 0x00;
425   let Inst{25-16} = 0x00;
426   let Inst{15-6}  = funct;
427   let Inst{5-0}   = 0x3c;
428 }
429
430 class EI_FM_MM<bits<10> funct> : MMArch {
431   bits<32> Inst;
432   bits<5> rt;
433
434   let Inst{31-26} = 0x00;
435   let Inst{25-21} = 0x00;
436   let Inst{20-16} = rt;
437   let Inst{15-6}  = funct;
438   let Inst{5-0}   = 0x3c;
439 }
440
441 class TEQ_FM_MM<bits<6> funct> : MMArch {
442   bits<5> rs;
443   bits<5> rt;
444   bits<4> code_;
445
446   bits<32> Inst;
447
448   let Inst{31-26} = 0x00;
449   let Inst{25-21} = rt;
450   let Inst{20-16} = rs;
451   let Inst{15-12} = code_;
452   let Inst{11-6}  = funct;
453   let Inst{5-0}   = 0x3c;
454 }
455
456 class TEQI_FM_MM<bits<5> funct> : MMArch {
457   bits<5> rs;
458   bits<16> imm16;
459
460   bits<32> Inst;
461
462   let Inst{31-26} = 0x10;
463   let Inst{25-21} = funct;
464   let Inst{20-16} = rs;
465   let Inst{15-0}  = imm16;
466 }
467
468 class LL_FM_MM<bits<4> funct> {
469   bits<5> rt;
470   bits<21> addr;
471
472   bits<32> Inst;
473
474   let Inst{31-26} = 0x18;
475   let Inst{25-21} = rt;
476   let Inst{20-16} = addr{20-16};
477   let Inst{15-12} = funct;
478   let Inst{11-0}  = addr{11-0};
479 }
480
481 class ADDS_FM_MM<bits<2> fmt, bits<8> funct> : MMArch {
482   bits<5> ft;
483   bits<5> fs;
484   bits<5> fd;
485
486   bits<32> Inst;
487
488   let Inst{31-26} = 0x15;
489   let Inst{25-21} = ft;
490   let Inst{20-16} = fs;
491   let Inst{15-11} = fd;
492   let Inst{10}    = 0;
493   let Inst{9-8}   = fmt;
494   let Inst{7-0}   = funct;
495
496   list<dag> Pattern = [];
497 }
498
499 class LWXC1_FM_MM<bits<9> funct> : MMArch {
500   bits<5> fd;
501   bits<5> base;
502   bits<5> index;
503
504   bits<32> Inst;
505
506   let Inst{31-26} = 0x15;
507   let Inst{25-21} = index;
508   let Inst{20-16} = base;
509   let Inst{15-11} = fd;
510   let Inst{10-9}  = 0x0;
511   let Inst{8-0}   = funct;
512 }
513
514 class SWXC1_FM_MM<bits<9> funct> : MMArch {
515   bits<5> fs;
516   bits<5> base;
517   bits<5> index;
518
519   bits<32> Inst;
520
521   let Inst{31-26} = 0x15;
522   let Inst{25-21} = index;
523   let Inst{20-16} = base;
524   let Inst{15-11} = fs;
525   let Inst{10-9}  = 0x0;
526   let Inst{8-0}   = funct;
527 }
528
529 class CEQS_FM_MM<bits<2> fmt> : MMArch {
530   bits<5> fs;
531   bits<5> ft;
532   bits<4> cond;
533
534   bits<32> Inst;
535
536   let Inst{31-26} = 0x15;
537   let Inst{25-21} = ft;
538   let Inst{20-16} = fs;
539   let Inst{15-13} = 0x0;  // cc
540   let Inst{12}    = 0;
541   let Inst{11-10} = fmt;
542   let Inst{9-6}   = cond;
543   let Inst{5-0}   = 0x3c;
544 }
545
546 class BC1F_FM_MM<bits<5> tf> : MMArch {
547   bits<16> offset;
548
549   bits<32> Inst;
550
551   let Inst{31-26} = 0x10;
552   let Inst{25-21} = tf;
553   let Inst{20-18} = 0x0; // cc
554   let Inst{17-16} = 0x0;
555   let Inst{15-0}  = offset;
556 }
557
558 class ROUND_W_FM_MM<bits<1> fmt, bits<8> funct> : MMArch {
559   bits<5> fd;
560   bits<5> fs;
561
562   bits<32> Inst;
563
564   let Inst{31-26} = 0x15;
565   let Inst{25-21} = fd;
566   let Inst{20-16} = fs;
567   let Inst{15}    = 0;
568   let Inst{14}    = fmt;
569   let Inst{13-6}  = funct;
570   let Inst{5-0}   = 0x3b;
571 }
572
573 class ABS_FM_MM<bits<2> fmt, bits<7> funct> : MMArch {
574   bits<5> fd;
575   bits<5> fs;
576
577   bits<32> Inst;
578
579   let Inst{31-26} = 0x15;
580   let Inst{25-21} = fd;
581   let Inst{20-16} = fs;
582   let Inst{15}    = 0;
583   let Inst{14-13} = fmt;
584   let Inst{12-6}  = funct;
585   let Inst{5-0}   = 0x3b;
586 }
587
588 class CMov_F_F_FM_MM<bits<9> func, bits<2> fmt> : MMArch {
589   bits<5> fd;
590   bits<5> fs;
591
592   bits<32> Inst;
593
594   let Inst{31-26} = 0x15;
595   let Inst{25-21} = fd;
596   let Inst{20-16} = fs;
597   let Inst{15-13} = 0x0; //cc
598   let Inst{12-11} = 0x0;
599   let Inst{10-9}  = fmt;
600   let Inst{8-0}   = func;
601 }
602
603 class CMov_I_F_FM_MM<bits<8> funct, bits<2> fmt> : MMArch {
604   bits<5> fd;
605   bits<5> fs;
606   bits<5> rt;
607
608   bits<32> Inst;
609
610   let Inst{31-26} = 0x15;
611   let Inst{25-21} = rt;
612   let Inst{20-16} = fs;
613   let Inst{15-11} = fd;
614   let Inst{9-8}   = fmt;
615   let Inst{7-0}   = funct;
616 }
617
618 class MFC1_FM_MM<bits<8> funct> : MMArch {
619   bits<5> rt;
620   bits<5> fs;
621
622   bits<32> Inst;
623
624   let Inst{31-26} = 0x15;
625   let Inst{25-21} = rt;
626   let Inst{20-16} = fs;
627   let Inst{15-14} = 0x0;
628   let Inst{13-6}  = funct;
629   let Inst{5-0}   = 0x3b;
630 }
631
632 class MADDS_FM_MM<bits<6> funct>: MMArch {
633   bits<5> ft;
634   bits<5> fs;
635   bits<5> fd;
636   bits<5> fr;
637
638   bits<32> Inst;
639
640   let Inst{31-26} = 0x15;
641   let Inst{25-21} = ft;
642   let Inst{20-16} = fs;
643   let Inst{15-11} = fd;
644   let Inst{10-6}  = fr;
645   let Inst{5-0}   = funct;
646 }
647
648 class COMPACT_BRANCH_FM_MM<bits<5> funct> {
649   bits<5>  rs;
650   bits<16> offset;
651
652   bits<32> Inst;
653
654   let Inst{31-26} = 0x10;
655   let Inst{25-21} = funct;
656   let Inst{20-16} = rs;
657   let Inst{15-0}  = offset;
658 }
659
660 class COP0_TLB_FM_MM<bits<10> op> : MMArch {
661   bits<32> Inst;
662
663   let Inst{31-26} = 0x0;
664   let Inst{25-16} = 0x0;
665   let Inst{15-6}  = op;
666   let Inst{5-0}   = 0x3c;
667 }