- case 0x20: /* mfusr */
- case 0x21: /* mtusr */
- func (stream, "%s\t%s, $%s", mnemonic_alu20[op],
- gpr_map[rt], usr_map[__GF (insn, 10, 5)][__GF (insn, 15, 5)]);
- return;
- case 0x28: /* mults64 */
- case 0x29: /* mult64 */
- case 0x2a: /* madds64 */
- case 0x2b: /* madd64 */
- case 0x2c: /* msubs64 */
- case 0x2d: /* msub64 */
- case 0x2e: /* divs */
- case 0x2f: /* div */
- case 0x31: /* mult32 */
- case 0x33: /* madd32 */
- case 0x35: /* msub32 */
- func (stream, "%s\t$d%d, %s, %s", mnemonic_alu20[op],
- rt >> 1, gpr_map[ra], gpr_map[rb]);
- return;
-
- case 0x4f: /* flmism */
- case 0x68: /* mulsr64 */
- case 0x69: /* mulr64 */
- case 0x73: /* maddr32 */
- case 0x75: /* msubr32 */
- op = insn & 0x3f;
- func (stream, "%s\t%s, %s, %s", mnemonic_alu21[op],
- gpr_map[rt], gpr_map[ra], gpr_map[rb]);
- return;
+static uint32_t
+nds32_mask_opcode (uint32_t insn)
+{
+ uint32_t opcode = N32_OP6 (insn);
+ switch (opcode)
+ {
+ case N32_OP6_LBI:
+ case N32_OP6_LHI:
+ case N32_OP6_LWI:
+ case N32_OP6_LDI:
+ case N32_OP6_LBI_BI:
+ case N32_OP6_LHI_BI:
+ case N32_OP6_LWI_BI:
+ case N32_OP6_LDI_BI:
+ case N32_OP6_SBI:
+ case N32_OP6_SHI:
+ case N32_OP6_SWI:
+ case N32_OP6_SDI:
+ case N32_OP6_SBI_BI:
+ case N32_OP6_SHI_BI:
+ case N32_OP6_SWI_BI:
+ case N32_OP6_SDI_BI:
+ case N32_OP6_LBSI:
+ case N32_OP6_LHSI:
+ case N32_OP6_LWSI:
+ case N32_OP6_LBSI_BI:
+ case N32_OP6_LHSI_BI:
+ case N32_OP6_LWSI_BI:
+ case N32_OP6_MOVI:
+ case N32_OP6_SETHI:
+ case N32_OP6_ADDI:
+ case N32_OP6_SUBRI:
+ case N32_OP6_ANDI:
+ case N32_OP6_XORI:
+ case N32_OP6_ORI:
+ case N32_OP6_SLTI:
+ case N32_OP6_SLTSI:
+ case N32_OP6_CEXT:
+ case N32_OP6_BITCI:
+ return MASK_OP (insn, 0);
+ case N32_OP6_ALU2:
+ /* FFBI */
+ if (__GF (insn, 0, 7) == (N32_ALU2_FFBI | N32_BIT (6)))
+ return MASK_OP (insn, 0x7f);
+ else if (__GF (insn, 0, 7) == (N32_ALU2_MFUSR | N32_BIT (6))
+ || __GF (insn, 0, 7) == (N32_ALU2_MTUSR | N32_BIT (6)))
+ /* RDOV CLROV */
+ return MASK_OP (insn, 0xf81ff);
+ else if (__GF (insn, 0, 10) == (N32_ALU2_ONEOP | N32_BIT (7)))
+ {
+ /* INSB */
+ if (__GF (insn, 12, 3) == 4)
+ return MASK_OP (insn, 0x73ff);
+ return MASK_OP (insn, 0x7fff);
+ }
+ return MASK_OP (insn, 0x3ff);
+ case N32_OP6_ALU1:
+ case N32_OP6_SIMD:
+ return MASK_OP (insn, 0x1f);
+ case N32_OP6_MEM:
+ return MASK_OP (insn, 0xff);
+ case N32_OP6_JREG:
+ return MASK_OP (insn, 0x7f);
+ case N32_OP6_LSMW:
+ return MASK_OP (insn, 0x23);
+ case N32_OP6_SBGP:
+ case N32_OP6_LBGP:
+ return MASK_OP (insn, 0x1 << 19);
+ case N32_OP6_HWGP:
+ if (__GF (insn, 18, 2) == 0x3)
+ return MASK_OP (insn, 0x7 << 17);
+ return MASK_OP (insn, 0x3 << 18);
+ case N32_OP6_DPREFI:
+ return MASK_OP (insn, 0x1 << 24);
+ case N32_OP6_LWC:
+ case N32_OP6_SWC:
+ case N32_OP6_LDC:
+ case N32_OP6_SDC:
+ return MASK_OP (insn, 0x1 << 12);
+ case N32_OP6_JI:
+ return MASK_OP (insn, 0x1 << 24);
+ case N32_OP6_BR1:
+ return MASK_OP (insn, 0x1 << 14);
+ case N32_OP6_BR2:
+ if (__GF (insn, 16, 4) == 0)
+ return MASK_OP (insn, 0x1ff << 16);
+ else
+ return MASK_OP (insn, 0xf << 16);
+ case N32_OP6_BR3:
+ return MASK_OP (insn, 0x1 << 19);
+ case N32_OP6_MISC:
+ switch (__GF (insn, 0, 5))
+ {
+ case N32_MISC_MTSR:
+ /* SETGIE and SETEND */
+ if (__GF (insn, 5, 5) == 0x1 || __GF (insn, 5, 5) == 0x2)
+ return MASK_OP (insn, 0x1fffff);
+ return MASK_OP (insn, 0x1f);
+ case N32_MISC_TLBOP:
+ if (__GF (insn, 5, 5) == 5 || __GF (insn, 5, 5) == 7)
+ /* PB FLUA */
+ return MASK_OP (insn, 0x3ff);
+ return MASK_OP (insn, 0x1f);
+ default:
+ return MASK_OP (insn, 0x1f);
+ }
+ case N32_OP6_COP:
+ if (__GF (insn, 4, 2) == 0)
+ {
+ /* FPU */
+ switch (__GF (insn, 0, 4))
+ {
+ case 0x0:
+ case 0x8:
+ /* FS1/F2OP FD1/F2OP */
+ if (__GF (insn, 6, 4) == 0xf)
+ return MASK_OP (insn, 0x7fff);
+ /* FS1 FD1 */
+ return MASK_OP (insn, 0x3ff);
+ case 0x4:
+ case 0xc:
+ /* FS2 */
+ return MASK_OP (insn, 0x3ff);
+ case 0x1:
+ case 0x9:
+ /* XR */
+ if (__GF (insn, 6, 4) == 0xc)
+ return MASK_OP (insn, 0x7fff);
+ /* MFCP MTCP */
+ return MASK_OP (insn, 0x3ff);
+ default:
+ return MASK_OP (insn, 0xff);
+ }
+ }
+ else if (__GF (insn, 0, 2) == 0)
+ return MASK_OP (insn, 0xf);
+ return MASK_OP (insn, 0xcf);
+ case N32_OP6_AEXT:
+ /* AUDIO */
+ switch (__GF (insn, 23, 2))
+ {
+ case 0x0:
+ if (__GF (insn, 5, 4) == 0)
+ /* AMxxx AMAyyS AMyyS AMAWzS AMWzS */
+ return MASK_OP (insn, (0x1f << 20) | 0x1ff);
+ else if (__GF (insn, 5, 4) == 1)
+ /* ALR ASR ALA ASA AUPI */
+ return MASK_OP (insn, (0x1f << 20) | (0xf << 5));
+ else if (__GF (insn, 20, 3) == 0 && __GF (insn, 6, 3) == 1)
+ /* ALR2 */
+ return MASK_OP (insn, (0x1f << 20) | (0x7 << 6));
+ else if (__GF (insn, 20 ,3) == 2 && __GF (insn, 6, 3) == 1)
+ /* AWEXT ASATS48 */
+ return MASK_OP (insn, (0x1f << 20) | (0xf << 5));
+ else if (__GF (insn, 20 ,3) == 3 && __GF (insn, 6, 3) == 1)
+ /* AMTAR AMTAR2 AMFAR AMFAR2 */
+ return MASK_OP (insn, (0x1f << 20) | (0x1f << 5));
+ else if (__GF (insn, 7, 2) == 3)
+ /* AMxxxSA */
+ return MASK_OP (insn, (0x1f << 20) | (0x3 << 7));
+ else if (__GF (insn, 6, 3) == 2)
+ /* AMxxxL.S */
+ return MASK_OP (insn, (0x1f << 20) | (0xf << 5));
+ else
+ /* AmxxxL.l AmxxxL2.S AMxxxL2.L */
+ return MASK_OP (insn, (0x1f << 20) | (0x7 << 6));
+ case 0x1:
+ if (__GF (insn, 20, 3) == 0)
+ /* AADDL ASUBL */
+ return MASK_OP (insn, (0x1f << 20) | (0x1 << 5));
+ else if (__GF (insn, 20, 3) == 1)
+ /* AMTARI Ix AMTARI Mx */
+ return MASK_OP (insn, (0x1f << 20));
+ else if (__GF (insn, 6, 3) == 2)
+ /* AMAWzSl.S AMWzSl.S */
+ return MASK_OP (insn, (0x1f << 20) | (0xf << 5));
+ else if (__GF (insn, 7, 2) == 3)
+ /* AMAWzSSA AMWzSSA */
+ return MASK_OP (insn, (0x1f << 20) | (0x3 << 7));
+ else
+ /* AMAWzSL.L AMAWzSL2.S AMAWzSL2.L
+ AMWzSL.L AMWzSL.L AMWzSL2.S */
+ return MASK_OP (insn, (0x1f << 20) | (0x7 << 6));
+ case 0x2:
+ if (__GF (insn, 6, 3) == 2)
+ /* AMAyySl.S AMWyySl.S */
+ return MASK_OP (insn, (0x1f << 20) | (0xf << 5));
+ else if (__GF (insn, 7, 2) == 3)
+ /* AMAWyySSA AMWyySSA */
+ return MASK_OP (insn, (0x1f << 20) | (0x3 << 7));
+ else
+ /* AMAWyySL.L AMAWyySL2.S AMAWyySL2.L
+ AMWyySL.L AMWyySL.L AMWyySL2.S */
+ return MASK_OP (insn, (0x1f << 20) | (0x7 << 6));
+ }
+ return MASK_OP (insn, 0x1f << 20);