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