blob: 23c8dd6d1b2f3e751b4208e3421102042c30a3d1 [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 Jovanovicbac36192014-10-23 11:06:34 +000084class ADDIUR2_FM_MM16 {
85 bits<3> rd;
86 bits<3> rs;
87 bits<3> imm;
88
89 bits<16> Inst;
90
91 let Inst{15-10} = 0x1b;
92 let Inst{9-7} = rd;
93 let Inst{6-4} = rs;
94 let Inst{3-1} = imm;
95 let Inst{0} = 0;
96}
97
Zoran Jovanovicb26f8892014-10-10 13:45:34 +000098class ADDIUS5_FM_MM16 {
99 bits<5> rd;
100 bits<4> imm;
101
102 bits<16> Inst;
103
104 let Inst{15-10} = 0x13;
105 let Inst{9-5} = rd;
106 let Inst{4-1} = imm;
107 let Inst{0} = 0;
108}
109
Zoran Jovanovic98bd58c2014-10-10 14:37:30 +0000110class ADDIUSP_FM_MM16 {
111 bits<9> imm;
112
113 bits<16> Inst;
114
115 let Inst{15-10} = 0x13;
116 let Inst{9-1} = imm;
117 let Inst{0} = 1;
118}
119
Zoran Jovanovic87d13e52014-03-20 10:18:24 +0000120class MOVE_FM_MM16<bits<6> funct> {
121 bits<5> rs;
122 bits<5> rd;
123
124 bits<16> Inst;
125
126 let Inst{15-10} = funct;
127 let Inst{9-5} = rd;
128 let Inst{4-0} = rs;
129}
130
Zoran Jovanovic9bda2f12014-10-23 10:59:24 +0000131class LI_FM_MM16 {
132 bits<3> rd;
133 bits<7> imm;
134
135 bits<16> Inst;
136
137 let Inst{15-10} = 0x3b;
138 let Inst{9-7} = rd;
139 let Inst{6-0} = imm;
140}
141
Zoran Jovanovic87d13e52014-03-20 10:18:24 +0000142class JALR_FM_MM16<bits<5> op> {
143 bits<5> rs;
144
145 bits<16> Inst;
146
147 let Inst{15-10} = 0x11;
148 let Inst{9-5} = op;
149 let Inst{4-0} = rs;
150}
151
Zoran Jovanoviccabf0f42014-04-03 12:47:34 +0000152class MFHILO_FM_MM16<bits<5> funct> {
153 bits<5> rd;
154
155 bits<16> Inst;
156
157 let Inst{15-10} = 0x11;
158 let Inst{9-5} = funct;
159 let Inst{4-0} = rd;
160}
161
Zoran Jovanovicc74e3eb92014-09-12 14:29:54 +0000162class JRADDIUSP_FM_MM16<bits<5> op> {
163 bits<5> rs;
164 bits<5> imm;
165
166 bits<16> Inst;
167
168 let Inst{15-10} = 0x11;
169 let Inst{9-5} = op;
170 let Inst{4-0} = imm;
171}
172
Zoran Jovanovic87d13e52014-03-20 10:18:24 +0000173//===----------------------------------------------------------------------===//
174// MicroMIPS 32-bit Instruction Formats
175//===----------------------------------------------------------------------===//
176
Akira Hatanakabe6a8182013-04-19 19:03:11 +0000177class MMArch {
178 string Arch = "micromips";
179 list<dag> Pattern = [];
180}
181
182class ADD_FM_MM<bits<6> op, bits<10> funct> : MMArch {
183 bits<5> rt;
184 bits<5> rs;
185 bits<5> rd;
186
187 bits<32> Inst;
188
189 let Inst{31-26} = op;
190 let Inst{25-21} = rt;
191 let Inst{20-16} = rs;
192 let Inst{15-11} = rd;
193 let Inst{10} = 0;
194 let Inst{9-0} = funct;
195}
196
197class ADDI_FM_MM<bits<6> op> : MMArch {
198 bits<5> rs;
199 bits<5> rt;
200 bits<16> imm16;
201
202 bits<32> Inst;
203
204 let Inst{31-26} = op;
205 let Inst{25-21} = rt;
206 let Inst{20-16} = rs;
207 let Inst{15-0} = imm16;
208}
209
210class SLTI_FM_MM<bits<6> op> : MMArch {
211 bits<5> rt;
212 bits<5> rs;
213 bits<16> imm16;
214
215 bits<32> Inst;
216
217 let Inst{31-26} = op;
Zoran Jovanovicf4d4d782013-11-15 08:07:34 +0000218 let Inst{25-21} = rt;
219 let Inst{20-16} = rs;
Akira Hatanakabe6a8182013-04-19 19:03:11 +0000220 let Inst{15-0} = imm16;
221}
222
223class LUI_FM_MM : MMArch {
224 bits<5> rt;
225 bits<16> imm16;
226
227 bits<32> Inst;
228
229 let Inst{31-26} = 0x10;
230 let Inst{25-21} = 0xd;
231 let Inst{20-16} = rt;
232 let Inst{15-0} = imm16;
233}
234
235class MULT_FM_MM<bits<10> funct> : MMArch {
236 bits<5> rs;
237 bits<5> rt;
238
239 bits<32> Inst;
240
241 let Inst{31-26} = 0x00;
242 let Inst{25-21} = rt;
243 let Inst{20-16} = rs;
244 let Inst{15-6} = funct;
245 let Inst{5-0} = 0x3c;
246}
Akira Hatanakacd9b74a2013-04-25 01:11:15 +0000247
248class SRA_FM_MM<bits<10> funct, bit rotate> : MMArch {
249 bits<5> rd;
250 bits<5> rt;
251 bits<5> shamt;
252
253 bits<32> Inst;
254
255 let Inst{31-26} = 0;
256 let Inst{25-21} = rd;
257 let Inst{20-16} = rt;
258 let Inst{15-11} = shamt;
259 let Inst{10} = rotate;
260 let Inst{9-0} = funct;
261}
262
263class SRLV_FM_MM<bits<10> funct, bit rotate> : MMArch {
264 bits<5> rd;
265 bits<5> rt;
266 bits<5> rs;
267
268 bits<32> Inst;
269
270 let Inst{31-26} = 0;
271 let Inst{25-21} = rt;
272 let Inst{20-16} = rs;
273 let Inst{15-11} = rd;
274 let Inst{10} = rotate;
275 let Inst{9-0} = funct;
276}
Akira Hatanakaf0aa6c92013-04-25 01:21:25 +0000277
278class LW_FM_MM<bits<6> op> : MMArch {
279 bits<5> rt;
280 bits<21> addr;
281
282 bits<32> Inst;
283
284 let Inst{31-26} = op;
285 let Inst{25-21} = rt;
286 let Inst{20-16} = addr{20-16};
287 let Inst{15-0} = addr{15-0};
288}
Jack Carter97700972013-08-13 20:19:16 +0000289
290class LWL_FM_MM<bits<4> funct> {
291 bits<5> rt;
292 bits<21> addr;
293
294 bits<32> Inst;
295
296 let Inst{31-26} = 0x18;
297 let Inst{25-21} = rt;
298 let Inst{20-16} = addr{20-16};
299 let Inst{15-12} = funct;
300 let Inst{11-0} = addr{11-0};
301}
Vladimir Medice0fbb442013-09-06 12:41:17 +0000302
303class CMov_F_I_FM_MM<bits<7> func> : MMArch {
304 bits<5> rd;
305 bits<5> rs;
306 bits<3> fcc;
307
308 bits<32> Inst;
309
310 let Inst{31-26} = 0x15;
311 let Inst{25-21} = rd;
312 let Inst{20-16} = rs;
313 let Inst{15-13} = fcc;
314 let Inst{12-6} = func;
315 let Inst{5-0} = 0x3b;
316}
Vladimir Medic457ba562013-09-06 12:53:21 +0000317
318class MTLO_FM_MM<bits<10> funct> : MMArch {
319 bits<5> rs;
320
321 bits<32> Inst;
322
323 let Inst{31-26} = 0x00;
324 let Inst{25-21} = 0x00;
325 let Inst{20-16} = rs;
326 let Inst{15-6} = funct;
327 let Inst{5-0} = 0x3c;
328}
329
330class MFLO_FM_MM<bits<10> funct> : MMArch {
331 bits<5> rd;
332
333 bits<32> Inst;
334
335 let Inst{31-26} = 0x00;
336 let Inst{25-21} = 0x00;
337 let Inst{20-16} = rd;
338 let Inst{15-6} = funct;
339 let Inst{5-0} = 0x3c;
340}
Zoran Jovanovicab852782013-09-14 06:49:25 +0000341
342class CLO_FM_MM<bits<10> funct> : MMArch {
343 bits<5> rd;
344 bits<5> rs;
345
346 bits<32> Inst;
347
348 let Inst{31-26} = 0x00;
349 let Inst{25-21} = rd;
350 let Inst{20-16} = rs;
351 let Inst{15-6} = funct;
352 let Inst{5-0} = 0x3c;
353}
354
355class SEB_FM_MM<bits<10> funct> : MMArch {
356 bits<5> rd;
357 bits<5> rt;
358
359 bits<32> Inst;
360
361 let Inst{31-26} = 0x00;
362 let Inst{25-21} = rd;
363 let Inst{20-16} = rt;
364 let Inst{15-6} = funct;
365 let Inst{5-0} = 0x3c;
366}
367
368class EXT_FM_MM<bits<6> funct> : MMArch {
369 bits<5> rt;
370 bits<5> rs;
371 bits<5> pos;
372 bits<5> size;
373
374 bits<32> Inst;
375
376 let Inst{31-26} = 0x00;
377 let Inst{25-21} = rt;
378 let Inst{20-16} = rs;
379 let Inst{15-11} = size;
380 let Inst{10-6} = pos;
381 let Inst{5-0} = funct;
382}
Zoran Jovanovic507e0842013-10-29 16:38:59 +0000383
384class J_FM_MM<bits<6> op> : MMArch {
385 bits<26> target;
386
387 bits<32> Inst;
388
389 let Inst{31-26} = op;
390 let Inst{25-0} = target;
391}
392
393class JR_FM_MM<bits<8> funct> : MMArch {
394 bits<5> rs;
395
396 bits<32> Inst;
397
398 let Inst{31-21} = 0x00;
399 let Inst{20-16} = rs;
400 let Inst{15-14} = 0x0;
401 let Inst{13-6} = funct;
402 let Inst{5-0} = 0x3c;
403}
404
Zoran Jovanovic87d13e52014-03-20 10:18:24 +0000405class JALR_FM_MM<bits<10> funct> {
Zoran Jovanovic507e0842013-10-29 16:38:59 +0000406 bits<5> rs;
407 bits<5> rd;
408
409 bits<32> Inst;
410
411 let Inst{31-26} = 0x00;
412 let Inst{25-21} = rd;
413 let Inst{20-16} = rs;
414 let Inst{15-6} = funct;
415 let Inst{5-0} = 0x3c;
416}
Zoran Jovanovic8a80aa72013-11-04 14:53:22 +0000417
418class BEQ_FM_MM<bits<6> op> : MMArch {
419 bits<5> rs;
420 bits<5> rt;
421 bits<16> offset;
422
423 bits<32> Inst;
424
425 let Inst{31-26} = op;
426 let Inst{25-21} = rt;
427 let Inst{20-16} = rs;
428 let Inst{15-0} = offset;
429}
430
431class BGEZ_FM_MM<bits<5> funct> : MMArch {
432 bits<5> rs;
433 bits<16> offset;
434
435 bits<32> Inst;
436
437 let Inst{31-26} = 0x10;
438 let Inst{25-21} = funct;
439 let Inst{20-16} = rs;
440 let Inst{15-0} = offset;
441}
442
443class BGEZAL_FM_MM<bits<5> funct> : MMArch {
444 bits<5> rs;
445 bits<16> offset;
446
447 bits<32> Inst;
448
449 let Inst{31-26} = 0x10;
450 let Inst{25-21} = funct;
451 let Inst{20-16} = rs;
452 let Inst{15-0} = offset;
453}
Zoran Jovanovicc18b6d12013-11-07 14:35:24 +0000454
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000455class SYNC_FM_MM : MMArch {
456 bits<5> stype;
457
458 bits<32> Inst;
459
460 let Inst{31-26} = 0x00;
461 let Inst{25-21} = 0x0;
462 let Inst{20-16} = stype;
463 let Inst{15-6} = 0x1ad;
464 let Inst{5-0} = 0x3c;
465}
466
467class BRK_FM_MM : MMArch {
468 bits<10> code_1;
469 bits<10> code_2;
470 bits<32> Inst;
471 let Inst{31-26} = 0x0;
472 let Inst{25-16} = code_1;
473 let Inst{15-6} = code_2;
474 let Inst{5-0} = 0x07;
475}
476
477class SYS_FM_MM : MMArch {
478 bits<10> code_;
479 bits<32> Inst;
480 let Inst{31-26} = 0x0;
481 let Inst{25-16} = code_;
Zoran Jovanovic7c6c36d2014-02-28 18:17:08 +0000482 let Inst{15-6} = 0x22d;
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000483 let Inst{5-0} = 0x3c;
484}
485
Zoran Jovanovica0f53282014-03-20 10:41:37 +0000486class WAIT_FM_MM {
487 bits<10> code_;
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000488 bits<32> Inst;
489
490 let Inst{31-26} = 0x00;
Zoran Jovanovica0f53282014-03-20 10:41:37 +0000491 let Inst{25-16} = code_;
Zoran Jovanovic8e918c32013-12-19 16:25:00 +0000492 let Inst{15-6} = 0x24d;
493 let Inst{5-0} = 0x3c;
494}
495
496class ER_FM_MM<bits<10> funct> : MMArch {
497 bits<32> Inst;
498
499 let Inst{31-26} = 0x00;
500 let Inst{25-16} = 0x00;
501 let Inst{15-6} = funct;
502 let Inst{5-0} = 0x3c;
503}
504
505class EI_FM_MM<bits<10> funct> : MMArch {
506 bits<32> Inst;
507 bits<5> rt;
508
509 let Inst{31-26} = 0x00;
510 let Inst{25-21} = 0x00;
511 let Inst{20-16} = rt;
512 let Inst{15-6} = funct;
513 let Inst{5-0} = 0x3c;
514}
515
Zoran Jovanovicc18b6d12013-11-07 14:35:24 +0000516class TEQ_FM_MM<bits<6> funct> : MMArch {
517 bits<5> rs;
518 bits<5> rt;
519 bits<4> code_;
520
521 bits<32> Inst;
522
523 let Inst{31-26} = 0x00;
524 let Inst{25-21} = rt;
525 let Inst{20-16} = rs;
526 let Inst{15-12} = code_;
527 let Inst{11-6} = funct;
528 let Inst{5-0} = 0x3c;
529}
Zoran Jovanovicccb70ca2013-11-13 13:15:03 +0000530
531class TEQI_FM_MM<bits<5> funct> : MMArch {
532 bits<5> rs;
533 bits<16> imm16;
534
535 bits<32> Inst;
536
537 let Inst{31-26} = 0x10;
538 let Inst{25-21} = funct;
539 let Inst{20-16} = rs;
540 let Inst{15-0} = imm16;
541}
Zoran Jovanovicff9d5f32013-12-19 16:12:56 +0000542
543class LL_FM_MM<bits<4> funct> {
544 bits<5> rt;
545 bits<21> addr;
546
547 bits<32> Inst;
548
549 let Inst{31-26} = 0x18;
550 let Inst{25-21} = rt;
551 let Inst{20-16} = addr{20-16};
552 let Inst{15-12} = funct;
553 let Inst{11-0} = addr{11-0};
554}
Zoran Jovanovicce024862013-12-20 15:44:08 +0000555
556class ADDS_FM_MM<bits<2> fmt, bits<8> funct> : MMArch {
557 bits<5> ft;
558 bits<5> fs;
559 bits<5> fd;
560
561 bits<32> Inst;
562
563 let Inst{31-26} = 0x15;
564 let Inst{25-21} = ft;
565 let Inst{20-16} = fs;
566 let Inst{15-11} = fd;
567 let Inst{10} = 0;
568 let Inst{9-8} = fmt;
569 let Inst{7-0} = funct;
570
571 list<dag> Pattern = [];
572}
573
574class LWXC1_FM_MM<bits<9> funct> : MMArch {
575 bits<5> fd;
576 bits<5> base;
577 bits<5> index;
578
579 bits<32> Inst;
580
581 let Inst{31-26} = 0x15;
582 let Inst{25-21} = index;
583 let Inst{20-16} = base;
584 let Inst{15-11} = fd;
585 let Inst{10-9} = 0x0;
586 let Inst{8-0} = funct;
587}
588
589class SWXC1_FM_MM<bits<9> funct> : MMArch {
590 bits<5> fs;
591 bits<5> base;
592 bits<5> index;
593
594 bits<32> Inst;
595
596 let Inst{31-26} = 0x15;
597 let Inst{25-21} = index;
598 let Inst{20-16} = base;
599 let Inst{15-11} = fs;
600 let Inst{10-9} = 0x0;
601 let Inst{8-0} = funct;
602}
603
604class CEQS_FM_MM<bits<2> fmt> : MMArch {
605 bits<5> fs;
606 bits<5> ft;
607 bits<4> cond;
608
609 bits<32> Inst;
610
611 let Inst{31-26} = 0x15;
612 let Inst{25-21} = ft;
613 let Inst{20-16} = fs;
614 let Inst{15-13} = 0x0; // cc
615 let Inst{12} = 0;
616 let Inst{11-10} = fmt;
617 let Inst{9-6} = cond;
618 let Inst{5-0} = 0x3c;
619}
620
621class BC1F_FM_MM<bits<5> tf> : MMArch {
622 bits<16> offset;
623
624 bits<32> Inst;
625
626 let Inst{31-26} = 0x10;
627 let Inst{25-21} = tf;
628 let Inst{20-18} = 0x0; // cc
629 let Inst{17-16} = 0x0;
630 let Inst{15-0} = offset;
631}
632
633class ROUND_W_FM_MM<bits<1> fmt, bits<8> funct> : MMArch {
634 bits<5> fd;
635 bits<5> fs;
636
637 bits<32> Inst;
638
639 let Inst{31-26} = 0x15;
640 let Inst{25-21} = fd;
641 let Inst{20-16} = fs;
642 let Inst{15} = 0;
643 let Inst{14} = fmt;
644 let Inst{13-6} = funct;
645 let Inst{5-0} = 0x3b;
646}
647
648class ABS_FM_MM<bits<2> fmt, bits<7> funct> : MMArch {
649 bits<5> fd;
650 bits<5> fs;
651
652 bits<32> Inst;
653
654 let Inst{31-26} = 0x15;
655 let Inst{25-21} = fd;
656 let Inst{20-16} = fs;
657 let Inst{15} = 0;
658 let Inst{14-13} = fmt;
659 let Inst{12-6} = funct;
660 let Inst{5-0} = 0x3b;
661}
Zoran Jovanovic8876be32013-12-25 10:09:27 +0000662
663class CMov_F_F_FM_MM<bits<9> func, bits<2> fmt> : MMArch {
664 bits<5> fd;
665 bits<5> fs;
666
667 bits<32> Inst;
668
669 let Inst{31-26} = 0x15;
670 let Inst{25-21} = fd;
671 let Inst{20-16} = fs;
672 let Inst{15-13} = 0x0; //cc
673 let Inst{12-11} = 0x0;
674 let Inst{10-9} = fmt;
675 let Inst{8-0} = func;
676}
677
678class CMov_I_F_FM_MM<bits<8> funct, bits<2> fmt> : MMArch {
679 bits<5> fd;
680 bits<5> fs;
681 bits<5> rt;
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-11} = fd;
689 let Inst{9-8} = fmt;
690 let Inst{7-0} = funct;
691}
692
693class MFC1_FM_MM<bits<8> funct> : MMArch {
694 bits<5> rt;
695 bits<5> fs;
696
697 bits<32> Inst;
698
699 let Inst{31-26} = 0x15;
700 let Inst{25-21} = rt;
701 let Inst{20-16} = fs;
702 let Inst{15-14} = 0x0;
703 let Inst{13-6} = funct;
704 let Inst{5-0} = 0x3b;
705}
706
707class MADDS_FM_MM<bits<6> funct>: MMArch {
708 bits<5> ft;
709 bits<5> fs;
710 bits<5> fd;
711 bits<5> fr;
712
713 bits<32> Inst;
714
715 let Inst{31-26} = 0x15;
716 let Inst{25-21} = ft;
717 let Inst{20-16} = fs;
718 let Inst{15-11} = fd;
719 let Inst{10-6} = fr;
720 let Inst{5-0} = funct;
721}
Zoran Jovanovic73ff9482014-08-14 12:09:10 +0000722
723class COMPACT_BRANCH_FM_MM<bits<5> funct> {
724 bits<5> rs;
725 bits<16> offset;
726
727 bits<32> Inst;
728
729 let Inst{31-26} = 0x10;
730 let Inst{25-21} = funct;
731 let Inst{20-16} = rs;
732 let Inst{15-0} = offset;
733}
Zoran Jovanovic4e7ac4a2014-09-12 13:33:33 +0000734
735class COP0_TLB_FM_MM<bits<10> op> : MMArch {
736 bits<32> Inst;
737
738 let Inst{31-26} = 0x0;
739 let Inst{25-16} = 0x0;
740 let Inst{15-6} = op;
741 let Inst{5-0} = 0x3c;
742}