blob: ae80b4f7e6d05d8c1b5dd91fb44a1fa9bcc0a90f [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
Zoran Jovanovic9bda2f12014-10-23 10:59:24 +0000117class LI_FM_MM16 {
118 bits<3> rd;
119 bits<7> imm;
120
121 bits<16> Inst;
122
123 let Inst{15-10} = 0x3b;
124 let Inst{9-7} = rd;
125 let Inst{6-0} = imm;
126}
127
Zoran Jovanovic87d13e52014-03-20 10:18:24 +0000128class JALR_FM_MM16<bits<5> op> {
129 bits<5> rs;
130
131 bits<16> Inst;
132
133 let Inst{15-10} = 0x11;
134 let Inst{9-5} = op;
135 let Inst{4-0} = rs;
136}
137
Zoran Jovanoviccabf0f42014-04-03 12:47:34 +0000138class MFHILO_FM_MM16<bits<5> funct> {
139 bits<5> rd;
140
141 bits<16> Inst;
142
143 let Inst{15-10} = 0x11;
144 let Inst{9-5} = funct;
145 let Inst{4-0} = rd;
146}
147
Zoran Jovanovicc74e3eb92014-09-12 14:29:54 +0000148class JRADDIUSP_FM_MM16<bits<5> op> {
149 bits<5> rs;
150 bits<5> imm;
151
152 bits<16> Inst;
153
154 let Inst{15-10} = 0x11;
155 let Inst{9-5} = op;
156 let Inst{4-0} = imm;
157}
158
Zoran Jovanovic87d13e52014-03-20 10:18:24 +0000159//===----------------------------------------------------------------------===//
160// MicroMIPS 32-bit Instruction Formats
161//===----------------------------------------------------------------------===//
162
Akira Hatanakabe6a8182013-04-19 19:03:11 +0000163class MMArch {
164 string Arch = "micromips";
165 list<dag> Pattern = [];
166}
167
168class ADD_FM_MM<bits<6> op, bits<10> funct> : MMArch {
169 bits<5> rt;
170 bits<5> rs;
171 bits<5> rd;
172
173 bits<32> Inst;
174
175 let Inst{31-26} = op;
176 let Inst{25-21} = rt;
177 let Inst{20-16} = rs;
178 let Inst{15-11} = rd;
179 let Inst{10} = 0;
180 let Inst{9-0} = funct;
181}
182
183class ADDI_FM_MM<bits<6> op> : MMArch {
184 bits<5> rs;
185 bits<5> rt;
186 bits<16> imm16;
187
188 bits<32> Inst;
189
190 let Inst{31-26} = op;
191 let Inst{25-21} = rt;
192 let Inst{20-16} = rs;
193 let Inst{15-0} = imm16;
194}
195
196class SLTI_FM_MM<bits<6> op> : MMArch {
197 bits<5> rt;
198 bits<5> rs;
199 bits<16> imm16;
200
201 bits<32> Inst;
202
203 let Inst{31-26} = op;
Zoran Jovanovicf4d4d782013-11-15 08:07:34 +0000204 let Inst{25-21} = rt;
205 let Inst{20-16} = rs;
Akira Hatanakabe6a8182013-04-19 19:03:11 +0000206 let Inst{15-0} = imm16;
207}
208
209class LUI_FM_MM : MMArch {
210 bits<5> rt;
211 bits<16> imm16;
212
213 bits<32> Inst;
214
215 let Inst{31-26} = 0x10;
216 let Inst{25-21} = 0xd;
217 let Inst{20-16} = rt;
218 let Inst{15-0} = imm16;
219}
220
221class MULT_FM_MM<bits<10> funct> : MMArch {
222 bits<5> rs;
223 bits<5> rt;
224
225 bits<32> Inst;
226
227 let Inst{31-26} = 0x00;
228 let Inst{25-21} = rt;
229 let Inst{20-16} = rs;
230 let Inst{15-6} = funct;
231 let Inst{5-0} = 0x3c;
232}
Akira Hatanakacd9b74a2013-04-25 01:11:15 +0000233
234class SRA_FM_MM<bits<10> funct, bit rotate> : MMArch {
235 bits<5> rd;
236 bits<5> rt;
237 bits<5> shamt;
238
239 bits<32> Inst;
240
241 let Inst{31-26} = 0;
242 let Inst{25-21} = rd;
243 let Inst{20-16} = rt;
244 let Inst{15-11} = shamt;
245 let Inst{10} = rotate;
246 let Inst{9-0} = funct;
247}
248
249class SRLV_FM_MM<bits<10> funct, bit rotate> : MMArch {
250 bits<5> rd;
251 bits<5> rt;
252 bits<5> rs;
253
254 bits<32> Inst;
255
256 let Inst{31-26} = 0;
257 let Inst{25-21} = rt;
258 let Inst{20-16} = rs;
259 let Inst{15-11} = rd;
260 let Inst{10} = rotate;
261 let Inst{9-0} = funct;
262}
Akira Hatanakaf0aa6c92013-04-25 01:21:25 +0000263
264class LW_FM_MM<bits<6> op> : MMArch {
265 bits<5> rt;
266 bits<21> addr;
267
268 bits<32> Inst;
269
270 let Inst{31-26} = op;
271 let Inst{25-21} = rt;
272 let Inst{20-16} = addr{20-16};
273 let Inst{15-0} = addr{15-0};
274}
Jack Carter97700972013-08-13 20:19:16 +0000275
276class LWL_FM_MM<bits<4> funct> {
277 bits<5> rt;
278 bits<21> addr;
279
280 bits<32> Inst;
281
282 let Inst{31-26} = 0x18;
283 let Inst{25-21} = rt;
284 let Inst{20-16} = addr{20-16};
285 let Inst{15-12} = funct;
286 let Inst{11-0} = addr{11-0};
287}
Vladimir Medice0fbb442013-09-06 12:41:17 +0000288
289class CMov_F_I_FM_MM<bits<7> func> : MMArch {
290 bits<5> rd;
291 bits<5> rs;
292 bits<3> fcc;
293
294 bits<32> Inst;
295
296 let Inst{31-26} = 0x15;
297 let Inst{25-21} = rd;
298 let Inst{20-16} = rs;
299 let Inst{15-13} = fcc;
300 let Inst{12-6} = func;
301 let Inst{5-0} = 0x3b;
302}
Vladimir Medic457ba562013-09-06 12:53:21 +0000303
304class MTLO_FM_MM<bits<10> funct> : MMArch {
305 bits<5> rs;
306
307 bits<32> Inst;
308
309 let Inst{31-26} = 0x00;
310 let Inst{25-21} = 0x00;
311 let Inst{20-16} = rs;
312 let Inst{15-6} = funct;
313 let Inst{5-0} = 0x3c;
314}
315
316class MFLO_FM_MM<bits<10> funct> : MMArch {
317 bits<5> rd;
318
319 bits<32> Inst;
320
321 let Inst{31-26} = 0x00;
322 let Inst{25-21} = 0x00;
323 let Inst{20-16} = rd;
324 let Inst{15-6} = funct;
325 let Inst{5-0} = 0x3c;
326}
Zoran Jovanovicab852782013-09-14 06:49:25 +0000327
328class CLO_FM_MM<bits<10> funct> : MMArch {
329 bits<5> rd;
330 bits<5> rs;
331
332 bits<32> Inst;
333
334 let Inst{31-26} = 0x00;
335 let Inst{25-21} = rd;
336 let Inst{20-16} = rs;
337 let Inst{15-6} = funct;
338 let Inst{5-0} = 0x3c;
339}
340
341class SEB_FM_MM<bits<10> funct> : MMArch {
342 bits<5> rd;
343 bits<5> rt;
344
345 bits<32> Inst;
346
347 let Inst{31-26} = 0x00;
348 let Inst{25-21} = rd;
349 let Inst{20-16} = rt;
350 let Inst{15-6} = funct;
351 let Inst{5-0} = 0x3c;
352}
353
354class EXT_FM_MM<bits<6> funct> : MMArch {
355 bits<5> rt;
356 bits<5> rs;
357 bits<5> pos;
358 bits<5> size;
359
360 bits<32> Inst;
361
362 let Inst{31-26} = 0x00;
363 let Inst{25-21} = rt;
364 let Inst{20-16} = rs;
365 let Inst{15-11} = size;
366 let Inst{10-6} = pos;
367 let Inst{5-0} = funct;
368}
Zoran Jovanovic507e0842013-10-29 16:38:59 +0000369
370class J_FM_MM<bits<6> op> : MMArch {
371 bits<26> target;
372
373 bits<32> Inst;
374
375 let Inst{31-26} = op;
376 let Inst{25-0} = target;
377}
378
379class JR_FM_MM<bits<8> funct> : MMArch {
380 bits<5> rs;
381
382 bits<32> Inst;
383
384 let Inst{31-21} = 0x00;
385 let Inst{20-16} = rs;
386 let Inst{15-14} = 0x0;
387 let Inst{13-6} = funct;
388 let Inst{5-0} = 0x3c;
389}
390
Zoran Jovanovic87d13e52014-03-20 10:18:24 +0000391class JALR_FM_MM<bits<10> funct> {
Zoran Jovanovic507e0842013-10-29 16:38:59 +0000392 bits<5> rs;
393 bits<5> rd;
394
395 bits<32> Inst;
396
397 let Inst{31-26} = 0x00;
398 let Inst{25-21} = rd;
399 let Inst{20-16} = rs;
400 let Inst{15-6} = funct;
401 let Inst{5-0} = 0x3c;
402}
Zoran Jovanovic8a80aa72013-11-04 14:53:22 +0000403
404class BEQ_FM_MM<bits<6> op> : MMArch {
405 bits<5> rs;
406 bits<5> rt;
407 bits<16> offset;
408
409 bits<32> Inst;
410
411 let Inst{31-26} = op;
412 let Inst{25-21} = rt;
413 let Inst{20-16} = rs;
414 let Inst{15-0} = offset;
415}
416
417class BGEZ_FM_MM<bits<5> funct> : MMArch {
418 bits<5> rs;
419 bits<16> offset;
420
421 bits<32> Inst;
422
423 let Inst{31-26} = 0x10;
424 let Inst{25-21} = funct;
425 let Inst{20-16} = rs;
426 let Inst{15-0} = offset;
427}
428
429class BGEZAL_FM_MM<bits<5> funct> : MMArch {
430 bits<5> rs;
431 bits<16> offset;
432
433 bits<32> Inst;
434
435 let Inst{31-26} = 0x10;
436 let Inst{25-21} = funct;
437 let Inst{20-16} = rs;
438 let Inst{15-0} = offset;
439}
Zoran Jovanovicc18b6d12013-11-07 14:35:24 +0000440
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000441class SYNC_FM_MM : MMArch {
442 bits<5> stype;
443
444 bits<32> Inst;
445
446 let Inst{31-26} = 0x00;
447 let Inst{25-21} = 0x0;
448 let Inst{20-16} = stype;
449 let Inst{15-6} = 0x1ad;
450 let Inst{5-0} = 0x3c;
451}
452
453class BRK_FM_MM : MMArch {
454 bits<10> code_1;
455 bits<10> code_2;
456 bits<32> Inst;
457 let Inst{31-26} = 0x0;
458 let Inst{25-16} = code_1;
459 let Inst{15-6} = code_2;
460 let Inst{5-0} = 0x07;
461}
462
463class SYS_FM_MM : MMArch {
464 bits<10> code_;
465 bits<32> Inst;
466 let Inst{31-26} = 0x0;
467 let Inst{25-16} = code_;
Zoran Jovanovic7c6c36d2014-02-28 18:17:08 +0000468 let Inst{15-6} = 0x22d;
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000469 let Inst{5-0} = 0x3c;
470}
471
Zoran Jovanovica0f53282014-03-20 10:41:37 +0000472class WAIT_FM_MM {
473 bits<10> code_;
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000474 bits<32> Inst;
475
476 let Inst{31-26} = 0x00;
Zoran Jovanovica0f53282014-03-20 10:41:37 +0000477 let Inst{25-16} = code_;
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000478 let Inst{15-6} = 0x24d;
479 let Inst{5-0} = 0x3c;
480}
481
482class ER_FM_MM<bits<10> funct> : MMArch {
483 bits<32> Inst;
484
485 let Inst{31-26} = 0x00;
486 let Inst{25-16} = 0x00;
487 let Inst{15-6} = funct;
488 let Inst{5-0} = 0x3c;
489}
490
491class EI_FM_MM<bits<10> funct> : MMArch {
492 bits<32> Inst;
493 bits<5> rt;
494
495 let Inst{31-26} = 0x00;
496 let Inst{25-21} = 0x00;
497 let Inst{20-16} = rt;
498 let Inst{15-6} = funct;
499 let Inst{5-0} = 0x3c;
500}
501
Zoran Jovanovicc18b6d12013-11-07 14:35:24 +0000502class TEQ_FM_MM<bits<6> funct> : MMArch {
503 bits<5> rs;
504 bits<5> rt;
505 bits<4> code_;
506
507 bits<32> Inst;
508
509 let Inst{31-26} = 0x00;
510 let Inst{25-21} = rt;
511 let Inst{20-16} = rs;
512 let Inst{15-12} = code_;
513 let Inst{11-6} = funct;
514 let Inst{5-0} = 0x3c;
515}
Zoran Jovanovicccb70ca2013-11-13 13:15:03 +0000516
517class TEQI_FM_MM<bits<5> funct> : MMArch {
518 bits<5> rs;
519 bits<16> imm16;
520
521 bits<32> Inst;
522
523 let Inst{31-26} = 0x10;
524 let Inst{25-21} = funct;
525 let Inst{20-16} = rs;
526 let Inst{15-0} = imm16;
527}
Zoran Jovanovicff9d5f32013-12-19 16:12:56 +0000528
529class LL_FM_MM<bits<4> funct> {
530 bits<5> rt;
531 bits<21> addr;
532
533 bits<32> Inst;
534
535 let Inst{31-26} = 0x18;
536 let Inst{25-21} = rt;
537 let Inst{20-16} = addr{20-16};
538 let Inst{15-12} = funct;
539 let Inst{11-0} = addr{11-0};
540}
Zoran Jovanovicce024862013-12-20 15:44:08 +0000541
542class ADDS_FM_MM<bits<2> fmt, bits<8> funct> : MMArch {
543 bits<5> ft;
544 bits<5> fs;
545 bits<5> fd;
546
547 bits<32> Inst;
548
549 let Inst{31-26} = 0x15;
550 let Inst{25-21} = ft;
551 let Inst{20-16} = fs;
552 let Inst{15-11} = fd;
553 let Inst{10} = 0;
554 let Inst{9-8} = fmt;
555 let Inst{7-0} = funct;
556
557 list<dag> Pattern = [];
558}
559
560class LWXC1_FM_MM<bits<9> funct> : MMArch {
561 bits<5> fd;
562 bits<5> base;
563 bits<5> index;
564
565 bits<32> Inst;
566
567 let Inst{31-26} = 0x15;
568 let Inst{25-21} = index;
569 let Inst{20-16} = base;
570 let Inst{15-11} = fd;
571 let Inst{10-9} = 0x0;
572 let Inst{8-0} = funct;
573}
574
575class SWXC1_FM_MM<bits<9> funct> : MMArch {
576 bits<5> fs;
577 bits<5> base;
578 bits<5> index;
579
580 bits<32> Inst;
581
582 let Inst{31-26} = 0x15;
583 let Inst{25-21} = index;
584 let Inst{20-16} = base;
585 let Inst{15-11} = fs;
586 let Inst{10-9} = 0x0;
587 let Inst{8-0} = funct;
588}
589
590class CEQS_FM_MM<bits<2> fmt> : MMArch {
591 bits<5> fs;
592 bits<5> ft;
593 bits<4> cond;
594
595 bits<32> Inst;
596
597 let Inst{31-26} = 0x15;
598 let Inst{25-21} = ft;
599 let Inst{20-16} = fs;
600 let Inst{15-13} = 0x0; // cc
601 let Inst{12} = 0;
602 let Inst{11-10} = fmt;
603 let Inst{9-6} = cond;
604 let Inst{5-0} = 0x3c;
605}
606
607class BC1F_FM_MM<bits<5> tf> : MMArch {
608 bits<16> offset;
609
610 bits<32> Inst;
611
612 let Inst{31-26} = 0x10;
613 let Inst{25-21} = tf;
614 let Inst{20-18} = 0x0; // cc
615 let Inst{17-16} = 0x0;
616 let Inst{15-0} = offset;
617}
618
619class ROUND_W_FM_MM<bits<1> fmt, bits<8> funct> : MMArch {
620 bits<5> fd;
621 bits<5> fs;
622
623 bits<32> Inst;
624
625 let Inst{31-26} = 0x15;
626 let Inst{25-21} = fd;
627 let Inst{20-16} = fs;
628 let Inst{15} = 0;
629 let Inst{14} = fmt;
630 let Inst{13-6} = funct;
631 let Inst{5-0} = 0x3b;
632}
633
634class ABS_FM_MM<bits<2> fmt, bits<7> funct> : MMArch {
635 bits<5> fd;
636 bits<5> fs;
637
638 bits<32> Inst;
639
640 let Inst{31-26} = 0x15;
641 let Inst{25-21} = fd;
642 let Inst{20-16} = fs;
643 let Inst{15} = 0;
644 let Inst{14-13} = fmt;
645 let Inst{12-6} = funct;
646 let Inst{5-0} = 0x3b;
647}
Zoran Jovanovic8876be32013-12-25 10:09:27 +0000648
649class CMov_F_F_FM_MM<bits<9> func, bits<2> fmt> : MMArch {
650 bits<5> fd;
651 bits<5> fs;
652
653 bits<32> Inst;
654
655 let Inst{31-26} = 0x15;
656 let Inst{25-21} = fd;
657 let Inst{20-16} = fs;
658 let Inst{15-13} = 0x0; //cc
659 let Inst{12-11} = 0x0;
660 let Inst{10-9} = fmt;
661 let Inst{8-0} = func;
662}
663
664class CMov_I_F_FM_MM<bits<8> funct, bits<2> fmt> : MMArch {
665 bits<5> fd;
666 bits<5> fs;
667 bits<5> rt;
668
669 bits<32> Inst;
670
671 let Inst{31-26} = 0x15;
672 let Inst{25-21} = rt;
673 let Inst{20-16} = fs;
674 let Inst{15-11} = fd;
675 let Inst{9-8} = fmt;
676 let Inst{7-0} = funct;
677}
678
679class MFC1_FM_MM<bits<8> funct> : MMArch {
680 bits<5> rt;
681 bits<5> fs;
682
683 bits<32> Inst;
684
685 let Inst{31-26} = 0x15;
686 let Inst{25-21} = rt;
687 let Inst{20-16} = fs;
688 let Inst{15-14} = 0x0;
689 let Inst{13-6} = funct;
690 let Inst{5-0} = 0x3b;
691}
692
693class MADDS_FM_MM<bits<6> funct>: MMArch {
694 bits<5> ft;
695 bits<5> fs;
696 bits<5> fd;
697 bits<5> fr;
698
699 bits<32> Inst;
700
701 let Inst{31-26} = 0x15;
702 let Inst{25-21} = ft;
703 let Inst{20-16} = fs;
704 let Inst{15-11} = fd;
705 let Inst{10-6} = fr;
706 let Inst{5-0} = funct;
707}
Zoran Jovanovic73ff9482014-08-14 12:09:10 +0000708
709class COMPACT_BRANCH_FM_MM<bits<5> funct> {
710 bits<5> rs;
711 bits<16> offset;
712
713 bits<32> Inst;
714
715 let Inst{31-26} = 0x10;
716 let Inst{25-21} = funct;
717 let Inst{20-16} = rs;
718 let Inst{15-0} = offset;
719}
Zoran Jovanovic4e7ac4a2014-09-12 13:33:33 +0000720
721class COP0_TLB_FM_MM<bits<10> op> : MMArch {
722 bits<32> Inst;
723
724 let Inst{31-26} = 0x0;
725 let Inst{25-16} = 0x0;
726 let Inst{15-6} = op;
727 let Inst{5-0} = 0x3c;
728}