[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/3] target/riscv: Update MTINST/HTINST CSR in riscv_cpu_do_i
Re: [PATCH 3/3] target/riscv: Update MTINST/HTINST CSR in riscv_cpu_do_interrupt()
Thu, 13 Aug 2020 08:52:43 -0700
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0
On 8/12/20 4:16 PM, Alistair Francis wrote:
> I don't like that we have to manually decode the instructions. As it's
> only a handful it's not the end of the world, but it seems like
> duplication that could grow. Could we not use decode_insn16() instead?
> That way we can share the well tested TCG decoder.
Certainly. Compare how the decoder can be re-purposed for disassembly -- e.g.
Perhaps something like
typedef uint32_t DisasContext;
* This function is supposed to be called for an instruction
* that has already executed, and thus is known to be valid.
* That said, return 0 for an invalid instruction.
uint32_t riscv_expand_rvc_to_rvi(uint16_t insn16)
uint32_t insn32 = 0; /* illegal instruction */
static bool expand_i(DisasContext *ctx, arg_immi *a,
insn32 = SET_RD(insn32, a->rd);
insn32 = SET_RS1(insn32, a->rs1);
insn32 = SET_I_IMM(insn32, a->imm);
*ctx = insn32;
static bool trans_addi(DisasContext *ctx, arg_immi *a)
return expand_i(ctx, a, OPC_RISC_ADDI);
etc. All placed in a new file, so that the myriad symbols don't conflict with