[PATCH] RISC-V: Fix build with GCC-8
Jan Beulich
jbeulich@suse.com
Tue Jun 23 10:54:25 GMT 2026
On 23.06.2026 11:52, Mark Zhuang wrote:
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -1791,49 +1791,53 @@ validate_riscv_insn (const struct riscv_opcode *opc, int length)
> }
> break;
> case 'p': /* Vendor-specific (SpacemiT) operands. */
> - size_t n;
> - size_t s;
> - switch (*++oparg)
> - {
> - case 'V':
> - switch (*++oparg)
> - {
> - case 'd':
> - USE_BITS (OP_MASK_SPACEMIT_IME_VD, OP_SH_SPACEMIT_IME_VD);
> + {
> + size_t n;
> + size_t s;
> + 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;
> + case 'm':
> + USE_BITS (OP_MASK_SPACEMIT_IME_VMASK,
> + OP_SH_SPACEMIT_IME_VMASK);
> + break;
> + default:
> + goto unknown_validate_operand;
> + }
> break;
> - case 's':
> - USE_BITS (OP_MASK_SPACEMIT_IME_VS1,
> - OP_SH_SPACEMIT_IME_VS1);
> + case 'u': /* Integer immediate, 'XpuN@S' ...
> + N-bit unsigned immediate at bit S. */
> + n = strtol (oparg + 1, (char **)&oparg, 10);
> + if (*oparg != '@')
> + goto unknown_validate_operand;
> + s = strtol (oparg + 1, (char **)&oparg, 10);
> + oparg--;
> + USE_IMM (n, s);
> break;
Both variables are used only here, if I'm not mistaken. Can't we go with
less churn and less excessively deep indentation by limiting the change
to just this inner case block (moving the decls here)?
> @@ -4309,144 +4313,149 @@ riscv_ip (char *str, struct riscv_cl_insn *ip, expressionS *imm_expr,
> break;
>
> case 'p': /* Vendor-specific (SpacemiT) operands. */
> - size_t n;
> - size_t s;
> - switch (*++oparg)
> - {
> - case 'V':
> - switch (*++oparg)
> - {
> - case 'd':
> - if (!reg_lookup (&asarg, RCLASS_VECR, ®no))
> - break;
> - if ((regno & 0x1) != 0)
> + {
> + size_t n;
> + size_t s;
> + switch (*++oparg)
> + {
> + case 'V':
> + switch (*++oparg)
> {
> - error.msg
> - = _("illegal operands (vd must be even)");
> - error.missing_ext = NULL;
> - goto out;
> + case 'd':
> + if (!reg_lookup (&asarg, RCLASS_VECR, ®no))
> + break;
> + if ((regno & 0x1) != 0)
> + {
> + error.msg
> + = _("illegal operands (vd must be even)");
> + error.missing_ext = NULL;
> + goto out;
> + }
> + INSERT_OPERAND (SPACEMIT_IME_VD, *ip, regno>>1);
> + continue;
> + case 's':
> + if (!reg_lookup (&asarg, RCLASS_VECR, ®no))
> + break;
> + if ((regno & 0x1) != 0)
> + {
> + error.msg
> + = _("illegal operands "
> + "(vs1 must be even)");
> + error.missing_ext = NULL;
> + goto out;
> + }
> + INSERT_OPERAND (SPACEMIT_IME_VS1,
> + *ip, regno>>1);
> + continue;
> + case 'm':
> + if (!reg_lookup (&asarg, RCLASS_VECR, ®no))
> + break;
> + if (regno >= 2)
> + {
> + error.msg
> + = _("illegal operands "
> + "(mask must be v0/v1)");
> + error.missing_ext = NULL;
> + goto out;
> + }
> + INSERT_OPERAND (SPACEMIT_IME_VMASK, *ip, regno);
> + continue;
> + default:
> + goto unknown_riscv_ip_operand;
> }
> - INSERT_OPERAND (SPACEMIT_IME_VD, *ip, regno>>1);
> + break;
> + case 'u': /* Integer immediate, 'XpuN@S' ...
> + N-bit unsigned immediate at bit S. */
> + n = strtol (oparg + 1, (char **)&oparg, 10);
> + if (*oparg != '@')
> + goto unknown_riscv_ip_operand;
> + s = strtol (oparg + 1, (char **)&oparg, 10);
> + oparg--;
> + my_getExpression (imm_expr, asarg, force_reloc);
> + check_absolute_expr (ip, imm_expr, false);
> + if (!VALIDATE_U_IMM (imm_expr->X_add_number, n))
> + as_bad (_("improper immediate value (%"PRIu64")"),
> + imm_expr->X_add_number);
> + INSERT_IMM (n, s, *ip, imm_expr->X_add_number);
> + imm_expr->X_op = O_absent;
> + asarg = expr_parse_end;
> continue;
Similarly here then.
Jan
More information about the Binutils
mailing list