From: Richard Henderson <richard.henderson@linaro.org>
To: Weiwei Li <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
Subject: Re: [PATCH v3 6/9] target/riscv: add support for Zcmp extension
Date: Thu, 17 Nov 2022 01:44:03 -0800 [thread overview]
Message-ID: <97ceaca3-109e-ba04-30b2-c7f55c6ed422@linaro.org> (raw)
In-Reply-To: <20221117070316.58447-7-liweiwei@iscas.ac.cn>
On 11/16/22 23:03, Weiwei Li wrote:
> Add encode, trans* functions for Zcmp instructions
>
> Signed-off-by: Weiwei Li <liweiwei@iscas.ac.cn>
> Signed-off-by: Junqiang Wang <wangjunqiang@iscas.ac.cn>
> ---
> target/riscv/insn16.decode | 18 ++
> target/riscv/insn_trans/trans_rvzce.c.inc | 242 +++++++++++++++++++++-
> target/riscv/translate.c | 5 +
> 3 files changed, 264 insertions(+), 1 deletion(-)
Better, though...
> +static bool gen_zcmp_check(DisasContext *ctx, arg_zcmp *a)
> +{
> + /* rlist 0 to 3 are reserved for future EABI variant */
> + if (a->zcmp_rlist < 4) {
> + return false;
> + }
> +
> + /* rlist <= 6 when RV32E/RV64E */
> + if (ctx->cfg_ptr->ext_e && a->zcmp_rlist > 6) {
> + return false;
> + }
> +
> + return true;
> +}
This could be merged into...
> +
> +#define X_S0 8
> +#define X_S1 9
> +#define X_Sn 16
> +
> +static inline void update_push_pop_list(target_ulong rlist, bool *xreg_list)
... here.
For instance, one way is to return false when the list is invalid.
Better is to return a uint32_t bitmap of the registers in the list, with 0 indicating invalid.
Nit 1: Remove the inline.
Nit 2: A better name might be decode_push_pop_list.
> +static inline target_ulong caculate_stack_adj(int bytes, target_ulong rlist,
> + target_ulong spimm)
> +{
> + target_ulong stack_adj_base = 0;
> + switch (rlist) {
> + case 15:
> + stack_adj_base = bytes == 4 ? 64 : 112;
> + break;
> + case 14:
> + stack_adj_base = bytes == 4 ? 48 : 96;
> + break;
> + case 13:
> + case 12:
> + stack_adj_base = bytes == 4 ? 48 : 80;
> + break;
> + case 11:
> + case 10:
> + stack_adj_base = bytes == 4 ? 32 : 64;
> + break;
> + case 9:
> + case 8:
> + stack_adj_base = bytes == 4 ? 32 : 48;
> + break;
> + case 7:
> + case 6:
> + stack_adj_base = bytes == 4 ? 16 : 32;
> + break;
> + case 5:
> + case 4:
> + stack_adj_base = 16;
> + break;
> + }
I really dislike this, as it replicates the decoding done just above.
I think this ought to be simply:
ROUND_UP(ctpop32(reg_bitmap) * reg_size, 16) + spimm
> +static bool gen_pop(DisasContext *ctx, arg_zcmp *a, bool ret, bool ret_val)
> +{
> + REQUIRE_ZCMP(ctx);
> +
> + if (!gen_zcmp_check(ctx, a)) {
> + return false;
> + }
> +
> + bool xreg_list[32] = {false};
> + int bytes = get_ol(ctx) == MXL_RV32 ? 4 : 8;
Better with
MemOp memop = get_ol(ctx) == MXL_RV32 ? MO_TEUL : MO_TEUQ;
int reg_size = memop_size(memop);
> + switch (bytes) {
> + case 4:
> + tcg_gen_qemu_ld_tl(dest, addr, ctx->mem_idx, MO_32);
> + break;
> + case 8:
> + tcg_gen_qemu_ld_tl(dest, addr, ctx->mem_idx, MO_64);
> + break;
> + default:
> + break;
> + }
These are incorrect in that they do not indicate the target endianness.
Better to merge the two using the common memop computed above:
tcg_gen_qemu_ld_tl(dest, addr, ctx->mem_idx, memop);
> +static bool trans_cm_mvsa01(DisasContext *ctx, arg_cm_mvsa01 *a)
> +{
> + REQUIRE_ZCMP(ctx);
> +
> + TCGv a0 = get_gpr(ctx, xA0, EXT_NONE);
> + TCGv a1 = get_gpr(ctx, xA1, EXT_NONE);
> +
> + gen_set_gpr(ctx, a->rs1, a0);
> + gen_set_gpr(ctx, a->rs2, a1);
rs1 must not equal rs2.
r~
next prev parent reply other threads:[~2022-11-17 9:44 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 7:03 [PATCH v3 0/9] support subsets of code size reduction extension Weiwei Li
2022-11-17 7:03 ` [PATCH v3 1/9] target/riscv: add cfg properties for Zc* extension Weiwei Li
2022-11-17 8:54 ` Richard Henderson
2022-11-17 7:03 ` [PATCH v3 2/9] target/riscv: add support for Zca extension Weiwei Li
2022-11-17 8:56 ` Richard Henderson
2022-11-17 7:03 ` [PATCH v3 3/9] target/riscv: add support for Zcf extension Weiwei Li
2022-11-17 8:58 ` Richard Henderson
2022-11-17 7:03 ` [PATCH v3 4/9] target/riscv: add support for Zcd extension Weiwei Li
2022-11-17 7:03 ` [PATCH v3 5/9] target/riscv: add support for Zcb extension Weiwei Li
2022-11-17 9:10 ` Richard Henderson
2022-11-17 7:03 ` [PATCH v3 6/9] target/riscv: add support for Zcmp extension Weiwei Li
2022-11-17 9:44 ` Richard Henderson [this message]
2022-11-17 11:41 ` weiwei
2022-11-17 7:03 ` [PATCH v3 7/9] target/riscv: add support for Zcmt extension Weiwei Li
2022-11-17 9:56 ` Richard Henderson
2022-11-17 11:44 ` weiwei
2022-11-17 20:57 ` Richard Henderson
2022-11-18 1:46 ` weiwei
2022-11-18 2:51 ` Richard Henderson
2022-11-18 3:51 ` weiwei
2022-11-17 7:03 ` [PATCH v3 8/9] target/riscv: expose properties for Zc* extension Weiwei Li
2022-11-17 7:03 ` [PATCH v3 9/9] disas/riscv.c: add disasm support for Zc* Weiwei Li
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=97ceaca3-109e-ba04-30b2-c7f55c6ed422@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alistair.francis@wdc.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).