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