blob: 90ee077347e143f3ddcfe19547c823ddeee81bb9 [file] [log] [blame]
Zoran Jovanovic87d13e52014-03-20 10:18:24 +00001//===----------------------------------------------------------------------===//
2// MicroMIPS Base Classes
3//===----------------------------------------------------------------------===//
4
5//
6// Base class for MicroMips instructions.
7// This class does not depend on the instruction size.
8//
9class 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//
30class 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
Zoran Jovanovic592239d2014-10-21 08:44:58 +000044class 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
Zoran Jovanovic81ceebc2014-10-21 08:32:40 +000058class 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
Zoran Jovanovic4a00fdc2014-10-23 10:42:01 +000070class SHIFT_FM_MM16<bits<1> funct> {
71 bits<3> rd;
72 bits<3> rt;
73 bits<3> shamt;
74
75 bits<16> Inst;
76
77 let Inst{15-10} = 0x09;
78 let Inst{9-7} = rd;
79 let Inst{6-4} = rt;
80 let Inst{3-1} = shamt;
81 let Inst{0} = funct;
82}
83
Zoran Jovanovicb26f8892014-10-10 13:45:34 +000084class ADDIUS5_FM_MM16 {
85 bits<5> rd;
86 bits<4> imm;
87
88 bits<16> Inst;
89
90 let Inst{15-10} = 0x13;
91 let Inst{9-5} = rd;
92 let Inst{4-1} = imm;
93 let Inst{0} = 0;
94}
95
Zoran Jovanovic98bd58c2014-10-10 14:37:30 +000096class ADDIUSP_FM_MM16 {
97 bits<9> imm;
98
99 bits<16> Inst;
100
101 let Inst{15-10} = 0x13;
102 let Inst{9-1} = imm;
103 let Inst{0} = 1;
104}
105
Zoran Jovanovic87d13e52014-03-20 10:18:24 +0000106class MOVE_FM_MM16<bits<6> funct> {
107 bits<5> rs;
108 bits<5> rd;
109
110 bits<16> Inst;
111
112 let Inst{15-10} = funct;
113 let Inst{9-5} = rd;
114 let Inst{4-0} = rs;
115}
116
117class JALR_FM_MM16<bits<5> op> {
118 bits<5> rs;
119
120 bits<16> Inst;
121
122 let Inst{15-10} = 0x11;
123 let Inst{9-5} = op;
124 let Inst{4-0} = rs;
125}
126
Zoran Jovanoviccabf0f42014-04-03 12:47:34 +0000127class MFHILO_FM_MM16<bits<5> funct> {
128 bits<5> rd;
129
130 bits<16> Inst;
131
132 let Inst{15-10} = 0x11;
133 let Inst{9-5} = funct;
134 let Inst{4-0} = rd;
135}
136
Zoran Jovanovicc74e3eb92014-09-12 14:29:54 +0000137class JRADDIUSP_FM_MM16<bits<5> op> {
138 bits<5> rs;
139 bits<5> imm;
140
141 bits<16> Inst;
142
143 let Inst{15-10} = 0x11;
144 let Inst{9-5} = op;
145 let Inst{4-0} = imm;
146}
147
Zoran Jovanovic87d13e52014-03-20 10:18:24 +0000148//===----------------------------------------------------------------------===//
149// MicroMIPS 32-bit Instruction Formats
150//===----------------------------------------------------------------------===//
151
Akira Hatanakabe6a8182013-04-19 19:03:11 +0000152class MMArch {
153 string Arch = "micromips";
154 list<dag> Pattern = [];
155}
156
157class ADD_FM_MM<bits<6> op, bits<10> funct> : MMArch {
158 bits<5> rt;
159 bits<5> rs;
160 bits<5> rd;
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-11} = rd;
168 let Inst{10} = 0;
169 let Inst{9-0} = funct;
170}
171
172class ADDI_FM_MM<bits<6> op> : MMArch {
173 bits<5> rs;
174 bits<5> rt;
175 bits<16> imm16;
176
177 bits<32> Inst;
178
179 let Inst{31-26} = op;
180 let Inst{25-21} = rt;
181 let Inst{20-16} = rs;
182 let Inst{15-0} = imm16;
183}
184
185class SLTI_FM_MM<bits<6> op> : MMArch {
186 bits<5> rt;
187 bits<5> rs;
188 bits<16> imm16;
189
190 bits<32> Inst;
191
192 let Inst{31-26} = op;
Zoran Jovanovicf4d4d782013-11-15 08:07:34 +0000193 let Inst{25-21} = rt;
194 let Inst{20-16} = rs;
Akira Hatanakabe6a8182013-04-19 19:03:11 +0000195 let Inst{15-0} = imm16;
196}
197
198class LUI_FM_MM : MMArch {
199 bits<5> rt;
200 bits<16> imm16;
201
202 bits<32> Inst;
203
204 let Inst{31-26} = 0x10;
205 let Inst{25-21} = 0xd;
206 let Inst{20-16} = rt;
207 let Inst{15-0} = imm16;
208}
209
210class MULT_FM_MM<bits<10> funct> : MMArch {
211 bits<5> rs;
212 bits<5> rt;
213
214 bits<32> Inst;
215
216 let Inst{31-26} = 0x00;
217 let Inst{25-21} = rt;
218 let Inst{20-16} = rs;
219 let Inst{15-6} = funct;
220 let Inst{5-0} = 0x3c;
221}
Akira Hatanakacd9b74a2013-04-25 01:11:15 +0000222
223class SRA_FM_MM<bits<10> funct, bit rotate> : MMArch {
224 bits<5> rd;
225 bits<5> rt;
226 bits<5> shamt;
227
228 bits<32> Inst;
229
230 let Inst{31-26} = 0;
231 let Inst{25-21} = rd;
232 let Inst{20-16} = rt;
233 let Inst{15-11} = shamt;
234 let Inst{10} = rotate;
235 let Inst{9-0} = funct;
236}
237
238class SRLV_FM_MM<bits<10> funct, bit rotate> : MMArch {
239 bits<5> rd;
240 bits<5> rt;
241 bits<5> rs;
242
243 bits<32> Inst;
244
245 let Inst{31-26} = 0;
246 let Inst{25-21} = rt;
247 let Inst{20-16} = rs;
248 let Inst{15-11} = rd;
249 let Inst{10} = rotate;
250 let Inst{9-0} = funct;
251}
Akira Hatanakaf0aa6c92013-04-25 01:21:25 +0000252
253class LW_FM_MM<bits<6> op> : MMArch {
254 bits<5> rt;
255 bits<21> addr;
256
257 bits<32> Inst;
258
259 let Inst{31-26} = op;
260 let Inst{25-21} = rt;
261 let Inst{20-16} = addr{20-16};
262 let Inst{15-0} = addr{15-0};
263}
Jack Carter97700972013-08-13 20:19:16 +0000264
265class LWL_FM_MM<bits<4> funct> {
266 bits<5> rt;
267 bits<21> addr;
268
269 bits<32> Inst;
270
271 let Inst{31-26} = 0x18;
272 let Inst{25-21} = rt;
273 let Inst{20-16} = addr{20-16};
274 let Inst{15-12} = funct;
275 let Inst{11-0} = addr{11-0};
276}
Vladimir Medice0fbb442013-09-06 12:41:17 +0000277
278class CMov_F_I_FM_MM<bits<7> func> : MMArch {
279 bits<5> rd;
280 bits<5> rs;
281 bits<3> fcc;
282
283 bits<32> Inst;
284
285 let Inst{31-26} = 0x15;
286 let Inst{25-21} = rd;
287 let Inst{20-16} = rs;
288 let Inst{15-13} = fcc;
289 let Inst{12-6} = func;
290 let Inst{5-0} = 0x3b;
291}
Vladimir Medic457ba562013-09-06 12:53:21 +0000292
293class MTLO_FM_MM<bits<10> funct> : MMArch {
294 bits<5> rs;
295
296 bits<32> Inst;
297
298 let Inst{31-26} = 0x00;
299 let Inst{25-21} = 0x00;
300 let Inst{20-16} = rs;
301 let Inst{15-6} = funct;
302 let Inst{5-0} = 0x3c;
303}
304
305class MFLO_FM_MM<bits<10> funct> : MMArch {
306 bits<5> rd;
307
308 bits<32> Inst;
309
310 let Inst{31-26} = 0x00;
311 let Inst{25-21} = 0x00;
312 let Inst{20-16} = rd;
313 let Inst{15-6} = funct;
314 let Inst{5-0} = 0x3c;
315}
Zoran Jovanovicab852782013-09-14 06:49:25 +0000316
317class CLO_FM_MM<bits<10> funct> : MMArch {
318 bits<5> rd;
319 bits<5> rs;
320
321 bits<32> Inst;
322
323 let Inst{31-26} = 0x00;
324 let Inst{25-21} = rd;
325 let Inst{20-16} = rs;
326 let Inst{15-6} = funct;
327 let Inst{5-0} = 0x3c;
328}
329
330class SEB_FM_MM<bits<10> funct> : MMArch {
331 bits<5> rd;
332 bits<5> rt;
333
334 bits<32> Inst;
335
336 let Inst{31-26} = 0x00;
337 let Inst{25-21} = rd;
338 let Inst{20-16} = rt;
339 let Inst{15-6} = funct;
340 let Inst{5-0} = 0x3c;
341}
342
343class EXT_FM_MM<bits<6> funct> : MMArch {
344 bits<5> rt;
345 bits<5> rs;
346 bits<5> pos;
347 bits<5> size;
348
349 bits<32> Inst;
350
351 let Inst{31-26} = 0x00;
352 let Inst{25-21} = rt;
353 let Inst{20-16} = rs;
354 let Inst{15-11} = size;
355 let Inst{10-6} = pos;
356 let Inst{5-0} = funct;
357}
Zoran Jovanovic507e0842013-10-29 16:38:59 +0000358
359class J_FM_MM<bits<6> op> : MMArch {
360 bits<26> target;
361
362 bits<32> Inst;
363
364 let Inst{31-26} = op;
365 let Inst{25-0} = target;
366}
367
368class JR_FM_MM<bits<8> funct> : MMArch {
369 bits<5> rs;
370
371 bits<32> Inst;
372
373 let Inst{31-21} = 0x00;
374 let Inst{20-16} = rs;
375 let Inst{15-14} = 0x0;
376 let Inst{13-6} = funct;
377 let Inst{5-0} = 0x3c;
378}
379
Zoran Jovanovic87d13e52014-03-20 10:18:24 +0000380class JALR_FM_MM<bits<10> funct> {
Zoran Jovanovic507e0842013-10-29 16:38:59 +0000381 bits<5> rs;
382 bits<5> rd;
383
384 bits<32> Inst;
385
386 let Inst{31-26} = 0x00;
387 let Inst{25-21} = rd;
388 let Inst{20-16} = rs;
389 let Inst{15-6} = funct;
390 let Inst{5-0} = 0x3c;
391}
Zoran Jovanovic8a80aa72013-11-04 14:53:22 +0000392
393class BEQ_FM_MM<bits<6> op> : MMArch {
394 bits<5> rs;
395 bits<5> rt;
396 bits<16> offset;
397
398 bits<32> Inst;
399
400 let Inst{31-26} = op;
401 let Inst{25-21} = rt;
402 let Inst{20-16} = rs;
403 let Inst{15-0} = offset;
404}
405
406class BGEZ_FM_MM<bits<5> funct> : MMArch {
407 bits<5> rs;
408 bits<16> offset;
409
410 bits<32> Inst;
411
412 let Inst{31-26} = 0x10;
413 let Inst{25-21} = funct;
414 let Inst{20-16} = rs;
415 let Inst{15-0} = offset;
416}
417
418class BGEZAL_FM_MM<bits<5> funct> : MMArch {
419 bits<5> rs;
420 bits<16> offset;
421
422 bits<32> Inst;
423
424 let Inst{31-26} = 0x10;
425 let Inst{25-21} = funct;
426 let Inst{20-16} = rs;
427 let Inst{15-0} = offset;
428}
Zoran Jovanovicc18b6d12013-11-07 14:35:24 +0000429
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000430class SYNC_FM_MM : MMArch {
431 bits<5> stype;
432
433 bits<32> Inst;
434
435 let Inst{31-26} = 0x00;
436 let Inst{25-21} = 0x0;
437 let Inst{20-16} = stype;
438 let Inst{15-6} = 0x1ad;
439 let Inst{5-0} = 0x3c;
440}
441
442class BRK_FM_MM : MMArch {
443 bits<10> code_1;
444 bits<10> code_2;
445 bits<32> Inst;
446 let Inst{31-26} = 0x0;
447 let Inst{25-16} = code_1;
448 let Inst{15-6} = code_2;
449 let Inst{5-0} = 0x07;
450}
451
452class SYS_FM_MM : MMArch {
453 bits<10> code_;
454 bits<32> Inst;
455 let Inst{31-26} = 0x0;
456 let Inst{25-16} = code_;
Zoran Jovanovic7c6c36d2014-02-28 18:17:08 +0000457 let Inst{15-6} = 0x22d;
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000458 let Inst{5-0} = 0x3c;
459}
460
Zoran Jovanovica0f53282014-03-20 10:41:37 +0000461class WAIT_FM_MM {
462 bits<10> code_;
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000463 bits<32> Inst;
464
465 let Inst{31-26} = 0x00;
Zoran Jovanovica0f53282014-03-20 10:41:37 +0000466 let Inst{25-16} = code_;
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000467 let Inst{15-6} = 0x24d;
468 let Inst{5-0} = 0x3c;
469}
470
471class ER_FM_MM<bits<10> funct> : MMArch {
472 bits<32> Inst;
473
474 let Inst{31-26} = 0x00;
475 let Inst{25-16} = 0x00;
476 let Inst{15-6} = funct;
477 let Inst{5-0} = 0x3c;
478}
479
480class EI_FM_MM<bits<10> funct> : MMArch {
481 bits<32> Inst;
482 bits<5> rt;
483
484 let Inst{31-26} = 0x00;
485 let Inst{25-21} = 0x00;
486 let Inst{20-16} = rt;
487 let Inst{15-6} = funct;
488 let Inst{5-0} = 0x3c;
489}
490
Zoran Jovanovicc18b6d12013-11-07 14:35:24 +0000491class TEQ_FM_MM<bits<6> funct> : MMArch {
492 bits<5> rs;
493 bits<5> rt;
494 bits<4> code_;
495
496 bits<32> Inst;
497
498 let Inst{31-26} = 0x00;
499 let Inst{25-21} = rt;
500 let Inst{20-16} = rs;
501 let Inst{15-12} = code_;
502 let Inst{11-6} = funct;
503 let Inst{5-0} = 0x3c;
504}
Zoran Jovanovicccb70ca2013-11-13 13:15:03 +0000505
506class TEQI_FM_MM<bits<5> funct> : MMArch {
507 bits<5> rs;
508 bits<16> imm16;
509
510 bits<32> Inst;
511
512 let Inst{31-26} = 0x10;
513 let Inst{25-21} = funct;
514 let Inst{20-16} = rs;
515 let Inst{15-0} = imm16;
516}
Zoran Jovanovicff9d5f32013-12-19 16:12:56 +0000517
518class LL_FM_MM<bits<4> funct> {
519 bits<5> rt;
520 bits<21> addr;
521
522 bits<32> Inst;
523
524 let Inst{31-26} = 0x18;
525 let Inst{25-21} = rt;
526 let Inst{20-16} = addr{20-16};
527 let Inst{15-12} = funct;
528 let Inst{11-0} = addr{11-0};
529}
Zoran Jovanovicce024862013-12-20 15:44:08 +0000530
531class ADDS_FM_MM<bits<2> fmt, bits<8> funct> : MMArch {
532 bits<5> ft;
533 bits<5> fs;
534 bits<5> fd;
535
536 bits<32> Inst;
537
538 let Inst{31-26} = 0x15;
539 let Inst{25-21} = ft;
540 let Inst{20-16} = fs;
541 let Inst{15-11} = fd;
542 let Inst{10} = 0;
543 let Inst{9-8} = fmt;
544 let Inst{7-0} = funct;
545
546 list<dag> Pattern = [];
547}
548
549class LWXC1_FM_MM<bits<9> funct> : MMArch {
550 bits<5> fd;
551 bits<5> base;
552 bits<5> index;
553
554 bits<32> Inst;
555
556 let Inst{31-26} = 0x15;
557 let Inst{25-21} = index;
558 let Inst{20-16} = base;
559 let Inst{15-11} = fd;
560 let Inst{10-9} = 0x0;
561 let Inst{8-0} = funct;
562}
563
564class SWXC1_FM_MM<bits<9> funct> : MMArch {
565 bits<5> fs;
566 bits<5> base;
567 bits<5> index;
568
569 bits<32> Inst;
570
571 let Inst{31-26} = 0x15;
572 let Inst{25-21} = index;
573 let Inst{20-16} = base;
574 let Inst{15-11} = fs;
575 let Inst{10-9} = 0x0;
576 let Inst{8-0} = funct;
577}
578
579class CEQS_FM_MM<bits<2> fmt> : MMArch {
580 bits<5> fs;
581 bits<5> ft;
582 bits<4> cond;
583
584 bits<32> Inst;
585
586 let Inst{31-26} = 0x15;
587 let Inst{25-21} = ft;
588 let Inst{20-16} = fs;
589 let Inst{15-13} = 0x0; // cc
590 let Inst{12} = 0;
591 let Inst{11-10} = fmt;
592 let Inst{9-6} = cond;
593 let Inst{5-0} = 0x3c;
594}
595
596class BC1F_FM_MM<bits<5> tf> : MMArch {
597 bits<16> offset;
598
599 bits<32> Inst;
600
601 let Inst{31-26} = 0x10;
602 let Inst{25-21} = tf;
603 let Inst{20-18} = 0x0; // cc
604 let Inst{17-16} = 0x0;
605 let Inst{15-0} = offset;
606}
607
608class ROUND_W_FM_MM<bits<1> fmt, bits<8> funct> : MMArch {
609 bits<5> fd;
610 bits<5> fs;
611
612 bits<32> Inst;
613
614 let Inst{31-26} = 0x15;
615 let Inst{25-21} = fd;
616 let Inst{20-16} = fs;
617 let Inst{15} = 0;
618 let Inst{14} = fmt;
619 let Inst{13-6} = funct;
620 let Inst{5-0} = 0x3b;
621}
622
623class ABS_FM_MM<bits<2> fmt, bits<7> funct> : MMArch {
624 bits<5> fd;
625 bits<5> fs;
626
627 bits<32> Inst;
628
629 let Inst{31-26} = 0x15;
630 let Inst{25-21} = fd;
631 let Inst{20-16} = fs;
632 let Inst{15} = 0;
633 let Inst{14-13} = fmt;
634 let Inst{12-6} = funct;
635 let Inst{5-0} = 0x3b;
636}
Zoran Jovanovic8876be32013-12-25 10:09:27 +0000637
638class CMov_F_F_FM_MM<bits<9> func, bits<2> fmt> : MMArch {
639 bits<5> fd;
640 bits<5> fs;
641
642 bits<32> Inst;
643
644 let Inst{31-26} = 0x15;
645 let Inst{25-21} = fd;
646 let Inst{20-16} = fs;
647 let Inst{15-13} = 0x0; //cc
648 let Inst{12-11} = 0x0;
649 let Inst{10-9} = fmt;
650 let Inst{8-0} = func;
651}
652
653class CMov_I_F_FM_MM<bits<8> funct, bits<2> fmt> : MMArch {
654 bits<5> fd;
655 bits<5> fs;
656 bits<5> rt;
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-11} = fd;
664 let Inst{9-8} = fmt;
665 let Inst{7-0} = funct;
666}
667
668class MFC1_FM_MM<bits<8> funct> : MMArch {
669 bits<5> rt;
670 bits<5> fs;
671
672 bits<32> Inst;
673
674 let Inst{31-26} = 0x15;
675 let Inst{25-21} = rt;
676 let Inst{20-16} = fs;
677 let Inst{15-14} = 0x0;
678 let Inst{13-6} = funct;
679 let Inst{5-0} = 0x3b;
680}
681
682class MADDS_FM_MM<bits<6> funct>: MMArch {
683 bits<5> ft;
684 bits<5> fs;
685 bits<5> fd;
686 bits<5> fr;
687
688 bits<32> Inst;
689
690 let Inst{31-26} = 0x15;
691 let Inst{25-21} = ft;
692 let Inst{20-16} = fs;
693 let Inst{15-11} = fd;
694 let Inst{10-6} = fr;
695 let Inst{5-0} = funct;
696}
Zoran Jovanovic73ff9482014-08-14 12:09:10 +0000697
698class COMPACT_BRANCH_FM_MM<bits<5> funct> {
699 bits<5> rs;
700 bits<16> offset;
701
702 bits<32> Inst;
703
704 let Inst{31-26} = 0x10;
705 let Inst{25-21} = funct;
706 let Inst{20-16} = rs;
707 let Inst{15-0} = offset;
708}
Zoran Jovanovic4e7ac4a2014-09-12 13:33:33 +0000709
710class COP0_TLB_FM_MM<bits<10> op> : MMArch {
711 bits<32> Inst;
712
713 let Inst{31-26} = 0x0;
714 let Inst{25-16} = 0x0;
715 let Inst{15-6} = op;
716 let Inst{5-0} = 0x3c;
717}