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