From: Richard Henderson <richard.henderson@linaro.org>
To: Alistair Francis <alistair.francis@opensource.wdc.com>,
qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: alistair.francis@wdc.com, bmeng.cn@gmail.com, palmer@dabbelt.com,
alistair23@gmail.com
Subject: Re: [PATCH v2 1/3] target/riscv: Set the opcode in DisasContext
Date: Wed, 8 Sep 2021 08:27:09 +0200 [thread overview]
Message-ID: <ee61fe15-5851-c896-f7f6-10b33bbf5d2a@linaro.org> (raw)
In-Reply-To: <2540484d3fb928600d403182529bf345b2b1f915.1631076834.git.alistair.francis@wdc.com>
On 9/8/21 6:54 AM, Alistair Francis wrote:
> From: Alistair Francis <alistair.francis@wdc.com>
>
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> ---
> target/riscv/translate.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/target/riscv/translate.c b/target/riscv/translate.c
> index e356fc6c46..25670be435 100644
> --- a/target/riscv/translate.c
> +++ b/target/riscv/translate.c
> @@ -485,20 +485,20 @@ static uint32_t opcode_at(DisasContextBase *dcbase, target_ulong pc)
> /* Include the auto-generated decoder for 16 bit insn */
> #include "decode-insn16.c.inc"
>
> -static void decode_opc(CPURISCVState *env, DisasContext *ctx, uint16_t opcode)
> +static void decode_opc(CPURISCVState *env, DisasContext *ctx)
> {
> /* check for compressed insn */
> - if (extract16(opcode, 0, 2) != 3) {
> + if (extract16(ctx->opcode, 0, 2) != 3) {
> if (!has_ext(ctx, RVC)) {
> gen_exception_illegal(ctx);
> } else {
> ctx->pc_succ_insn = ctx->base.pc_next + 2;
> - if (!decode_insn16(ctx, opcode)) {
> + if (!decode_insn16(ctx, ctx->opcode)) {
> gen_exception_illegal(ctx);
> }
> }
> } else {
> - uint32_t opcode32 = opcode;
> + uint32_t opcode32 = ctx->opcode;
> opcode32 = deposit32(opcode32, 16, 16,
> translator_lduw(env, ctx->base.pc_next + 2));
You needed to write back to ctx->opcode here.
I think that all of the other changes are less than ideal -- let the value stay in a
register as long as possible and drop them to memory immediately before calling
decode_insn{16,32}, just before the write to pc_succ_insn in both cases.
r~
> ctx->pc_succ_insn = ctx->base.pc_next + 4;
> @@ -561,9 +561,9 @@ static void riscv_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
> {
> DisasContext *ctx = container_of(dcbase, DisasContext, base);
> CPURISCVState *env = cpu->env_ptr;
> - uint16_t opcode16 = translator_lduw(env, ctx->base.pc_next);
> + ctx->opcode = translator_lduw(env, ctx->base.pc_next);
>
> - decode_opc(env, ctx, opcode16);
> + decode_opc(env, ctx);
> ctx->base.pc_next = ctx->pc_succ_insn;
> ctx->w = false;
>
>
next prev parent reply other threads:[~2021-09-08 6:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-08 4:54 [PATCH v2 0/3] RISC-V: Populate mtval and stval Alistair Francis
2021-09-08 4:54 ` [PATCH v2 1/3] target/riscv: Set the opcode in DisasContext Alistair Francis
2021-09-08 5:42 ` Bin Meng
2021-09-08 6:27 ` Richard Henderson [this message]
2021-09-08 4:54 ` [PATCH v2 2/3] target/riscv: Implement the stval/mtval illegal instruction Alistair Francis
2021-09-08 5:53 ` Bin Meng
2021-09-08 6:48 ` Richard Henderson
2021-09-24 6:48 ` Alistair Francis
2021-09-24 12:57 ` Richard Henderson
2021-09-29 3:56 ` Alistair Francis
2021-09-08 4:54 ` [PATCH v2 3/3] target/riscv: Set mtval and stval support Alistair Francis
2021-09-08 5:55 ` Bin Meng
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=ee61fe15-5851-c896-f7f6-10b33bbf5d2a@linaro.org \
--to=richard.henderson@linaro.org \
--cc=alistair.francis@opensource.wdc.com \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=bmeng.cn@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
/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).