[PATCH v4 1/1] RISC-V: Add SpacemiT vendor extensions xsmtvdot

Jan Beulich jbeulich@suse.com
Thu Apr 16 06:34:52 GMT 2026


On 10.04.2026 17:11, Mark Zhuang wrote:
> @@ -4286,6 +4315,85 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
>  		    }
>  		  break;
>  
> +		case 'p': /* Vendor-specific (SpacemiT) operands.  */
> +		  switch (*++oparg)
> +		    {
> +		    case 'V':
> +		      switch (*++oparg)
> +			{
> +			case 'd':
> +			  if (!reg_lookup (&asarg, RCLASS_VECR, &regno))
> +			    break;
> +			  if ((regno & 0x1) != 0)
> +			    {
> +			      error.msg = _("illegal operands (vd must be even)");
> +			      break;
> +			    }
> +			  INSERT_OPERAND (SPACEMIT_IME_VD, *ip, regno>>1);
> +			  continue;
> +			case 's':
> +			  if (!reg_lookup (&asarg, RCLASS_VECR, &regno))
> +			    break;
> +			  if ((regno & 0x1) != 0)
> +			    {
> +			      error.msg = _("illegal operands (vs1 must be even)");
> +			      break;
> +			    }
> +			  INSERT_OPERAND (SPACEMIT_IME_VS1, *ip, regno>>1);
> +			  continue;
> +			default:
> +			  goto unknown_riscv_ip_operand;
> +			}
> +		      break;
> +		    case 'w':
> +		      /* Xpw&S ... bits in S indicates whether
> +			 corresponding item is permitted.  */
> +		      if (*++oparg != '&')
> +			goto unknown_riscv_ip_operand;
> +		      size_t n = strtol (oparg + 1, (char **)&oparg, 16);
> +		      oparg--;
> +		      /* Optional operand: if not present, default to i8.  */
> +		      if (*asarg == '\0')
> +			regno = 3;
> +		      else if (*asarg == ',')
> +			{
> +			  asarg++;
> +			  if (strncmp (asarg, "i2", 2) == 0)
> +			    {
> +			      regno = 0;
> +			      asarg += 2;
> +			    }
> +			  else if (strncmp (asarg, "i16", 3) == 0)
> +			    {
> +			      regno = 1;
> +			      asarg += 3;
> +			    }
> +			  else if (strncmp (asarg, "i4", 2) == 0)
> +			    {
> +			      regno = 2;
> +			      asarg += 2;
> +			    }
> +			  else if (strncmp (asarg, "i8", 2) == 0)
> +			    {
> +			      regno = 3;
> +			      asarg += 2;
> +			    }
> +			  else
> +			    break;
> +			}
> +		      else
> +			goto unknown_riscv_ip_operand;
> +		      if ((n & (1 << regno)) == 0)

I will admit that I didn't try to find this aspectr in the spec, but the
above looks pretty implausible. The mapping from "i<N>" to regno isn't
a regular transformation. What does <N> stand for? Why would the regno-
th bit need to be clear? IOW why would "i2" require "&4" in the opcode
pattern, or "i16" require "&2", when "i8" requires "&8"? How do the two
numbers fit together?

Jan


More information about the Binutils mailing list