[PATCH] RISC-V: Modify the error message for zilsd/zclsd
Nelson Chu
nelson@rivosinc.com
Tue Aug 12 13:56:32 GMT 2025
On Tue, Aug 12, 2025 at 9:33 PM Dongyan Chen <chendongyan@isrc.iscas.ac.cn>
wrote:
> Regarding the error messages caused by the use of register pairs in
> "zilsd" and "zclsd", it is necessary to inform the users that they
> need to use even-numbered register pairs.
>
> bfd/ChangeLog:
>
> * version.h (BFD_VERSION_DATE): Updated.
>
> gas/ChangeLog:
>
> * config/tc-riscv.c (riscv_ip): Select the error message.
> * testsuite/gas/riscv/zilsd-zclsd-fail.l: Updated.
>
> include/ChangeLog:
>
> * opcode/riscv.h (riscv_get_sp_base): Declare.
>
> opcodes/ChangeLog:
>
> * riscv-opc.c (match_rd_even): Add error message.
> (match_rs2_even): Ditto.
> (match_crs2s_even): Ditto.
> (match_crs2_even): Ditto.
>
> ---
> bfd/version.h | 2 +-
> gas/config/tc-riscv.c | 5 +++-
> gas/testsuite/gas/riscv/zilsd-zclsd-fail.l | 14 +++++-----
> include/opcode/riscv.h | 2 ++
> opcodes/riscv-opc.c | 30 +++++++++++++++++++---
> 5 files changed, 40 insertions(+), 13 deletions(-)
>
> diff --git a/bfd/version.h b/bfd/version.h
> index 7bdf479e492..9bf25d4a9cd 100644
> --- a/bfd/version.h
> +++ b/bfd/version.h
> @@ -16,7 +16,7 @@
>
> In releases, the date is not included in either version strings or
> sonames. */
> -#define BFD_VERSION_DATE 20250811
> +#define BFD_VERSION_DATE 20250812
> #define BFD_VERSION @bfd_version@
> #define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@
> #define REPORT_BUGS_TO @report_bugs_to@
> diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
>
You don't need to change this file.
> index 8a3356888d2..52a8abe0a58 100644
> --- a/gas/config/tc-riscv.c
> +++ b/gas/config/tc-riscv.c
> @@ -2908,7 +2908,10 @@ riscv_ip (char *str, struct riscv_cl_insn *ip,
> expressionS *imm_expr,
> {
> case '\0': /* End of args. */
> if (insn->match_func && !insn->match_func (insn,
> ip->insn_opcode))
> - break;
> + {
> + error.msg = riscv_match_error_msg ?
> riscv_match_error_msg : error.msg;
> + break;
> + }
>
I tried this many years ago,
https://github.com/riscvarchive/riscv-binutils-gdb/pull/188#issuecomment-557443035,
but finally I gave up because of the opcode search frameworks. The message
you set from the match function, may be overlapped by the latter
candidates, so it may not be the suitable or correct message for the case.
Personally I think maybe we should print all illegal operand messages for
all candidates, and let users choose. But I am not sure if users want all
errors for all instruction candidates or just a simple "illegal operands"?
Thanks
Nelson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20250812/34a8393a/attachment.htm>
More information about the Binutils
mailing list