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