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> : MMR6Arch<instr_asm> {
243 let Inst{15-11} = op;
248 class POOL32A_RDPGPR_FM_MMR6<bits<10> funct> {
254 let Inst{25-21} = rt;
255 let Inst{20-16} = rd;
256 let Inst{15-6} = funct;
257 let Inst{5-0} = 0b111100;
260 class POOL32A_RDHWR_FM_MMR6 {
267 let Inst{25-21} = rt;
268 let Inst{20-16} = rs;
270 let Inst{13-11} = sel;
272 let Inst{9-0} = 0b0111000000;
275 class POOL32A_SYNC_FM_MMR6 {
282 let Inst{20-16} = stype;
283 let Inst{15-6} = 0b0110101101;
284 let Inst{5-0} = 0b111100;
287 class POOL32I_SYNCI_FM_MMR6 {
289 bits<5> base = addr{20-16};
290 bits<16> immediate = addr{15-0};
294 let Inst{31-26} = 0b010000;
295 let Inst{25-21} = 0b01100;
296 let Inst{20-16} = base;
297 let Inst{15-0} = immediate;
300 class POOL32A_2R_FM_MMR6<bits<10> funct> : MipsR6Inst {
306 let Inst{31-26} = 0b000000;
307 let Inst{25-21} = rt;
308 let Inst{20-16} = rs;
309 let Inst{15-6} = funct;
310 let Inst{5-0} = 0b111100;
313 class SPECIAL_2R_FM_MMR6<bits<6> funct> : MipsR6Inst {
319 let Inst{31-26} = 0b000000;
320 let Inst{25-21} = rs;
321 let Inst{20-16} = 0b00000;
322 let Inst{15-11} = rt;
323 let Inst{10-6} = 0b00001;
324 let Inst{5-0} = funct;
327 class POOL32A_ALIGN_FM_MMR6<bits<6> funct> : MipsR6Inst {
335 let Inst{31-26} = 0b000000;
336 let Inst{25-21} = rs;
337 let Inst{20-16} = rt;
338 let Inst{15-11} = rd;
340 let Inst{8-6} = 0b000;
341 let Inst{5-0} = funct;
344 class AUI_FM_MMR6 : MipsR6Inst {
351 let Inst{31-26} = 0b000100;
352 let Inst{25-21} = rt;
353 let Inst{20-16} = rs;
354 let Inst{15-0} = imm;
357 class POOL32A_LSA_FM<bits<6> funct> : MipsR6Inst {
365 let Inst{31-26} = 0b000000;
366 let Inst{25-21} = rt;
367 let Inst{20-16} = rs;
368 let Inst{15-11} = rd;
369 let Inst{10-9} = imm2;
370 let Inst{8-6} = 0b000;
371 let Inst{5-0} = funct;
374 class SB32_SH32_STORE_FM_MMR6<bits<6> op> {
377 bits<5> base = addr{20-16};
378 bits<16> offset = addr{15-0};
382 let Inst{31-26} = op;
383 let Inst{25-21} = rt;
384 let Inst{20-16} = base;
385 let Inst{15-0} = offset;
388 class LOAD_WORD_FM_MMR6 {
391 bits<5> base = addr{20-16};
392 bits<16> offset = addr{15-0};
396 let Inst{31-26} = 0b111111;
397 let Inst{25-21} = rt;
398 let Inst{20-16} = base;
399 let Inst{15-0} = offset;
402 class LOAD_UPPER_IMM_FM_MMR6 {
408 let Inst{31-26} = 0b000100;
409 let Inst{25-21} = rt;
411 let Inst{15-0} = imm16;
414 class CMP_BRANCH_1R_RT_OFF16_FM_MMR6<string instr_asm, bits<6> funct>
415 : MMR6Arch<instr_asm>, MipsR6Inst {
421 let Inst{31-26} = funct;
422 let Inst{25-21} = rt;
423 let Inst{20-16} = 0b00000;
424 let Inst{15-0} = offset;
427 class CMP_BRANCH_1R_BOTH_OFF16_FM_MMR6<string instr_asm, bits<6> funct>
428 : MMR6Arch<instr_asm>, MipsR6Inst {
434 let Inst{31-26} = funct;
435 let Inst{25-21} = rt;
436 let Inst{20-16} = rt;
437 let Inst{15-0} = offset;
440 class POOL32A_JALRC_FM_MMR6<string instr_asm, bits<10> funct>
441 : MipsR6Inst, MMR6Arch<instr_asm> {
448 let Inst{25-21} = rt;
449 let Inst{20-16} = rs;
450 let Inst{15-6} = funct;
451 let Inst{5-0} = 0b111100;
454 class POOL32A_EXT_INS_FM_MMR6<string instr_asm, bits<6> funct>
455 : MMR6Arch<instr_asm>, MipsR6Inst {
464 let Inst{25-21} = rt;
465 let Inst{20-16} = rs;
466 let Inst{15-11} = size;
467 let Inst{10-6} = pos;
468 let Inst{5-0} = funct;
471 class POOL32A_ERET_FM_MMR6<string instr_asm, bits<10> funct>
472 : MMR6Arch<instr_asm> {
475 let Inst{31-26} = 0x00;
476 let Inst{25-16} = 0x00;
477 let Inst{15-6} = funct;
478 let Inst{5-0} = 0x3c;
481 class ERETNC_FM_MMR6<string instr_asm> : MMR6Arch<instr_asm> {
484 let Inst{31-26} = 0x00;
485 let Inst{25-17} = 0x00;
486 let Inst{16-16} = 0x01;
487 let Inst{15-6} = 0x3cd;
488 let Inst{5-0} = 0x3c;
491 class BREAK_MMR6_ENC<string instr_asm> : MMR6Arch<instr_asm> {
495 let Inst{31-26} = 0x0;
496 let Inst{25-16} = code_1;
497 let Inst{15-6} = code_2;
498 let Inst{5-0} = 0x07;
501 class BARRIER_MMR6_ENC<string instr_asm, bits<5> op> : MMR6Arch<instr_asm> {
504 let Inst{31-26} = 0x0;
505 let Inst{25-21} = 0x0;
506 let Inst{20-16} = 0x0;
507 let Inst{15-11} = op;
508 let Inst{10-6} = 0x0;
512 class POOL32A_EIDI_MMR6_ENC<string instr_asm, bits<10> funct>
513 : MMR6Arch<instr_asm> {
515 bits<5> rt; // Actually rs but we're sharing code with the standard encodings which call it rt
517 let Inst{31-26} = 0x00;
518 let Inst{25-21} = 0x00;
519 let Inst{20-16} = rt;
520 let Inst{15-6} = funct;
521 let Inst{5-0} = 0x3c;
524 class SHIFT_MMR6_ENC<string instr_asm, bits<10> funct, bit rotate> : MMR6Arch<instr_asm> {
532 let Inst{25-21} = rd;
533 let Inst{20-16} = rt;
534 let Inst{15-11} = shamt;
535 let Inst{10} = rotate;
536 let Inst{9-0} = funct;
539 class SW32_FM_MMR6<string instr_asm, bits<6> op> : MMR6Arch<instr_asm> {
545 let Inst{31-26} = op;
546 let Inst{25-21} = rt;
547 let Inst{20-16} = addr{20-16};
548 let Inst{15-0} = addr{15-0};
551 class POOL32F_ARITH_FM_MMR6<string instr_asm, bits<2> fmt, bits<8> funct>
552 : MMR6Arch<instr_asm>, MipsR6Inst {
559 let Inst{31-26} = 0b010101;
560 let Inst{25-21} = ft;
561 let Inst{20-16} = fs;
562 let Inst{15-11} = fd;
565 let Inst{7-0} = funct;
568 class POOL32F_ARITHF_FM_MMR6<string instr_asm, bits<2> fmt, bits<9> funct>
569 : MMR6Arch<instr_asm>, MipsR6Inst {
576 let Inst{31-26} = 0b010101;
577 let Inst{25-21} = ft;
578 let Inst{20-16} = fs;
579 let Inst{15-11} = fd;
580 let Inst{10-9} = fmt;
581 let Inst{8-0} = funct;
584 class POOL32F_MOV_NEG_FM_MMR6<string instr_asm, bits<2> fmt, bits<7> funct>
585 : MMR6Arch<instr_asm>, MipsR6Inst {
591 let Inst{31-26} = 0b010101;
592 let Inst{25-21} = ft;
593 let Inst{20-16} = fs;
595 let Inst{14-13} = fmt;
596 let Inst{12-6} = funct;
597 let Inst{5-0} = 0b111011;
600 class POOL32F_MINMAX_FM<string instr_asm, bits<2> fmt, bits<9> funct>
601 : MMR6Arch<instr_asm>, MipsR6Inst {
608 let Inst{31-26} = 0b010101;
609 let Inst{25-21} = ft;
610 let Inst{20-16} = fs;
611 let Inst{15-11} = fd;
612 let Inst{10-9} = fmt;
613 let Inst{8-0} = funct;
616 class POOL32F_CMP_FM<string instr_asm, bits<6> format, FIELD_CMP_COND Cond>
617 : MMR6Arch<instr_asm>, MipsR6Inst {
624 let Inst{31-26} = 0b010101;
625 let Inst{25-21} = ft;
626 let Inst{20-16} = fs;
627 let Inst{15-11} = fd;
628 let Inst{10-6} = Cond.Value;
629 let Inst{5-0} = format;
632 class POOL32F_CVT_LW_FM<string instr_asm, bit fmt, bits<8> funct>
633 : MMR6Arch<instr_asm>, MipsR6Inst {
638 let Inst{31-26} = 0b010101;
639 let Inst{25-21} = ft;
640 let Inst{20-16} = fs;
643 let Inst{13-6} = funct;
644 let Inst{5-0} = 0b111011;
647 class POOL32F_CVT_DS_FM<string instr_asm, bits<2> fmt, bits<7> funct>
648 : MMR6Arch<instr_asm>, MipsR6Inst {
653 let Inst{31-26} = 0b010101;
654 let Inst{25-21} = ft;
655 let Inst{20-16} = fs;
657 let Inst{14-13} = fmt;
658 let Inst{12-6} = funct;
659 let Inst{5-0} = 0b111011;
662 class POOL32F_ABS_FM_MMR6<string instr_asm, bits<2> fmt, bits<7> funct>
663 : MMR6Arch<instr_asm>, MipsR6Inst {
669 let Inst{31-26} = 0b010101;
670 let Inst{25-21} = ft;
671 let Inst{20-16} = fs;
673 let Inst{14-13} = fmt;
674 let Inst{12-6} = funct;
675 let Inst{5-0} = 0b111011;
678 class POOL32F_MATH_FM_MMR6<string instr_asm, bits<1> fmt, bits<8> funct>
679 : MMR6Arch<instr_asm>, MipsR6Inst {
685 let Inst{31-26} = 0b010101;
686 let Inst{25-21} = ft;
687 let Inst{20-16} = fs;
690 let Inst{13-6} = funct;
691 let Inst{5-0} = 0b111011;
694 class POOL16A_ADDU16_FM_MMR6 {
701 let Inst{15-10} = 0b000001;
708 class POOL16C_AND16_FM_MMR6 {
714 let Inst{15-10} = 0b010001;
717 let Inst{3-0} = 0b0001;
720 class POOL16C_NOT16_FM_MMR6 {
726 let Inst{15-10} = 0x11;
729 let Inst{3-0} = 0b0000;
732 class POOL16C_MOVEP16_FM_MMR6 {
739 let Inst{15-10} = 0b010001;
740 let Inst{9-7} = dst_regs;
744 let Inst{1-0} = rs{1-0};
747 class POOL16C_OR16_XOR16_FM_MMR6<bits<4> op> {
753 let Inst{15-10} = 0b010001;
759 class POOL16C_BREAKPOINT_FM_MMR6<bits<6> op> {
763 let Inst{15-10} = 0b010001;
764 let Inst{9-6} = code_;
768 class POOL16A_SUBU16_FM_MMR6 {
775 let Inst{15-10} = 0b000001;
782 class POOL32A_WRPGPR_WSBH_FM_MMR6<string instr_asm, bits<10> funct>
783 : MMR6Arch<instr_asm>, MipsR6Inst {
789 let Inst{31-26} = 0x00;
790 let Inst{25-21} = rt;
791 let Inst{20-16} = rs;
792 let Inst{15-6} = funct;
793 let Inst{5-0} = 0x3c;
796 class POOL32F_RECIP_ROUND_FM_MMR6<string instr_asm, bits<1> fmt, bits<8> funct>
797 : MMR6Arch<instr_asm>, MipsR6Inst {
803 let Inst{31-26} = 0b010101;
804 let Inst{25-21} = ft;
805 let Inst{20-16} = fs;
808 let Inst{13-6} = funct;
809 let Inst{5-0} = 0b111011;
812 class POOL32F_RINT_FM_MMR6<string instr_asm, bits<2> fmt>
813 : MMR6Arch<instr_asm>, MipsR6Inst {
819 let Inst{31-26} = 0b010101;
820 let Inst{25-21} = fs;
821 let Inst{20-16} = fd;
823 let Inst{10-9} = fmt;
824 let Inst{8-0} = 0b000100000;
827 class POOL32F_SEL_FM_MMR6<string instr_asm, bits<2> fmt, bits<9> funct>
828 : MMR6Arch<instr_asm>, MipsR6Inst {
835 let Inst{31-26} = 0b010101;
836 let Inst{25-21} = ft;
837 let Inst{20-16} = fs;
838 let Inst{15-11} = fd;
839 let Inst{10-9} = fmt;
840 let Inst{8-0} = funct;
843 class POOL32F_CLASS_FM_MMR6<string instr_asm, bits<2> fmt, bits<9> funct>
844 : MMR6Arch<instr_asm>, MipsR6Inst {
850 let Inst{31-26} = 0b010101;
851 let Inst{25-21} = fs;
852 let Inst{20-16} = fd;
853 let Inst{15-11} = 0b00000;
854 let Inst{10-9} = fmt;
855 let Inst{8-0} = funct;
858 class POOL32A_TLBINV_FM_MMR6<string instr_asm, bits<10> funct>
859 : MMR6Arch<instr_asm>, MipsR6Inst {
862 let Inst{31-26} = 0x0;
863 let Inst{25-16} = 0x0;
864 let Inst{15-6} = funct;
865 let Inst{5-0} = 0b111100;
868 class POOL32A_MFTC0_FM_MMR6<string instr_asm, bits<5> funct, bits<6> opcode>
869 : MMR6Arch<instr_asm>, MipsR6Inst {
876 let Inst{31-26} = 0b000000;
877 let Inst{25-21} = rt;
878 let Inst{20-16} = rs;
880 let Inst{13-11} = sel;
881 let Inst{10-6} = funct;
882 let Inst{5-0} = opcode;
885 class POOL32A_GINV_FM_MMR6<string instr_asm, bits<2> ginv>
886 : MMR6Arch<instr_asm>, MipsR6Inst {
892 let Inst{31-26} = 0x0;
893 let Inst{25-21} = 0x0;
894 let Inst{20-16} = rs;
895 let Inst{15-13} = 0b011;
896 let Inst{12-11} = ginv;
897 let Inst{10-9} = type;
898 let Inst{8-6} = 0b101;
899 let Inst{5-0} = 0b111100;
902 class POOL32F_MFTC1_FM_MMR6<string instr_asm, bits<8> funct>
903 : MMR6Arch<instr_asm> {
909 let Inst{31-26} = 0b010101;
910 let Inst{25-21} = rt;
911 let Inst{20-16} = fs;
913 let Inst{13-6} = funct;
914 let Inst{5-0} = 0b111011;
917 class POOL32A_MFTC2_FM_MMR6<string instr_asm, bits<10> funct>
918 : MMR6Arch<instr_asm>, MipsR6Inst {
924 let Inst{31-26} = 0b000000;
925 let Inst{25-21} = rt;
926 let Inst{20-16} = impl;
927 let Inst{15-6} = funct;
928 let Inst{5-0} = 0b111100;
931 class CMP_BRANCH_2R_OFF16_FM_MMR6<string opstr, bits<6> funct>
932 : MipsR6Inst, MMR6Arch<opstr> {
939 let Inst{31-26} = funct;
940 let Inst{25-21} = rt;
941 let Inst{20-16} = rs;
942 let Inst{15-0} = offset;
945 class POOL32A_DVPEVP_FM_MMR6<string instr_asm, bits<10> funct>
946 : MMR6Arch<instr_asm>, MipsR6Inst {
951 let Inst{31-26} = 0b000000;
952 let Inst{25-21} = 0b00000;
953 let Inst{20-16} = rs;
954 let Inst{15-6} = funct;
955 let Inst{5-0} = 0b111100;
958 class CMP_BRANCH_OFF21_FM_MMR6<string opstr, bits<6> funct> : MipsR6Inst {
964 let Inst{31-26} = funct;
965 let Inst{25-21} = rs;
966 let Inst{20-0} = offset;
969 class POOL32I_BRANCH_COP_1_2_FM_MMR6<string instr_asm, bits<5> funct>
970 : MMR6Arch<instr_asm> {
976 let Inst{31-26} = 0b010000;
977 let Inst{25-21} = funct;
978 let Inst{20-16} = rt;
979 let Inst{15-0} = offset;
982 class LDWC1_SDWC1_FM_MMR6<string instr_asm, bits<6> funct>
983 : MMR6Arch<instr_asm> {
986 bits<5> base = addr{20-16};
987 bits<16> offset = addr{15-0};
991 let Inst{31-26} = funct;
992 let Inst{25-21} = ft;
993 let Inst{20-16} = base;
994 let Inst{15-0} = offset;
997 class POOL32B_LDWC2_SDWC2_FM_MMR6<string instr_asm, bits<4> funct>
998 : MMR6Arch<instr_asm>, MipsR6Inst {
1001 bits<5> base = addr{20-16};
1002 bits<11> offset = addr{10-0};
1006 let Inst{31-26} = 0b001000;
1007 let Inst{25-21} = rt;
1008 let Inst{20-16} = base;
1009 let Inst{15-12} = funct;
1011 let Inst{10-0} = offset;
1014 class POOL32C_LL_E_SC_E_FM_MMR6<string instr_asm, bits<4> majorFunc,
1016 : MMR6Arch<instr_asm>, MipsR6Inst {
1019 bits<5> base = addr{20-16};
1020 bits<9> offset = addr{8-0};
1024 let Inst{31-26} = 0b011000;
1025 let Inst{25-21} = rt;
1026 let Inst{20-16} = base;
1027 let Inst{15-12} = majorFunc;
1028 let Inst{11-9} = minorFunc;
1029 let Inst{8-0} = offset;