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