1 //===----------------------------------------------------------------------===//
2 // MicroMIPS Base Classes
3 //===----------------------------------------------------------------------===//
6 // Base class for MicroMips instructions.
7 // This class does not depend on the instruction size.
9 class MicroMipsInstBase<dag outs, dag ins, string asmstr, list<dag> pattern,
10 InstrItinClass itin, Format f> : Instruction
12 let Namespace = "Mips";
13 let DecoderNamespace = "MicroMips";
15 let OutOperandList = outs;
16 let InOperandList = ins;
18 let AsmString = asmstr;
19 let Pattern = pattern;
22 let Predicates = [InMicroMips];
28 // Base class for MicroMIPS 16-bit instructions.
30 class MicroMipsInst16<dag outs, dag ins, string asmstr, list<dag> pattern,
31 InstrItinClass itin, Format f> :
32 MicroMipsInstBase<outs, ins, asmstr, pattern, itin, f>
36 field bits<16> SoftFail = 0;
40 //===----------------------------------------------------------------------===//
41 // MicroMIPS 16-bit Instruction Formats
42 //===----------------------------------------------------------------------===//
44 class ARITH_FM_MM16<bit funct> {
51 let Inst{15-10} = 0x01;
58 class ANDI_FM_MM16<bits<6> funct> {
65 let Inst{15-10} = funct;
71 class LOGIC_FM_MM16<bits<4> funct> {
77 let Inst{15-10} = 0x11;
78 let Inst{9-6} = funct;
83 class SHIFT_FM_MM16<bits<1> funct> {
90 let Inst{15-10} = 0x09;
93 let Inst{3-1} = shamt;
97 class ADDIUR2_FM_MM16 {
104 let Inst{15-10} = 0x1b;
111 class ADDIUS5_FM_MM16 {
117 let Inst{15-10} = 0x13;
123 class ADDIUSP_FM_MM16 {
128 let Inst{15-10} = 0x13;
133 class MOVE_FM_MM16<bits<6> funct> {
139 let Inst{15-10} = funct;
150 let Inst{15-10} = 0x3b;
155 class JALR_FM_MM16<bits<5> op> {
160 let Inst{15-10} = 0x11;
165 class MFHILO_FM_MM16<bits<5> funct> {
170 let Inst{15-10} = 0x11;
171 let Inst{9-5} = funct;
175 class JRADDIUSP_FM_MM16<bits<5> op> {
181 let Inst{15-10} = 0x11;
186 class ADDIUR1SP_FM_MM16 {
192 let Inst{15-10} = 0x1b;
198 //===----------------------------------------------------------------------===//
199 // MicroMIPS 32-bit Instruction Formats
200 //===----------------------------------------------------------------------===//
203 string Arch = "micromips";
204 list<dag> Pattern = [];
207 class ADD_FM_MM<bits<6> op, bits<10> funct> : MMArch {
214 let Inst{31-26} = op;
215 let Inst{25-21} = rt;
216 let Inst{20-16} = rs;
217 let Inst{15-11} = rd;
219 let Inst{9-0} = funct;
222 class ADDI_FM_MM<bits<6> op> : MMArch {
229 let Inst{31-26} = op;
230 let Inst{25-21} = rt;
231 let Inst{20-16} = rs;
232 let Inst{15-0} = imm16;
235 class SLTI_FM_MM<bits<6> op> : MMArch {
242 let Inst{31-26} = op;
243 let Inst{25-21} = rt;
244 let Inst{20-16} = rs;
245 let Inst{15-0} = imm16;
248 class LUI_FM_MM : MMArch {
254 let Inst{31-26} = 0x10;
255 let Inst{25-21} = 0xd;
256 let Inst{20-16} = rt;
257 let Inst{15-0} = imm16;
260 class MULT_FM_MM<bits<10> funct> : MMArch {
266 let Inst{31-26} = 0x00;
267 let Inst{25-21} = rt;
268 let Inst{20-16} = rs;
269 let Inst{15-6} = funct;
270 let Inst{5-0} = 0x3c;
273 class SRA_FM_MM<bits<10> funct, bit rotate> : MMArch {
281 let Inst{25-21} = rd;
282 let Inst{20-16} = rt;
283 let Inst{15-11} = shamt;
284 let Inst{10} = rotate;
285 let Inst{9-0} = funct;
288 class SRLV_FM_MM<bits<10> funct, bit rotate> : MMArch {
296 let Inst{25-21} = rt;
297 let Inst{20-16} = rs;
298 let Inst{15-11} = rd;
299 let Inst{10} = rotate;
300 let Inst{9-0} = funct;
303 class LW_FM_MM<bits<6> op> : MMArch {
309 let Inst{31-26} = op;
310 let Inst{25-21} = rt;
311 let Inst{20-16} = addr{20-16};
312 let Inst{15-0} = addr{15-0};
315 class LWL_FM_MM<bits<4> funct> {
321 let Inst{31-26} = 0x18;
322 let Inst{25-21} = rt;
323 let Inst{20-16} = addr{20-16};
324 let Inst{15-12} = funct;
325 let Inst{11-0} = addr{11-0};
328 class CMov_F_I_FM_MM<bits<7> func> : MMArch {
335 let Inst{31-26} = 0x15;
336 let Inst{25-21} = rd;
337 let Inst{20-16} = rs;
338 let Inst{15-13} = fcc;
339 let Inst{12-6} = func;
340 let Inst{5-0} = 0x3b;
343 class MTLO_FM_MM<bits<10> funct> : MMArch {
348 let Inst{31-26} = 0x00;
349 let Inst{25-21} = 0x00;
350 let Inst{20-16} = rs;
351 let Inst{15-6} = funct;
352 let Inst{5-0} = 0x3c;
355 class MFLO_FM_MM<bits<10> funct> : MMArch {
360 let Inst{31-26} = 0x00;
361 let Inst{25-21} = 0x00;
362 let Inst{20-16} = rd;
363 let Inst{15-6} = funct;
364 let Inst{5-0} = 0x3c;
367 class CLO_FM_MM<bits<10> funct> : MMArch {
373 let Inst{31-26} = 0x00;
374 let Inst{25-21} = rd;
375 let Inst{20-16} = rs;
376 let Inst{15-6} = funct;
377 let Inst{5-0} = 0x3c;
380 class SEB_FM_MM<bits<10> funct> : MMArch {
386 let Inst{31-26} = 0x00;
387 let Inst{25-21} = rd;
388 let Inst{20-16} = rt;
389 let Inst{15-6} = funct;
390 let Inst{5-0} = 0x3c;
393 class EXT_FM_MM<bits<6> funct> : MMArch {
401 let Inst{31-26} = 0x00;
402 let Inst{25-21} = rt;
403 let Inst{20-16} = rs;
404 let Inst{15-11} = size;
405 let Inst{10-6} = pos;
406 let Inst{5-0} = funct;
409 class J_FM_MM<bits<6> op> : MMArch {
414 let Inst{31-26} = op;
415 let Inst{25-0} = target;
418 class JR_FM_MM<bits<8> funct> : MMArch {
423 let Inst{31-21} = 0x00;
424 let Inst{20-16} = rs;
425 let Inst{15-14} = 0x0;
426 let Inst{13-6} = funct;
427 let Inst{5-0} = 0x3c;
430 class JALR_FM_MM<bits<10> funct> {
436 let Inst{31-26} = 0x00;
437 let Inst{25-21} = rd;
438 let Inst{20-16} = rs;
439 let Inst{15-6} = funct;
440 let Inst{5-0} = 0x3c;
443 class BEQ_FM_MM<bits<6> op> : MMArch {
450 let Inst{31-26} = op;
451 let Inst{25-21} = rt;
452 let Inst{20-16} = rs;
453 let Inst{15-0} = offset;
456 class BGEZ_FM_MM<bits<5> funct> : MMArch {
462 let Inst{31-26} = 0x10;
463 let Inst{25-21} = funct;
464 let Inst{20-16} = rs;
465 let Inst{15-0} = offset;
468 class BGEZAL_FM_MM<bits<5> funct> : MMArch {
474 let Inst{31-26} = 0x10;
475 let Inst{25-21} = funct;
476 let Inst{20-16} = rs;
477 let Inst{15-0} = offset;
480 class SYNC_FM_MM : MMArch {
485 let Inst{31-26} = 0x00;
486 let Inst{25-21} = 0x0;
487 let Inst{20-16} = stype;
488 let Inst{15-6} = 0x1ad;
489 let Inst{5-0} = 0x3c;
492 class BRK_FM_MM : MMArch {
496 let Inst{31-26} = 0x0;
497 let Inst{25-16} = code_1;
498 let Inst{15-6} = code_2;
499 let Inst{5-0} = 0x07;
502 class SYS_FM_MM : MMArch {
505 let Inst{31-26} = 0x0;
506 let Inst{25-16} = code_;
507 let Inst{15-6} = 0x22d;
508 let Inst{5-0} = 0x3c;
515 let Inst{31-26} = 0x00;
516 let Inst{25-16} = code_;
517 let Inst{15-6} = 0x24d;
518 let Inst{5-0} = 0x3c;
521 class ER_FM_MM<bits<10> funct> : MMArch {
524 let Inst{31-26} = 0x00;
525 let Inst{25-16} = 0x00;
526 let Inst{15-6} = funct;
527 let Inst{5-0} = 0x3c;
530 class EI_FM_MM<bits<10> funct> : MMArch {
534 let Inst{31-26} = 0x00;
535 let Inst{25-21} = 0x00;
536 let Inst{20-16} = rt;
537 let Inst{15-6} = funct;
538 let Inst{5-0} = 0x3c;
541 class TEQ_FM_MM<bits<6> funct> : MMArch {
548 let Inst{31-26} = 0x00;
549 let Inst{25-21} = rt;
550 let Inst{20-16} = rs;
551 let Inst{15-12} = code_;
552 let Inst{11-6} = funct;
553 let Inst{5-0} = 0x3c;
556 class TEQI_FM_MM<bits<5> funct> : MMArch {
562 let Inst{31-26} = 0x10;
563 let Inst{25-21} = funct;
564 let Inst{20-16} = rs;
565 let Inst{15-0} = imm16;
568 class LL_FM_MM<bits<4> funct> {
574 let Inst{31-26} = 0x18;
575 let Inst{25-21} = rt;
576 let Inst{20-16} = addr{20-16};
577 let Inst{15-12} = funct;
578 let Inst{11-0} = addr{11-0};
581 class ADDS_FM_MM<bits<2> fmt, bits<8> funct> : MMArch {
588 let Inst{31-26} = 0x15;
589 let Inst{25-21} = ft;
590 let Inst{20-16} = fs;
591 let Inst{15-11} = fd;
594 let Inst{7-0} = funct;
596 list<dag> Pattern = [];
599 class LWXC1_FM_MM<bits<9> funct> : MMArch {
606 let Inst{31-26} = 0x15;
607 let Inst{25-21} = index;
608 let Inst{20-16} = base;
609 let Inst{15-11} = fd;
610 let Inst{10-9} = 0x0;
611 let Inst{8-0} = funct;
614 class SWXC1_FM_MM<bits<9> funct> : MMArch {
621 let Inst{31-26} = 0x15;
622 let Inst{25-21} = index;
623 let Inst{20-16} = base;
624 let Inst{15-11} = fs;
625 let Inst{10-9} = 0x0;
626 let Inst{8-0} = funct;
629 class CEQS_FM_MM<bits<2> fmt> : MMArch {
636 let Inst{31-26} = 0x15;
637 let Inst{25-21} = ft;
638 let Inst{20-16} = fs;
639 let Inst{15-13} = 0x0; // cc
641 let Inst{11-10} = fmt;
642 let Inst{9-6} = cond;
643 let Inst{5-0} = 0x3c;
646 class BC1F_FM_MM<bits<5> tf> : MMArch {
651 let Inst{31-26} = 0x10;
652 let Inst{25-21} = tf;
653 let Inst{20-18} = 0x0; // cc
654 let Inst{17-16} = 0x0;
655 let Inst{15-0} = offset;
658 class ROUND_W_FM_MM<bits<1> fmt, bits<8> funct> : MMArch {
664 let Inst{31-26} = 0x15;
665 let Inst{25-21} = fd;
666 let Inst{20-16} = fs;
669 let Inst{13-6} = funct;
670 let Inst{5-0} = 0x3b;
673 class ABS_FM_MM<bits<2> fmt, bits<7> funct> : MMArch {
679 let Inst{31-26} = 0x15;
680 let Inst{25-21} = fd;
681 let Inst{20-16} = fs;
683 let Inst{14-13} = fmt;
684 let Inst{12-6} = funct;
685 let Inst{5-0} = 0x3b;
688 class CMov_F_F_FM_MM<bits<9> func, bits<2> fmt> : MMArch {
694 let Inst{31-26} = 0x15;
695 let Inst{25-21} = fd;
696 let Inst{20-16} = fs;
697 let Inst{15-13} = 0x0; //cc
698 let Inst{12-11} = 0x0;
699 let Inst{10-9} = fmt;
700 let Inst{8-0} = func;
703 class CMov_I_F_FM_MM<bits<8> funct, bits<2> fmt> : MMArch {
710 let Inst{31-26} = 0x15;
711 let Inst{25-21} = rt;
712 let Inst{20-16} = fs;
713 let Inst{15-11} = fd;
715 let Inst{7-0} = funct;
718 class MFC1_FM_MM<bits<8> funct> : MMArch {
724 let Inst{31-26} = 0x15;
725 let Inst{25-21} = rt;
726 let Inst{20-16} = fs;
727 let Inst{15-14} = 0x0;
728 let Inst{13-6} = funct;
729 let Inst{5-0} = 0x3b;
732 class MADDS_FM_MM<bits<6> funct>: MMArch {
740 let Inst{31-26} = 0x15;
741 let Inst{25-21} = ft;
742 let Inst{20-16} = fs;
743 let Inst{15-11} = fd;
745 let Inst{5-0} = funct;
748 class COMPACT_BRANCH_FM_MM<bits<5> funct> {
754 let Inst{31-26} = 0x10;
755 let Inst{25-21} = funct;
756 let Inst{20-16} = rs;
757 let Inst{15-0} = offset;
760 class COP0_TLB_FM_MM<bits<10> op> : MMArch {
763 let Inst{31-26} = 0x0;
764 let Inst{25-16} = 0x0;
766 let Inst{5-0} = 0x3c;
769 class SDBBP_FM_MM : MMArch {
774 let Inst{31-26} = 0x0;
775 let Inst{25-16} = code_;
776 let Inst{15-6} = 0x36d;
777 let Inst{5-0} = 0x3c;
780 class RDHWR_FM_MM : MMArch {
786 let Inst{31-26} = 0x0;
787 let Inst{25-21} = rt;
788 let Inst{20-16} = rd;
789 let Inst{15-6} = 0x1ac;
790 let Inst{5-0} = 0x3c;
793 class LWXS_FM_MM<bits<10> funct> {
800 let Inst{31-26} = 0x0;
801 let Inst{25-21} = index;
802 let Inst{20-16} = base;
803 let Inst{15-11} = rd;
805 let Inst{9-0} = funct;