[PATCH] RISC-V: Add SpacemiT vendor extensions xsmtvdot
Jan Beulich
jbeulich@suse.com
Thu Apr 9 12:21:41 GMT 2026
On 09.04.2026 13:37, Mark Zhuang wrote:
> --- a/gas/NEWS
> +++ b/gas/NEWS
> @@ -17,6 +17,9 @@ Changes in 2.46:
> * Add support for RISC-V standard extensions:
> sdtrig v1.0, ssstrict v1.0.
>
> +* Add support for RISC-V vendor extensions:
> + SpacemiT: xsmtvdot v1.0.
> +
> * The assembler now supports generating SFrame Version 3 format. This version
> supports .text > 2 GiB, support for marking outermost frames, support for
> marking signal trampolines, and support for "flexible" frames which have
This clearly is in need of adjustment. 2.46 has already gone out.
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -1771,6 +1771,29 @@ validate_riscv_insn (const struct riscv_opcode *opc, int length)
> goto unknown_validate_operand;
> }
> break;
> + case 'p': /* Vendor-specific (SpacemiT) operands. */
> + switch (*++oparg)
> + {
> + case 'V':
> + switch (*++oparg)
> + {
> + case 'd': USE_BITS (OP_MASK_SPACEMIT_IME_VD, OP_SH_SPACEMIT_IME_VD); break;
> + case 's': USE_BITS (OP_MASK_SPACEMIT_IME_VS1, OP_SH_SPACEMIT_IME_VS1); break;
> + default:
> + goto unknown_validate_operand;
> + }
> + break;
> + case 'w': /* Xpw&S ... bits in S indicates whether corresponding item is permitted. */
> + if (*++oparg != '&')
> + goto unknown_validate_operand;
> + strtol (oparg + 1, (char **)&oparg, 16);
> + oparg--;
> + USE_BITS (OP_MASK_SPACEMIT_IME_WI, OP_SH_SPACEMIT_IME_WI);
> + break;
> + default:
> + goto unknown_validate_operand;
> + }
> + break;
> default:
> goto unknown_validate_operand;
> }
There look to be issues with indentation and line length throughout here. And
more further down, including in disassembler code.
> --- a/opcodes/riscv-opc.c
> +++ b/opcodes/riscv-opc.c
> @@ -122,6 +122,12 @@ const char * const riscv_th_vediv[4] =
> "d1", "d2", "d4", "d8"
> };
>
> +/* XSmtVdot, List of int type width constants. */
> +const char * const riscv_smt_wi[4] =
> +{
> + "i2", "i16", "i4", "i8"
> +};
Do you really need to use arg_lookup() for these, and hence do you really need
this table (requiring more space for the pointers than for the actual strings
pointed to)?
> @@ -3579,6 +3585,45 @@ const struct riscv_opcode riscv_opcodes[] =
> {"mips.sdp", 0, INSN_CLASS_XMIPSLSP, "t,r,Xm^(s)", MATCH_MIPS_SDP, MASK_MIPS_SDP, match_opcode, 0 },
> {"mips.swp", 0, INSN_CLASS_XMIPSLSP, "t,r,Xm&(s)", MATCH_MIPS_SWP, MASK_MIPS_SWP, match_opcode, 0 },
>
> +/* SpacemiT custom instructions. */
> +/* Int Matrix Multi-Accumulation */
> +{"smt.vmadot", 0, INSN_CLASS_XSMTVDOT, "XpVd,Vs,Vt", MATCH_SMT_VMADOT_I8, MASK_SMT_VMADOT_I8, match_opcode, INSN_ALIAS },
> +{"smt.vmadot", 0, INSN_CLASS_XSMTVDOT, "XpVd,Vs,Vt,Xpw&8", MATCH_SMT_VMADOT, MASK_SMT_VMADOT, match_opcode, 0 },
Rather than having two entries each, can't you handle to Xpw&8 operand as an
optional one, like is done for Vm (and I'm soon to submit a patch to do the
same for floating point rounding mode operands)? We shouldn't grow this ever
growing table more than necessary, imo.
Jan
More information about the Binutils
mailing list