From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: Max Chou <max.chou@sifive.com>,
qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <alistair.francis@wdc.com>,
Weiwei Li <liwei1518@gmail.com>,
Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
antonb@tenstorrent.com
Subject: Re: [PATCH v2 03/12] target/riscv: Add vext_check_input_eew to check mismatched input EEWs encoding constraint
Date: Sat, 5 Apr 2025 06:09:20 -0300 [thread overview]
Message-ID: <b554b45e-50c2-41e9-af73-5074bdfee0ee@ventanamicro.com> (raw)
In-Reply-To: <20250329144446.2619306-4-max.chou@sifive.com>
On 3/29/25 11:44 AM, Max Chou wrote:
> According to the v spec, a vector register cannot be used to provide source
> operands with more than one EEW for a single instruction.
>
> Signed-off-by: Max Chou <max.chou@sifive.com>
> ---
> target/riscv/insn_trans/trans_rvv.c.inc | 29 +++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
>
> diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc
> index e630f8661e1..70c19c49ae4 100644
> --- a/target/riscv/insn_trans/trans_rvv.c.inc
> +++ b/target/riscv/insn_trans/trans_rvv.c.inc
> @@ -379,6 +379,35 @@ static bool vext_check_ld_index(DisasContext *s, int vd, int vs2,
> return ret;
> }
>
> +/*
> + * Check whether a vector register is used to provide source operands with
> + * more than one EEW for the vector instruction.
> + * Returns true if the instruction has valid encoding
> + * Returns false if encoding violates the mismatched input EEWs constraint
> + */
> +static bool vext_check_input_eew(DisasContext *s, int vs1, uint8_t eew_vs1,
> + int vs2, uint8_t eew_vs2, int vm)
> +{
> + bool is_valid = true;
> + int8_t emul_vs1 = eew_vs1 - s->sew + s->lmul;
> + int8_t emul_vs2 = eew_vs2 - s->sew + s->lmul;
> +
> + /* When vm is 0, vs1 & vs2(EEW!=1) group can't overlap v0 (EEW=1) */
> + if ((vs1 != -1 && !require_vm(vm, vs1)) ||
> + (vs2 != -1 && !require_vm(vm, vs2))) {
> + is_valid = false;
> + }
> +
> + /* When eew_vs1 != eew_vs2, check whether vs1 and vs2 are overlapped */
> + if ((vs1 != -1 && vs2 != -1) && (eew_vs1 != eew_vs2) &&
> + is_overlapped(vs1, 1 << MAX(emul_vs1, 0),
> + vs2, 1 << MAX(emul_vs2, 0))) {
> + is_valid = false;
> + }
> +
> + return is_valid;
> +}
> +
Code LGTM but the patch won't compile on its own because there's no callers for
it:
In file included from ../target/riscv/translate.c:1182:
../target/riscv/insn_trans/trans_rvv.c.inc:388:13: error: ‘vext_check_input_eew’ defined but not used [-Werror=unused-function]
388 | static bool vext_check_input_eew(DisasContext *s, int vs1, uint8_t eew_vs1,
| ^~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
ninja: build stopped: subcommand failed.
We want each patch to be "buildable" and with test passing to make our lives easier
when doing bisects.
You can merge this patch with patch 4 to introduce the new function and add its first
callers. Thanks,
Daniel
> static bool vext_check_ss(DisasContext *s, int vd, int vs, int vm)
> {
> return require_vm(vm, vd) &&
next prev parent reply other threads:[~2025-04-05 9:10 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-29 14:44 [PATCH v2 00/12] Fix RVV encoding corner cases Max Chou
2025-03-29 14:44 ` [PATCH v2 01/12] target/riscv: rvv: Source vector registers cannot overlap mask register Max Chou
2025-04-05 8:58 ` Daniel Henrique Barboza
2025-03-29 14:44 ` [PATCH v2 02/12] target/riscv: rvv: Add CHECK arg to GEN_OPFVF_WIDEN_TRANS Max Chou
2025-04-05 8:58 ` Daniel Henrique Barboza
2025-03-29 14:44 ` [PATCH v2 03/12] target/riscv: Add vext_check_input_eew to check mismatched input EEWs encoding constraint Max Chou
2025-04-05 9:09 ` Daniel Henrique Barboza [this message]
2025-04-07 8:32 ` Max Chou
2025-03-29 14:44 ` [PATCH v2 04/12] target/riscv: rvv: Apply vext_check_input_eew to vector register gather instructions Max Chou
2025-04-05 9:14 ` Daniel Henrique Barboza
2025-04-07 8:34 ` Max Chou
2025-03-29 14:44 ` [PATCH v2 05/12] target/riscv: rvv: Apply vext_check_input_eew to OPIVI/OPIVX/OPFVF(vext_check_ss) instructions Max Chou
2025-04-05 9:17 ` Daniel Henrique Barboza
2025-04-07 8:35 ` Max Chou
2025-03-29 14:44 ` [PATCH v2 06/12] target/riscv: rvv: Apply vext_check_input_eew to OPIVV/OPFVV(vext_check_sss) instructions Max Chou
2025-04-05 9:18 ` Daniel Henrique Barboza
2025-03-29 14:44 ` [PATCH v2 07/12] target/riscv: rvv: Apply vext_check_input_eew to vector slide instructions(OPIVI/OPIVX) Max Chou
2025-04-05 9:18 ` Daniel Henrique Barboza
2025-03-29 14:44 ` [PATCH v2 08/12] target/riscv: rvv: Apply vext_check_input_eew to vector integer extension instructions(OPMVV) Max Chou
2025-04-05 9:18 ` Daniel Henrique Barboza
2025-03-29 14:44 ` [PATCH v2 09/12] target/riscv: rvv: Apply vext_check_input_eew to vector widen instructions(OPMVV/OPMVX/etc.) Max Chou
2025-04-05 9:20 ` Daniel Henrique Barboza
2025-03-29 14:44 ` [PATCH v2 10/12] target/riscv: rvv: Apply vext_check_input_eew to vector narrow instructions Max Chou
2025-04-05 9:20 ` Daniel Henrique Barboza
2025-03-29 14:44 ` [PATCH v2 11/12] target/riscv: rvv: Apply vext_check_input_eew to vector indexed load/store instructions Max Chou
2025-04-05 9:20 ` Daniel Henrique Barboza
2025-03-29 14:44 ` [PATCH v2 12/12] target/riscv: Fix the rvv reserved encoding of unmasked instructions Max Chou
2025-04-05 9:21 ` Daniel Henrique Barboza
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b554b45e-50c2-41e9-af73-5074bdfee0ee@ventanamicro.com \
--to=dbarboza@ventanamicro.com \
--cc=alistair.francis@wdc.com \
--cc=antonb@tenstorrent.com \
--cc=liwei1518@gmail.com \
--cc=max.chou@sifive.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.