1 //=- MicroMips32r6InstrFormats.td - Mips32r6 Instruction 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 file describes microMIPS32r6 instruction formats.
11 //===----------------------------------------------------------------------===//
13 class MMR6Arch<string opstr> {
14 string Arch = "micromipsr6";
15 string BaseOpcode = opstr;
16 string DecoderNamespace = "MicroMipsR6";
19 //===----------------------------------------------------------------------===//
23 //===----------------------------------------------------------------------===//
25 // Some encodings are ambiguous except by comparing field values.
27 class MMDecodeDisambiguatedBy<string Name> : DecodeDisambiguates<Name> {
28 string DecoderNamespace = "MicroMipsR6_Ambiguous";
31 //===----------------------------------------------------------------------===//
35 //===----------------------------------------------------------------------===//
37 class BC16_FM_MM16R6 {
42 let Inst{15-10} = 0x33;
43 let Inst{9-0} = offset;
46 class BEQZC_BNEZC_FM_MM16R6<bits<6> op> {
54 let Inst{6-0} = offset;
57 class POOL16C_JALRC_FM_MM16R6<bits<5> op> {
62 let Inst{15-10} = 0x11;
67 class POP35_BOVC_FM_MMR6<string instr_asm> : MipsR6Inst, MMR6Arch<instr_asm> {
74 let Inst{31-26} = 0b011101;
77 let Inst{15-0} = offset;
80 class POP37_BNVC_FM_MMR6<string instr_asm> : MipsR6Inst, MMR6Arch<instr_asm> {
87 let Inst{31-26} = 0b011111;
90 let Inst{15-0} = offset;
93 class POOL16C_JRCADDIUSP_FM_MM16R6<bits<5> op> {
98 let Inst{15-10} = 0x11;
103 class POOL16C_LWM_SWM_FM_MM16R6<bits<4> funct> {
109 let Inst{15-10} = 0x11;
111 let Inst{7-4} = addr;
112 let Inst{3-0} = funct;
115 class POOL32A_BITSWAP_FM_MMR6<bits<6> funct> : MipsR6Inst {
121 let Inst{31-26} = 0b000000;
122 let Inst{25-21} = rt;
123 let Inst{20-16} = rd;
124 let Inst{15-12} = 0b0000;
125 let Inst{11-6} = funct;
126 let Inst{5-0} = 0b111100;
129 class CACHE_PREF_FM_MMR6<bits<6> opgroup, bits<4> funct> : MipsR6Inst {
135 let Inst{31-26} = opgroup;
136 let Inst{25-21} = hint;
137 let Inst{20-16} = addr{20-16};
138 let Inst{15-12} = funct;
139 let Inst{11-0} = addr{11-0};
142 class ARITH_FM_MMR6<string instr_asm, bits<10> funct> : MMR6Arch<instr_asm> {
150 let Inst{25-21} = rt;
151 let Inst{20-16} = rs;
152 let Inst{15-11} = rd;
154 let Inst{9-0} = funct;
157 class ADDI_FM_MMR6<string instr_asm, bits<6> op> : MMR6Arch<instr_asm> {
164 let Inst{31-26} = op;
165 let Inst{25-21} = rt;
166 let Inst{20-16} = rs;
167 let Inst{15-0} = imm16;
170 class LB32_FM_MMR6 : MipsR6Inst {
173 bits<5> base = addr{20-16};
174 bits<16> offset = addr{15-0};
178 let Inst{31-26} = 0b000111;
179 let Inst{25-21} = rt;
180 let Inst{20-16} = base;
181 let Inst{15-0} = offset;
184 class LBU32_FM_MMR6 : MipsR6Inst {
187 bits<5> base = addr{20-16};
188 bits<16> offset = addr{15-0};
192 let Inst{31-26} = 0b000101;
193 let Inst{25-21} = rt;
194 let Inst{20-16} = base;
195 let Inst{15-0} = offset;
198 class PCREL19_FM_MMR6<bits<2> funct> : MipsR6Inst {
204 let Inst{31-26} = 0b011110;
205 let Inst{25-21} = rt;
206 let Inst{20-19} = funct;
207 let Inst{18-0} = imm;
210 class PCREL16_FM_MMR6<bits<5> funct> : MipsR6Inst {
216 let Inst{31-26} = 0b011110;
217 let Inst{25-21} = rt;
218 let Inst{20-16} = funct;
219 let Inst{15-0} = imm;
222 class POOL32A_FM_MMR6<bits<10> funct> : MipsR6Inst {
229 let Inst{31-26} = 0b000000;
230 let Inst{25-21} = rt;
231 let Inst{20-16} = rs;
232 let Inst{15-11} = rd;
234 let Inst{9-0} = funct;
237 class POOL32A_PAUSE_FM_MMR6<string instr_asm, bits<5> op>
238 : MMR6Arch<instr_asm> {
244 let Inst{15-11} = op;
249 class POOL32A_RDPGPR_FM_MMR6<bits<10> funct> {
255 let Inst{25-21} = rt;
256 let Inst{20-16} = rd;
257 let Inst{15-6} = funct;
258 let Inst{5-0} = 0b111100;
261 class POOL32A_RDHWR_FM_MMR6 {
268 let Inst{25-21} = rt;
269 let Inst{20-16} = rs;
271 let Inst{13-11} = sel;
273 let Inst{9-0} = 0b0111000000;
276 class POOL32A_SYNC_FM_MMR6 {
283 let Inst{20-16} = stype;
284 let Inst{15-6} = 0b0110101101;
285 let Inst{5-0} = 0b111100;
288 class POOL32I_SYNCI_FM_MMR6 {
290 bits<5> base = addr{20-16};
291 bits<16> immediate = addr{15-0};
295 let Inst{31-26} = 0b010000;
296 let Inst{25-21} = 0b01100;
297 let Inst{20-16} = base;
298 let Inst{15-0} = immediate;
301 class POOL32A_2R_FM_MMR6<bits<10> funct> : MipsR6Inst {
307 let Inst{31-26} = 0b000000;
308 let Inst{25-21} = rt;
309 let Inst{20-16} = rs;
310 let Inst{15-6} = funct;
311 let Inst{5-0} = 0b111100;
314 class SPECIAL_2R_FM_MMR6<bits<6> funct> : MipsR6Inst {
320 let Inst{31-26} = 0b000000;
321 let Inst{25-21} = rs;
322 let Inst{20-16} = 0b00000;
323 let Inst{15-11} = rt;
324 let Inst{10-6} = 0b00001;
325 let Inst{5-0} = funct;
328 class POOL32A_ALIGN_FM_MMR6<bits<6> funct> : MipsR6Inst {
336 let Inst{31-26} = 0b000000;
337 let Inst{25-21} = rs;
338 let Inst{20-16} = rt;
339 let Inst{15-11} = rd;
341 let Inst{8-6} = 0b000;
342 let Inst{5-0} = funct;
345 class AUI_FM_MMR6 : MipsR6Inst {
352 let Inst{31-26} = 0b000100;
353 let Inst{25-21} = rt;
354 let Inst{20-16} = rs;
355 let Inst{15-0} = imm;
358 class POOL32A_LSA_FM<bits<6> funct> : MipsR6Inst {
366 let Inst{31-26} = 0b000000;
367 let Inst{25-21} = rt;
368 let Inst{20-16} = rs;
369 let Inst{15-11} = rd;
370 let Inst{10-9} = imm2;
371 let Inst{8-6} = 0b000;
372 let Inst{5-0} = funct;
375 class SB32_SH32_STORE_FM_MMR6<bits<6> op> {
378 bits<5> base = addr{20-16};
379 bits<16> offset = addr{15-0};
383 let Inst{31-26} = op;
384 let Inst{25-21} = rt;
385 let Inst{20-16} = base;
386 let Inst{15-0} = offset;
389 class LOAD_WORD_FM_MMR6 {
392 bits<5> base = addr{20-16};
393 bits<16> offset = addr{15-0};
397 let Inst{31-26} = 0b111111;
398 let Inst{25-21} = rt;
399 let Inst{20-16} = base;
400 let Inst{15-0} = offset;
403 class LOAD_UPPER_IMM_FM_MMR6 {
409 let Inst{31-26} = 0b000100;
410 let Inst{25-21} = rt;
412 let Inst{15-0} = imm16;
415 class CMP_BRANCH_1R_RT_OFF16_FM_MMR6<string instr_asm, bits<6> funct>
416 : MMR6Arch<instr_asm>, MipsR6Inst {
422 let Inst{31-26} = funct;
423 let Inst{25-21} = rt;
424 let Inst{20-16} = 0b00000;
425 let Inst{15-0} = offset;
428 class CMP_BRANCH_1R_BOTH_OFF16_FM_MMR6<string instr_asm, bits<6> funct>
429 : MMR6Arch<instr_asm>, MipsR6Inst {
435 let Inst{31-26} = funct;
436 let Inst{25-21} = rt;
437 let Inst{20-16} = rt;
438 let Inst{15-0} = offset;
441 class POOL32A_JALRC_FM_MMR6<string instr_asm, bits<10> funct>
442 : MipsR6Inst, MMR6Arch<instr_asm> {
449 let Inst{25-21} = rt;
450 let Inst{20-16} = rs;
451 let Inst{15-6} = funct;
452 let Inst{5-0} = 0b111100;
455 class POOL32A_EXT_INS_FM_MMR6<string instr_asm, bits<6> funct>
456 : MMR6Arch<instr_asm>, MipsR6Inst {
465 let Inst{25-21} = rt;
466 let Inst{20-16} = rs;
467 let Inst{15-11} = size;
468 let Inst{10-6} = pos;
469 let Inst{5-0} = funct;
472 class POOL32A_ERET_FM_MMR6<string instr_asm, bits<10> funct>
473 : MMR6Arch<instr_asm> {
476 let Inst{31-26} = 0x00;
477 let Inst{25-16} = 0x00;
478 let Inst{15-6} = funct;
479 let Inst{5-0} = 0x3c;
482 class ERETNC_FM_MMR6<string instr_asm> : MMR6Arch<instr_asm> {
485 let Inst{31-26} = 0x00;
486 let Inst{25-17} = 0x00;
487 let Inst{16-16} = 0x01;
488 let Inst{15-6} = 0x3cd;
489 let Inst{5-0} = 0x3c;
492 class BREAK_MMR6_ENC<string instr_asm> : MMR6Arch<instr_asm> {
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 BARRIER_MMR6_ENC<string instr_asm, bits<5> op> : MMR6Arch<instr_asm> {
505 let Inst{31-26} = 0x0;
506 let Inst{25-21} = 0x0;
507 let Inst{20-16} = 0x0;
508 let Inst{15-11} = op;
509 let Inst{10-6} = 0x0;
513 class POOL32A_EIDI_MMR6_ENC<string instr_asm, bits<10> funct>
514 : MMR6Arch<instr_asm> {
516 bits<5> rt; // Actually rs but we're sharing code with the standard encodings
519 let Inst{31-26} = 0x00;
520 let Inst{25-21} = 0x00;
521 let Inst{20-16} = rt;
522 let Inst{15-6} = funct;
523 let Inst{5-0} = 0x3c;
526 class SHIFT_MMR6_ENC<string instr_asm, bits<10> funct, bit rotate>
527 : MMR6Arch<instr_asm> {
535 let Inst{25-21} = rd;
536 let Inst{20-16} = rt;
537 let Inst{15-11} = shamt;
538 let Inst{10} = rotate;
539 let Inst{9-0} = funct;
542 class SW32_FM_MMR6<string instr_asm, bits<6> op> : MMR6Arch<instr_asm> {
548 let Inst{31-26} = op;
549 let Inst{25-21} = rt;
550 let Inst{20-16} = addr{20-16};
551 let Inst{15-0} = addr{15-0};
554 class POOL32F_ARITH_FM_MMR6<string instr_asm, bits<2> fmt, bits<8> funct>
555 : MMR6Arch<instr_asm>, MipsR6Inst {
562 let Inst{31-26} = 0b010101;
563 let Inst{25-21} = ft;
564 let Inst{20-16} = fs;
565 let Inst{15-11} = fd;
568 let Inst{7-0} = funct;
571 class POOL32F_ARITHF_FM_MMR6<string instr_asm, bits<2> fmt, bits<9> funct>
572 : MMR6Arch<instr_asm>, MipsR6Inst {
579 let Inst{31-26} = 0b010101;
580 let Inst{25-21} = ft;
581 let Inst{20-16} = fs;
582 let Inst{15-11} = fd;
583 let Inst{10-9} = fmt;
584 let Inst{8-0} = funct;
587 class POOL32F_MOV_NEG_FM_MMR6<string instr_asm, bits<2> fmt, bits<7> funct>
588 : MMR6Arch<instr_asm>, MipsR6Inst {
594 let Inst{31-26} = 0b010101;
595 let Inst{25-21} = ft;
596 let Inst{20-16} = fs;
598 let Inst{14-13} = fmt;
599 let Inst{12-6} = funct;
600 let Inst{5-0} = 0b111011;
603 class POOL32F_MINMAX_FM<string instr_asm, bits<2> fmt, bits<9> funct>
604 : MMR6Arch<instr_asm>, MipsR6Inst {
611 let Inst{31-26} = 0b010101;
612 let Inst{25-21} = ft;
613 let Inst{20-16} = fs;
614 let Inst{15-11} = fd;
615 let Inst{10-9} = fmt;
616 let Inst{8-0} = funct;
619 class POOL32F_CMP_FM<string instr_asm, bits<6> format, FIELD_CMP_COND Cond>
620 : MMR6Arch<instr_asm>, MipsR6Inst {
627 let Inst{31-26} = 0b010101;
628 let Inst{25-21} = ft;
629 let Inst{20-16} = fs;
630 let Inst{15-11} = fd;
631 let Inst{10-6} = Cond.Value;
632 let Inst{5-0} = format;
635 class POOL32F_CVT_LW_FM<string instr_asm, bit fmt, bits<8> funct>
636 : MMR6Arch<instr_asm>, MipsR6Inst {
641 let Inst{31-26} = 0b010101;
642 let Inst{25-21} = ft;
643 let Inst{20-16} = fs;
646 let Inst{13-6} = funct;
647 let Inst{5-0} = 0b111011;
650 class POOL32F_CVT_DS_FM<string instr_asm, bits<2> fmt, bits<7> funct>
651 : MMR6Arch<instr_asm>, MipsR6Inst {
656 let Inst{31-26} = 0b010101;
657 let Inst{25-21} = ft;
658 let Inst{20-16} = fs;
660 let Inst{14-13} = fmt;
661 let Inst{12-6} = funct;
662 let Inst{5-0} = 0b111011;
665 class POOL32F_ABS_FM_MMR6<string instr_asm, bits<2> fmt, bits<7> funct>
666 : MMR6Arch<instr_asm>, MipsR6Inst {
672 let Inst{31-26} = 0b010101;
673 let Inst{25-21} = ft;
674 let Inst{20-16} = fs;
676 let Inst{14-13} = fmt;
677 let Inst{12-6} = funct;
678 let Inst{5-0} = 0b111011;
681 class POOL32F_MATH_FM_MMR6<string instr_asm, bits<1> fmt, bits<8> funct>
682 : MMR6Arch<instr_asm>, MipsR6Inst {
688 let Inst{31-26} = 0b010101;
689 let Inst{25-21} = ft;
690 let Inst{20-16} = fs;
693 let Inst{13-6} = funct;
694 let Inst{5-0} = 0b111011;
697 class POOL16A_ADDU16_FM_MMR6 {
704 let Inst{15-10} = 0b000001;
711 class POOL16C_AND16_FM_MMR6 {
717 let Inst{15-10} = 0b010001;
720 let Inst{3-0} = 0b0001;
723 class POOL16C_NOT16_FM_MMR6 {
729 let Inst{15-10} = 0x11;
732 let Inst{3-0} = 0b0000;
735 class POOL16C_MOVEP16_FM_MMR6 {
742 let Inst{15-10} = 0b010001;
743 let Inst{9-7} = dst_regs;
747 let Inst{1-0} = rs{1-0};
750 class POOL16C_OR16_XOR16_FM_MMR6<bits<4> op> {
756 let Inst{15-10} = 0b010001;
762 class POOL16C_BREAKPOINT_FM_MMR6<bits<6> op> {
766 let Inst{15-10} = 0b010001;
767 let Inst{9-6} = code_;
771 class POOL16A_SUBU16_FM_MMR6 {
778 let Inst{15-10} = 0b000001;
785 class POOL32A_WRPGPR_WSBH_FM_MMR6<string instr_asm, bits<10> funct>
786 : MMR6Arch<instr_asm>, MipsR6Inst {
792 let Inst{31-26} = 0x00;
793 let Inst{25-21} = rt;
794 let Inst{20-16} = rs;
795 let Inst{15-6} = funct;
796 let Inst{5-0} = 0x3c;
799 class POOL32F_RECIP_ROUND_FM_MMR6<string instr_asm, bits<1> fmt, bits<8> funct>
800 : MMR6Arch<instr_asm>, MipsR6Inst {
806 let Inst{31-26} = 0b010101;
807 let Inst{25-21} = ft;
808 let Inst{20-16} = fs;
811 let Inst{13-6} = funct;
812 let Inst{5-0} = 0b111011;
815 class POOL32F_RINT_FM_MMR6<string instr_asm, bits<2> fmt> : MMR6Arch<instr_asm>,
822 let Inst{31-26} = 0b010101;
823 let Inst{25-21} = fs;
824 let Inst{20-16} = fd;
826 let Inst{10-9} = fmt;
827 let Inst{8-0} = 0b000100000;
830 class POOL32F_SEL_FM_MMR6<string instr_asm, bits<2> fmt, bits<9> funct>
831 : MMR6Arch<instr_asm>, MipsR6Inst {
838 let Inst{31-26} = 0b010101;
839 let Inst{25-21} = ft;
840 let Inst{20-16} = fs;
841 let Inst{15-11} = fd;
842 let Inst{10-9} = fmt;
843 let Inst{8-0} = funct;
846 class POOL32F_CLASS_FM_MMR6<string instr_asm, bits<2> fmt, bits<9> funct>
847 : MMR6Arch<instr_asm>, MipsR6Inst {
853 let Inst{31-26} = 0b010101;
854 let Inst{25-21} = fs;
855 let Inst{20-16} = fd;
856 let Inst{15-11} = 0b00000;
857 let Inst{10-9} = fmt;
858 let Inst{8-0} = funct;
861 class POOL32A_TLBINV_FM_MMR6<string instr_asm, bits<10> funct>
862 : MMR6Arch<instr_asm>, MipsR6Inst {
865 let Inst{31-26} = 0x0;
866 let Inst{25-16} = 0x0;
867 let Inst{15-6} = funct;
868 let Inst{5-0} = 0b111100;
871 class POOL32A_MFTC0_FM_MMR6<string instr_asm, bits<5> funct, bits<6> opcode>
872 : MMR6Arch<instr_asm>, MipsR6Inst {
879 let Inst{31-26} = 0b000000;
880 let Inst{25-21} = rt;
881 let Inst{20-16} = rs;
883 let Inst{13-11} = sel;
884 let Inst{10-6} = funct;
885 let Inst{5-0} = opcode;
888 class POOL32A_GINV_FM_MMR6<string instr_asm, bits<2> ginv>
889 : MMR6Arch<instr_asm>, MipsR6Inst {
895 let Inst{31-26} = 0x0;
896 let Inst{25-21} = 0x0;
897 let Inst{20-16} = rs;
898 let Inst{15-13} = 0b011;
899 let Inst{12-11} = ginv;
900 let Inst{10-9} = type;
901 let Inst{8-6} = 0b101;
902 let Inst{5-0} = 0b111100;
905 class POOL32F_MFTC1_FM_MMR6<string instr_asm, bits<8> funct>
906 : MMR6Arch<instr_asm> {
912 let Inst{31-26} = 0b010101;
913 let Inst{25-21} = rt;
914 let Inst{20-16} = fs;
916 let Inst{13-6} = funct;
917 let Inst{5-0} = 0b111011;
920 class POOL32A_MFTC2_FM_MMR6<string instr_asm, bits<10> funct>
921 : MMR6Arch<instr_asm>, MipsR6Inst {
927 let Inst{31-26} = 0b000000;
928 let Inst{25-21} = rt;
929 let Inst{20-16} = impl;
930 let Inst{15-6} = funct;
931 let Inst{5-0} = 0b111100;
934 class CMP_BRANCH_2R_OFF16_FM_MMR6<string opstr, bits<6> funct>
935 : MipsR6Inst, MMR6Arch<opstr> {
942 let Inst{31-26} = funct;
943 let Inst{25-21} = rt;
944 let Inst{20-16} = rs;
945 let Inst{15-0} = offset;
948 class POOL32A_DVPEVP_FM_MMR6<string instr_asm, bits<10> funct>
949 : MMR6Arch<instr_asm>, MipsR6Inst {
954 let Inst{31-26} = 0b000000;
955 let Inst{25-21} = 0b00000;
956 let Inst{20-16} = rs;
957 let Inst{15-6} = funct;
958 let Inst{5-0} = 0b111100;
961 class CMP_BRANCH_OFF21_FM_MMR6<string opstr, bits<6> funct> : MipsR6Inst {
967 let Inst{31-26} = funct;
968 let Inst{25-21} = rs;
969 let Inst{20-0} = offset;
972 class POOL32I_BRANCH_COP_1_2_FM_MMR6<string instr_asm, bits<5> funct>
973 : MMR6Arch<instr_asm> {
979 let Inst{31-26} = 0b010000;
980 let Inst{25-21} = funct;
981 let Inst{20-16} = rt;
982 let Inst{15-0} = offset;
985 class LDWC1_SDWC1_FM_MMR6<string instr_asm, bits<6> funct>
986 : MMR6Arch<instr_asm> {
989 bits<5> base = addr{20-16};
990 bits<16> offset = addr{15-0};
994 let Inst{31-26} = funct;
995 let Inst{25-21} = ft;
996 let Inst{20-16} = base;
997 let Inst{15-0} = offset;
1000 class POOL32B_LDWC2_SDWC2_FM_MMR6<string instr_asm, bits<4> funct>
1001 : MMR6Arch<instr_asm>, MipsR6Inst {
1004 bits<5> base = addr{20-16};
1005 bits<11> offset = addr{10-0};
1009 let Inst{31-26} = 0b001000;
1010 let Inst{25-21} = rt;
1011 let Inst{20-16} = base;
1012 let Inst{15-12} = funct;
1014 let Inst{10-0} = offset;
1017 class POOL32C_LL_E_SC_E_FM_MMR6<string instr_asm, bits<4> majorFunc,
1018 bits<3> minorFunc> : MMR6Arch<instr_asm>,
1022 bits<5> base = addr{20-16};
1023 bits<9> offset = addr{8-0};
1027 let Inst{31-26} = 0b011000;
1028 let Inst{25-21} = rt;
1029 let Inst{20-16} = base;
1030 let Inst{15-12} = majorFunc;
1031 let Inst{11-9} = minorFunc;
1032 let Inst{8-0} = offset;