mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
target/riscv: Calculate address according to XLEN
Define one common function to compute a canonical address from a register plus offset. Merge gen_pm_adjust_address into this function. Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-id: 20220120122050.41546-14-zhiwei_liu@c-sky.com Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
0cff460de9
commit
4302bef9e1
5 changed files with 21 additions and 69 deletions
|
@ -226,14 +226,7 @@ static bool trans_bgeu(DisasContext *ctx, arg_bgeu *a)
|
|||
static bool gen_load_tl(DisasContext *ctx, arg_lb *a, MemOp memop)
|
||||
{
|
||||
TCGv dest = dest_gpr(ctx, a->rd);
|
||||
TCGv addr = get_gpr(ctx, a->rs1, EXT_NONE);
|
||||
|
||||
if (a->imm) {
|
||||
TCGv temp = temp_new(ctx);
|
||||
tcg_gen_addi_tl(temp, addr, a->imm);
|
||||
addr = temp;
|
||||
}
|
||||
addr = gen_pm_adjust_address(ctx, addr);
|
||||
TCGv addr = get_address(ctx, a->rs1, a->imm);
|
||||
|
||||
tcg_gen_qemu_ld_tl(dest, addr, ctx->mem_idx, memop);
|
||||
gen_set_gpr(ctx, a->rd, dest);
|
||||
|
@ -330,16 +323,9 @@ static bool trans_ldu(DisasContext *ctx, arg_ldu *a)
|
|||
|
||||
static bool gen_store_tl(DisasContext *ctx, arg_sb *a, MemOp memop)
|
||||
{
|
||||
TCGv addr = get_gpr(ctx, a->rs1, EXT_NONE);
|
||||
TCGv addr = get_address(ctx, a->rs1, a->imm);
|
||||
TCGv data = get_gpr(ctx, a->rs2, EXT_NONE);
|
||||
|
||||
if (a->imm) {
|
||||
TCGv temp = temp_new(ctx);
|
||||
tcg_gen_addi_tl(temp, addr, a->imm);
|
||||
addr = temp;
|
||||
}
|
||||
addr = gen_pm_adjust_address(ctx, addr);
|
||||
|
||||
tcg_gen_qemu_st_tl(data, addr, ctx->mem_idx, memop);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue