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