From: Richard Henderson <richard.henderson@linaro.org>
To: liweiwei <liweiwei@iscas.ac.cn>,
palmer@dabbelt.com, alistair.francis@wdc.com,
bin.meng@windriver.com, qemu-riscv@nongnu.org,
qemu-devel@nongnu.org
Cc: wangjunqiang@iscas.ac.cn, lazyparser@gmail.com, ardxwe@gmail.com
Subject: Re: [PATCH 3/6] target/riscv: add support for zfinx
Date: Fri, 24 Dec 2021 14:26:43 -0800 [thread overview]
Message-ID: <a075e163-820e-d6ee-149d-1311af9dcc0a@linaro.org> (raw)
In-Reply-To: <20211224034915.17204-4-liweiwei@iscas.ac.cn>
On 12/23/21 7:49 PM, liweiwei wrote:
> static bool trans_fsgnj_s(DisasContext *ctx, arg_fsgnj_s *a)
> {
> REQUIRE_FPU;
> - REQUIRE_EXT(ctx, RVF);
> + REQUIRE_ZFINX_OR_F(ctx);
>
> + TCGv_i64 dest = dest_fpr(ctx, a->rd);
> if (a->rs1 == a->rs2) { /* FMOV */
> - gen_check_nanbox_s(cpu_fpr[a->rd], cpu_fpr[a->rs1]);
> + TCGv_i64 src1 = get_fpr_hs(ctx, a->rs1);
> + if (ctx->ext_zfinx) {
> + gen_nanbox_s(dest, src1);
Sign-extend, not nanbox. Or, since you handle sign-extension in gen_set_gpr_hs, nothing
at all -- just tcg_gen_mov_i64.
> } else { /* FSGNJ */
> - TCGv_i64 rs1 = tcg_temp_new_i64();
> - TCGv_i64 rs2 = tcg_temp_new_i64();
> -
> - gen_check_nanbox_s(rs1, cpu_fpr[a->rs1]);
> - gen_check_nanbox_s(rs2, cpu_fpr[a->rs2]);
> -
> - /* This formulation retains the nanboxing of rs2. */
> - tcg_gen_deposit_i64(cpu_fpr[a->rd], rs2, rs1, 0, 31);
> - tcg_temp_free_i64(rs1);
> - tcg_temp_free_i64(rs2);
> + TCGv_i64 rs1, rs2;
> + if (!ctx->ext_zfinx) {
> + TCGv_i64 src1 = get_fpr_hs(ctx, a->rs1);
> + TCGv_i64 src2 = get_fpr_hs(ctx, a->rs2);
> + rs1 = tcg_temp_new_i64();
> + rs2 = tcg_temp_new_i64();
> + gen_check_nanbox_s(rs1, src1);
> + gen_check_nanbox_s(rs2, src2);
> + } else {
> + rs1 = get_fpr_hs(ctx, a->rs1);
> + rs2 = get_fpr_hs(ctx, a->rs2);
> + }
> +
> + /* This formulation retains the nanboxing of rs2 in normal 'F'. */
> + tcg_gen_deposit_i64(dest, rs2, rs1, 0, 31);
> + if (!ctx->ext_zfinx) {
> + tcg_temp_free_i64(rs1);
> + tcg_temp_free_i64(rs2);
> + } else {
> + gen_nanbox_s(dest, dest);
> + }
This is tangled enough that I think you should check zfinx at one higher indent level, and
not do conditional allocate followed by conditional free.
> diff --git a/target/riscv/internals.h b/target/riscv/internals.h
> index 065e8162a2..9f3f3319f2 100644
> --- a/target/riscv/internals.h
> +++ b/target/riscv/internals.h
> @@ -51,8 +51,12 @@ static inline uint64_t nanbox_s(float32 f)
> return f | MAKE_64BIT_MASK(32, 32);
> }
>
> -static inline float32 check_nanbox_s(uint64_t f)
> +static inline float32 check_nanbox_s(CPURISCVState *env, uint64_t f)
> {
> + /* Disable nanbox check when enable zfinx */
> + if (RISCV_CPU(env_cpu(env))->cfg.ext_zfinx)
> + return (uint32_t)f;
> +
Braces.
r~
next prev parent reply other threads:[~2021-12-24 22:27 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-24 3:49 [PATCH 0/6] support subsets of Float-Point in Integer Registers extensions liweiwei
2021-12-24 3:49 ` [PATCH 1/6] target/riscv: add cfg properties for zfinx, zdinx and zhinx{min} liweiwei
2021-12-24 21:40 ` Richard Henderson
2022-01-03 22:47 ` Alistair Francis
2021-12-24 3:49 ` [PATCH 2/6] target/riscv: add support for unique fpr read/write with support for zfinx liweiwei
2021-12-24 22:00 ` Richard Henderson
2021-12-25 3:13 ` liweiwei
2021-12-25 22:00 ` Richard Henderson
2021-12-26 1:42 ` liweiwei
2021-12-26 1:54 ` liweiwei
2021-12-26 3:48 ` Richard Henderson
2021-12-24 3:49 ` [PATCH 3/6] target/riscv: add " liweiwei
2021-12-24 22:26 ` Richard Henderson [this message]
2021-12-25 3:24 ` liweiwei
2021-12-24 3:49 ` [PATCH 4/6] target/riscv: add support for zdinx liweiwei
2021-12-24 22:30 ` Richard Henderson
2021-12-25 3:27 ` liweiwei
2021-12-24 3:49 ` [PATCH 5/6] target/riscv: add support for zhinx/zhinxmin liweiwei
2021-12-24 22:32 ` Richard Henderson
2021-12-25 3:35 ` liweiwei
2021-12-24 3:49 ` [PATCH 6/6] target/riscv: expose zfinx, zdinx, zhinx{min} properties liweiwei
2021-12-24 22:32 ` Richard Henderson
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=a075e163-820e-d6ee-149d-1311af9dcc0a@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=ardxwe@gmail.com \
--cc=bin.meng@windriver.com \
--cc=lazyparser@gmail.com \
--cc=liweiwei@iscas.ac.cn \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=wangjunqiang@iscas.ac.cn \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).