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