|
| From: | Richard Henderson |
| Subject: | Re: [PATCH v6 4/6] target/riscv: Add support for PC-relative translation |
| Date: | Tue, 4 Apr 2023 06:56:45 -0700 |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 |
On 4/3/23 19:06, Weiwei Li wrote:
static bool trans_auipc(DisasContext *ctx, arg_auipc *a)
{
- gen_set_gpri(ctx, a->rd, a->imm + ctx->base.pc_next);
+ TCGv target_pc = dest_gpr(ctx, a->rd);
+ gen_pc_plus_diff(target_pc, ctx, a->imm + ctx->base.pc_next);
+ gen_set_gpr(ctx, a->rd, target_pc);
return true;
}
This is not how I expect a function called "pc plus diff" to work.
It should be simpler:
TCGv rd = dest_gpr(ctx, a->rd);
gen_pc_plus_diff(ctx, rd, a->imm);
gen_set_gpr(ctx, a->rd, rd);
All of the manipulation of cpu_pc, pc_save, and pc_next are all hidden inside the
function. All that "add upper immediate to pc" should do is supply the immediate.
r~
| [Prev in Thread] | Current Thread | [Next in Thread] |