[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC v3 15/71] target/riscv: introduce more imm value modes in trans
From: |
Richard Henderson |
Subject: |
Re: [RFC v3 15/71] target/riscv: introduce more imm value modes in translator functions |
Date: |
Thu, 6 Aug 2020 15:54:07 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
On 8/6/20 3:46 AM, frank.chang@sifive.com wrote:
> From: Frank Chang <frank.chang@sifive.com>
>
> Immediate value in translator function is extended not only
> zero-extended and sign-extended but with more modes to be applicable
> with multiple formats of vector instructions.
>
> * IMM_ZX: Zero-extended
> * IMM_SX: Sign-extended
> * IMM_TRUNC_SEW: Truncate to log(SEW) bit
> * IMM_TRUNC_2SEW: Truncate to log(2*SEW) bit
>
> Signed-off-by: Frank Chang <frank.chang@sifive.com>
> ---
> target/riscv/insn_trans/trans_rvv.inc.c | 115 ++++++++++++++----------
> 1 file changed, 66 insertions(+), 49 deletions(-)
>
> diff --git a/target/riscv/insn_trans/trans_rvv.inc.c
> b/target/riscv/insn_trans/trans_rvv.inc.c
> index c2d0865bb9b..0a4dd875e96 100644
> --- a/target/riscv/insn_trans/trans_rvv.inc.c
> +++ b/target/riscv/insn_trans/trans_rvv.inc.c
> @@ -1281,8 +1281,32 @@ static void tcg_gen_gvec_rsubs(unsigned vece, uint32_t
> dofs, uint32_t aofs,
>
> GEN_OPIVX_GVEC_TRANS(vrsub_vx, rsubs)
>
> +enum {
> + IMM_ZX, /* Zero-extended */
> + IMM_SX, /* Sign-extended */
> + IMM_TRUNC_SEW, /* Truncate to log(SEW) bits */
> + IMM_TRUNC_2SEW, /* Truncate to log(2*SEW) bits */
> +};
Better to name the enumeration and use it...
> +
> +static int64_t extract_imm(DisasContext *s, uint32_t imm, int imm_mode)
... here.
> +{
> + switch (imm_mode) {
> + case IMM_ZX:
> + return extract64(imm, 0, 5);
> + case IMM_SX:
> + return sextract64(imm, 0, 5);
> + case IMM_TRUNC_SEW:
> + return extract64(imm, 0, 5) & ((1 << (s->sew + 3)) - 1);
> + case IMM_TRUNC_2SEW:
> + return extract64(imm, 0, 5) & ((2 << (s->sew + 3)) - 1);
The extract is redundant with the &.
Alternately, put sew into the extract, like so:
return extract64(imm, 0, s->sew + 3);
and
return extract64(imm, 0, s->sew + 4);
> + default:
> + g_assert_not_reached();
> + break;
Unreachable break.
> static bool opivi_trans(uint32_t vd, uint32_t imm, uint32_t vs2, uint32_t vm,
> - gen_helper_opivx *fn, DisasContext *s, int zx)
> + gen_helper_opivx *fn, DisasContext *s, int imm_mode)
Use the enum.
> static inline bool
> do_opivi_gvec(DisasContext *s, arg_rmrr *a, GVecGen2iFn *gvec_fn,
> - gen_helper_opivx *fn, int zx)
> + gen_helper_opivx *fn, int imm_mode)
Use the enum.
r~
- [RFC v3 09/71] target/riscv: rvv-1.0: add vlenb register, (continued)
- [RFC v3 09/71] target/riscv: rvv-1.0: add vlenb register, frank . chang, 2020/08/06
- [RFC v3 10/71] target/riscv: rvv-1.0: check MSTATUS_VS when accessing vector csr registers, frank . chang, 2020/08/06
- [RFC v3 11/71] target/riscv: rvv-1.0: remove MLEN calculations, frank . chang, 2020/08/06
- [RFC v3 12/71] target/riscv: rvv-1.0: add fractional LMUL, frank . chang, 2020/08/06
- [RFC v3 13/71] target/riscv: rvv-1.0: add VMA and VTA, frank . chang, 2020/08/06
- [RFC v3 15/71] target/riscv: introduce more imm value modes in translator functions, frank . chang, 2020/08/06
- Re: [RFC v3 15/71] target/riscv: introduce more imm value modes in translator functions,
Richard Henderson <=
- [RFC v3 16/71] target/riscv: add fp16 nan-box check generator function, frank . chang, 2020/08/06
- [RFC v3 14/71] target/riscv: rvv-1.0: update check functions, frank . chang, 2020/08/06
- [RFC v3 17/71] target/riscv: rvv:1.0: add translation-time nan-box helper function, frank . chang, 2020/08/06
- [RFC v3 19/71] target/riscv: rvv-1.0: configure instructions, frank . chang, 2020/08/06
- [RFC v3 18/71] target/riscv: rvv-1.0: apply nanbox helper in opfvf_trans, frank . chang, 2020/08/06
- [RFC v3 20/71] target/riscv: rvv-1.0: stride load and store instructions, frank . chang, 2020/08/06