1 //===-- MicroMipsInstrFormats.td - microMIPS Inst Formats -*- tablegen -*--===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This files descributes the formats of the microMIPS instruction set.
11 //===----------------------------------------------------------------------===//
13 //===----------------------------------------------------------------------===//
14 // MicroMIPS Base Classes
15 //===----------------------------------------------------------------------===//
18 // Base class for MicroMips instructions.
19 // This class does not depend on the instruction size.
21 class MicroMipsInstBase<dag outs, dag ins, string asmstr, list<dag> pattern,
22 InstrItinClass itin, Format f> : Instruction,
24 let Namespace = "Mips";
25 let DecoderNamespace = "MicroMips";
27 let OutOperandList = outs;
28 let InOperandList = ins;
30 let AsmString = asmstr;
31 let Pattern = pattern;
34 let EncodingPredicates = [InMicroMips];
40 // Base class for MicroMIPS 16-bit instructions.
42 class MicroMipsInst16<dag outs, dag ins, string asmstr, list<dag> pattern,
43 InstrItinClass itin, Format f> :
44 MicroMipsInstBase<outs, ins, asmstr, pattern, itin, f>
48 field bits<16> SoftFail = 0;
52 //===----------------------------------------------------------------------===//
53 // MicroMIPS 16-bit Instruction Formats
54 //===----------------------------------------------------------------------===//
56 class ARITH_FM_MM16<bit funct> {
63 let Inst{15-10} = 0x01;
70 class ANDI_FM_MM16<bits<6> funct> {
77 let Inst{15-10} = funct;
83 class LOGIC_FM_MM16<bits<4> funct> {
89 let Inst{15-10} = 0x11;
90 let Inst{9-6} = funct;
95 class SHIFT_FM_MM16<bits<1> funct> {
102 let Inst{15-10} = 0x09;
105 let Inst{3-1} = shamt;
109 class ADDIUR2_FM_MM16 {
116 let Inst{15-10} = 0x1b;
123 class LOAD_STORE_FM_MM16<bits<6> op> {
129 let Inst{15-10} = op;
131 let Inst{6-4} = addr{6-4};
132 let Inst{3-0} = addr{3-0};
135 class LOAD_STORE_SP_FM_MM16<bits<6> op> {
141 let Inst{15-10} = op;
143 let Inst{4-0} = offset;
146 class LOAD_GP_FM_MM16<bits<6> op> {
152 let Inst{15-10} = op;
154 let Inst{6-0} = offset;
157 class ADDIUS5_FM_MM16 {
163 let Inst{15-10} = 0x13;
169 class ADDIUSP_FM_MM16 {
174 let Inst{15-10} = 0x13;
179 class MOVE_FM_MM16<bits<6> funct> {
185 let Inst{15-10} = funct;
196 let Inst{15-10} = 0x3b;
201 class JALR_FM_MM16<bits<5> op> {
206 let Inst{15-10} = 0x11;
211 class MFHILO_FM_MM16<bits<5> funct> {
216 let Inst{15-10} = 0x11;
217 let Inst{9-5} = funct;
221 class JRADDIUSP_FM_MM16<bits<5> op> {
227 let Inst{15-10} = 0x11;
232 class ADDIUR1SP_FM_MM16 {
238 let Inst{15-10} = 0x1b;
244 class BRKSDBBP16_FM_MM<bits<6> op> {
248 let Inst{15-10} = 0x11;
250 let Inst{3-0} = code_;
253 class BEQNEZ_FM_MM16<bits<6> op> {
259 let Inst{15-10} = op;
261 let Inst{6-0} = offset;
269 let Inst{15-10} = 0x33;
270 let Inst{9-0} = offset;
273 class MOVEP_FM_MM16 {
280 let Inst{15-10} = 0x21;
281 let Inst{9-7} = dst_regs;
287 //===----------------------------------------------------------------------===//
288 // MicroMIPS 32-bit Instruction Formats
289 //===----------------------------------------------------------------------===//
292 string Arch = "micromips";
295 class ADD_FM_MM<bits<6> op, bits<10> funct> : MMArch {
302 let Inst{31-26} = op;
303 let Inst{25-21} = rt;
304 let Inst{20-16} = rs;
305 let Inst{15-11} = rd;
307 let Inst{9-0} = funct;
310 class ADDI_FM_MM<bits<6> op> : MMArch {
317 let Inst{31-26} = op;
318 let Inst{25-21} = rt;
319 let Inst{20-16} = rs;
320 let Inst{15-0} = imm16;
323 class SLTI_FM_MM<bits<6> op> : MMArch {
330 let Inst{31-26} = op;
331 let Inst{25-21} = rt;
332 let Inst{20-16} = rs;
333 let Inst{15-0} = imm16;
336 class LUI_FM_MM : MMArch {
342 let Inst{31-26} = 0x10;
343 let Inst{25-21} = 0xd;
344 let Inst{20-16} = rt;
345 let Inst{15-0} = imm16;
348 class MULT_FM_MM<bits<10> funct> : MMArch {
354 let Inst{31-26} = 0x00;
355 let Inst{25-21} = rt;
356 let Inst{20-16} = rs;
357 let Inst{15-6} = funct;
358 let Inst{5-0} = 0x3c;
361 class SRA_FM_MM<bits<10> funct, bit rotate> : MMArch {
369 let Inst{25-21} = rd;
370 let Inst{20-16} = rt;
371 let Inst{15-11} = shamt;
372 let Inst{10} = rotate;
373 let Inst{9-0} = funct;
376 class SRLV_FM_MM<bits<10> funct, bit rotate> : MMArch {
384 let Inst{25-21} = rt;
385 let Inst{20-16} = rs;
386 let Inst{15-11} = rd;
387 let Inst{10} = rotate;
388 let Inst{9-0} = funct;
391 class LW_FM_MM<bits<6> op> : MMArch {
394 bits<5> base = addr{20-16};
395 bits<16> offset = addr{15-0};
399 let Inst{31-26} = op;
400 let Inst{25-21} = rt;
401 let Inst{20-16} = base;
402 let Inst{15-0} = offset;
405 class POOL32C_LHUE_FM_MM<bits<6> op, bits<4> fmt, bits<3> funct> : MMArch {
408 bits<5> base = addr{20-16};
409 bits<9> offset = addr{8-0};
413 let Inst{31-26} = op;
414 let Inst{25-21} = rt;
415 let Inst{20-16} = base;
416 let Inst{15-12} = fmt;
417 let Inst{11-9} = funct;
418 let Inst{8-0} = offset;
421 class LWL_FM_MM<bits<4> funct> : MMArch {
427 let Inst{31-26} = 0x18;
428 let Inst{25-21} = rt;
429 let Inst{20-16} = addr{20-16};
430 let Inst{15-12} = funct;
431 let Inst{11-0} = addr{11-0};
434 class POOL32C_STEVA_LDEVA_FM_MM<bits<4> type, bits<3> funct> : MMArch {
437 bits<5> base = addr{20-16};
438 bits<9> offset = addr{8-0};
442 let Inst{31-26} = 0x18;
443 let Inst{25-21} = rt;
444 let Inst{20-16} = base;
445 let Inst{15-12} = type;
446 let Inst{11-9} = funct;
447 let Inst{8-0} = offset;
450 class CMov_F_I_FM_MM<bits<7> func> : MMArch {
457 let Inst{31-26} = 0x15;
458 let Inst{25-21} = rd;
459 let Inst{20-16} = rs;
460 let Inst{15-13} = fcc;
461 let Inst{12-6} = func;
462 let Inst{5-0} = 0x3b;
465 class MTLO_FM_MM<bits<10> funct> : MMArch {
470 let Inst{31-26} = 0x00;
471 let Inst{25-21} = 0x00;
472 let Inst{20-16} = rs;
473 let Inst{15-6} = funct;
474 let Inst{5-0} = 0x3c;
477 class MFLO_FM_MM<bits<10> funct> : MMArch {
482 let Inst{31-26} = 0x00;
483 let Inst{25-21} = 0x00;
484 let Inst{20-16} = rd;
485 let Inst{15-6} = funct;
486 let Inst{5-0} = 0x3c;
489 class CLO_FM_MM<bits<10> funct> : MMArch {
495 let Inst{31-26} = 0x00;
496 let Inst{25-21} = rd;
497 let Inst{20-16} = rs;
498 let Inst{15-6} = funct;
499 let Inst{5-0} = 0x3c;
502 class SEB_FM_MM<bits<10> funct> : MMArch {
508 let Inst{31-26} = 0x00;
509 let Inst{25-21} = rd;
510 let Inst{20-16} = rt;
511 let Inst{15-6} = funct;
512 let Inst{5-0} = 0x3c;
515 class EXT_FM_MM<bits<6> funct> : MMArch {
523 let Inst{31-26} = 0x00;
524 let Inst{25-21} = rt;
525 let Inst{20-16} = rs;
526 let Inst{15-11} = size;
527 let Inst{10-6} = pos;
528 let Inst{5-0} = funct;
531 class J_FM_MM<bits<6> op> : MMArch {
536 let Inst{31-26} = op;
537 let Inst{25-0} = target;
540 class JR_FM_MM<bits<8> funct> : MMArch {
545 let Inst{31-21} = 0x00;
546 let Inst{20-16} = rs;
547 let Inst{15-14} = 0x0;
548 let Inst{13-6} = funct;
549 let Inst{5-0} = 0x3c;
552 class JALR_FM_MM<bits<10> funct> {
558 let Inst{31-26} = 0x00;
559 let Inst{25-21} = rd;
560 let Inst{20-16} = rs;
561 let Inst{15-6} = funct;
562 let Inst{5-0} = 0x3c;
565 class BEQ_FM_MM<bits<6> op> : MMArch {
572 let Inst{31-26} = op;
573 let Inst{25-21} = rt;
574 let Inst{20-16} = rs;
575 let Inst{15-0} = offset;
578 class BGEZ_FM_MM<bits<5> funct> : MMArch {
584 let Inst{31-26} = 0x10;
585 let Inst{25-21} = funct;
586 let Inst{20-16} = rs;
587 let Inst{15-0} = offset;
590 class BGEZAL_FM_MM<bits<5> funct> : MMArch {
596 let Inst{31-26} = 0x10;
597 let Inst{25-21} = funct;
598 let Inst{20-16} = rs;
599 let Inst{15-0} = offset;
602 class SYNC_FM_MM : MMArch {
607 let Inst{31-26} = 0x00;
608 let Inst{25-21} = 0x0;
609 let Inst{20-16} = stype;
610 let Inst{15-6} = 0x1ad;
611 let Inst{5-0} = 0x3c;
614 class SYNCI_FM_MM : MMArch {
616 bits<5> rs = addr{20-16};
617 bits<16> offset = addr{15-0};
620 let Inst{31-26} = 0b010000;
621 let Inst{25-21} = 0b10000;
622 let Inst{20-16} = rs;
623 let Inst{15-0} = offset;
626 class BRK_FM_MM : MMArch {
630 let Inst{31-26} = 0x0;
631 let Inst{25-16} = code_1;
632 let Inst{15-6} = code_2;
633 let Inst{5-0} = 0x07;
636 class SYS_FM_MM : MMArch {
639 let Inst{31-26} = 0x0;
640 let Inst{25-16} = code_;
641 let Inst{15-6} = 0x22d;
642 let Inst{5-0} = 0x3c;
645 class WAIT_FM_MM : MMArch {
649 let Inst{31-26} = 0x00;
650 let Inst{25-16} = code_;
651 let Inst{15-6} = 0x24d;
652 let Inst{5-0} = 0x3c;
655 class ER_FM_MM<bits<10> funct> : MMArch {
658 let Inst{31-26} = 0x00;
659 let Inst{25-16} = 0x00;
660 let Inst{15-6} = funct;
661 let Inst{5-0} = 0x3c;
664 class EI_FM_MM<bits<10> funct> : MMArch {
668 let Inst{31-26} = 0x00;
669 let Inst{25-21} = 0x00;
670 let Inst{20-16} = rt;
671 let Inst{15-6} = funct;
672 let Inst{5-0} = 0x3c;
675 class TEQ_FM_MM<bits<6> funct> : MMArch {
682 let Inst{31-26} = 0x00;
683 let Inst{25-21} = rt;
684 let Inst{20-16} = rs;
685 let Inst{15-12} = code_;
686 let Inst{11-6} = funct;
687 let Inst{5-0} = 0x3c;
690 class TEQI_FM_MM<bits<5> funct> : MMArch {
696 let Inst{31-26} = 0x10;
697 let Inst{25-21} = funct;
698 let Inst{20-16} = rs;
699 let Inst{15-0} = imm16;
702 class LL_FM_MM<bits<4> funct> : MMArch {
708 let Inst{31-26} = 0x18;
709 let Inst{25-21} = rt;
710 let Inst{20-16} = addr{20-16};
711 let Inst{15-12} = funct;
712 let Inst{11-0} = addr{11-0};
715 class LLE_FM_MM<bits<4> funct> : MMArch {
718 bits<5> base = addr{20-16};
719 bits<9> offset = addr{8-0};
723 let Inst{31-26} = 0x18;
724 let Inst{25-21} = rt;
725 let Inst{20-16} = base;
726 let Inst{15-12} = funct;
727 let Inst{11-9} = 0x6;
728 let Inst{8-0} = offset;
731 class ADDS_FM_MM<bits<2> fmt, bits<8> funct> : MMArch {
738 let Inst{31-26} = 0x15;
739 let Inst{25-21} = ft;
740 let Inst{20-16} = fs;
741 let Inst{15-11} = fd;
744 let Inst{7-0} = funct;
748 class LWXC1_FM_MM<bits<9> funct> : MMArch {
755 let Inst{31-26} = 0x15;
756 let Inst{25-21} = index;
757 let Inst{20-16} = base;
758 let Inst{15-11} = fd;
759 let Inst{10-9} = 0x0;
760 let Inst{8-0} = funct;
763 class SWXC1_FM_MM<bits<9> funct> : MMArch {
770 let Inst{31-26} = 0x15;
771 let Inst{25-21} = index;
772 let Inst{20-16} = base;
773 let Inst{15-11} = fs;
774 let Inst{10-9} = 0x0;
775 let Inst{8-0} = funct;
778 class CEQS_FM_MM<bits<2> fmt> : MMArch {
786 let Inst{31-26} = 0x15;
787 let Inst{25-21} = ft;
788 let Inst{20-16} = fs;
789 let Inst{15-13} = fcc;
791 let Inst{11-10} = fmt;
792 let Inst{9-6} = cond;
793 let Inst{5-0} = 0x3c;
796 class C_COND_FM_MM<bits <2> fmt, bits<4> c> : CEQS_FM_MM<fmt> {
800 class BC1F_FM_MM<bits<5> tf> : MMArch {
806 let Inst{31-26} = 0x10;
807 let Inst{25-21} = tf;
808 let Inst{20-18} = fcc; // cc
809 let Inst{17-16} = 0x0;
810 let Inst{15-0} = offset;
813 class ROUND_W_FM_MM<bits<1> fmt, bits<8> funct> : MMArch {
819 let Inst{31-26} = 0x15;
820 let Inst{25-21} = fd;
821 let Inst{20-16} = fs;
824 let Inst{13-6} = funct;
825 let Inst{5-0} = 0x3b;
828 class ABS_FM_MM<bits<2> fmt, bits<7> funct> : MMArch {
834 let Inst{31-26} = 0x15;
835 let Inst{25-21} = fd;
836 let Inst{20-16} = fs;
838 let Inst{14-13} = fmt;
839 let Inst{12-6} = funct;
840 let Inst{5-0} = 0x3b;
843 class CMov_F_F_FM_MM<bits<9> func, bits<2> fmt> : MMArch {
849 let Inst{31-26} = 0x15;
850 let Inst{25-21} = fd;
851 let Inst{20-16} = fs;
852 let Inst{15-13} = fcc; //cc
853 let Inst{12-11} = 0x0;
854 let Inst{10-9} = fmt;
855 let Inst{8-0} = func;
858 class CMov_I_F_FM_MM<bits<8> funct, bits<2> fmt> : MMArch {
865 let Inst{31-26} = 0x15;
866 let Inst{25-21} = rt;
867 let Inst{20-16} = fs;
868 let Inst{15-11} = fd;
870 let Inst{7-0} = funct;
873 class MFC1_FM_MM<bits<8> funct> : MMArch {
879 let Inst{31-26} = 0x15;
880 let Inst{25-21} = rt;
881 let Inst{20-16} = fs;
882 let Inst{15-14} = 0x0;
883 let Inst{13-6} = funct;
884 let Inst{5-0} = 0x3b;
887 class MADDS_FM_MM<bits<6> funct>: MMArch {
895 let Inst{31-26} = 0x15;
896 let Inst{25-21} = ft;
897 let Inst{20-16} = fs;
898 let Inst{15-11} = fd;
900 let Inst{5-0} = funct;
903 class COMPACT_BRANCH_FM_MM<bits<5> funct> {
909 let Inst{31-26} = 0x10;
910 let Inst{25-21} = funct;
911 let Inst{20-16} = rs;
912 let Inst{15-0} = offset;
915 class COP0_TLB_FM_MM<bits<10> op> : MMArch {
918 let Inst{31-26} = 0x0;
919 let Inst{25-16} = 0x0;
921 let Inst{5-0} = 0x3c;
924 class SDBBP_FM_MM : MMArch {
929 let Inst{31-26} = 0x0;
930 let Inst{25-16} = code_;
931 let Inst{15-6} = 0x36d;
932 let Inst{5-0} = 0x3c;
935 class SIGRIE_FM_MM : MMArch {
940 let Inst{31-26} = 0x0;
941 let Inst{25-22} = 0x0;
942 let Inst{21-6} = code_;
943 let Inst{5-0} = 0b111111;
946 class RDHWR_FM_MM : MMArch {
952 let Inst{31-26} = 0x0;
953 let Inst{25-21} = rt;
954 let Inst{20-16} = rd;
955 let Inst{15-6} = 0x1ac;
956 let Inst{5-0} = 0x3c;
959 class LWXS_FM_MM<bits<10> funct> {
966 let Inst{31-26} = 0x0;
967 let Inst{25-21} = index;
968 let Inst{20-16} = base;
969 let Inst{15-11} = rd;
971 let Inst{9-0} = funct;
974 class LWM_FM_MM<bits<4> funct> : MMArch {
980 let Inst{31-26} = 0x8;
981 let Inst{25-21} = rt;
982 let Inst{20-16} = addr{20-16};
983 let Inst{15-12} = funct;
984 let Inst{11-0} = addr{11-0};
987 class LWM_FM_MM16<bits<4> funct> : MMArch {
993 let Inst{15-10} = 0x11;
994 let Inst{9-6} = funct;
996 let Inst{3-0} = addr;
999 class CACHE_PREF_FM_MM<bits<6> op, bits<4> funct> : MMArch {
1002 bits<5> base = addr{20-16};
1003 bits<12> offset = addr{11-0};
1007 let Inst{31-26} = op;
1008 let Inst{25-21} = hint;
1009 let Inst{20-16} = base;
1010 let Inst{15-12} = funct;
1011 let Inst{11-0} = offset;
1014 class CACHE_PREFE_FM_MM<bits<6> op, bits<3> funct> : MMArch {
1017 bits<5> base = addr{20-16};
1018 bits<9> offset = addr{8-0};
1022 let Inst{31-26} = op;
1023 let Inst{25-21} = hint;
1024 let Inst{20-16} = base;
1025 let Inst{15-12} = 0xA;
1026 let Inst{11-9} = funct;
1027 let Inst{8-0} = offset;
1030 class POOL32F_PREFX_FM_MM<bits<6> op, bits<9> funct> : MMArch {
1037 let Inst{31-26} = op;
1038 let Inst{25-21} = index;
1039 let Inst{20-16} = base;
1040 let Inst{15-11} = hint;
1041 let Inst{10-9} = 0x0;
1042 let Inst{8-0} = funct;
1045 class BARRIER_FM_MM<bits<5> op> : MMArch {
1048 let Inst{31-26} = 0x0;
1049 let Inst{25-21} = 0x0;
1050 let Inst{20-16} = 0x0;
1051 let Inst{15-11} = op;
1052 let Inst{10-6} = 0x0;
1053 let Inst{5-0} = 0x0;
1056 class ADDIUPC_FM_MM {
1062 let Inst{31-26} = 0x1e;
1063 let Inst{25-23} = rs;
1064 let Inst{22-0} = imm;
1067 class POOL32A_CFTC2_FM_MM<bits<10> funct> : MMArch {
1073 let Inst{31-26} = 0b000000;
1074 let Inst{25-21} = rt;
1075 let Inst{20-16} = impl;
1076 let Inst{15-6} = funct;
1077 let Inst{5-0} = 0b111100;
1080 class POOL32A_TLBINV_FM_MM<bits<10> funct> : MMArch {
1083 let Inst{31-26} = 0x0;
1084 let Inst{25-16} = 0x0;
1085 let Inst{15-6} = funct;
1086 let Inst{5-0} = 0b111100;
1089 class POOL32A_MFTC0_FM_MM<bits<5> funct, bits<6> opcode> : MMArch {
1096 let Inst{31-26} = 0b000000;
1097 let Inst{25-21} = rt;
1098 let Inst{20-16} = rs;
1099 let Inst{15-14} = 0;
1100 let Inst{13-11} = sel;
1101 let Inst{10-6} = funct;
1102 let Inst{5-0} = opcode;
1105 class POOL32A_HYPCALL_FM_MM : MMArch {
1110 let Inst{31-26} = 0x0;
1111 let Inst{25-16} = code_;
1112 let Inst{15-6} = 0b1100001101;
1113 let Inst{5-0} = 0b111100;