mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03: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
|
@ -390,21 +390,20 @@ static void gen_jal(DisasContext *ctx, int rd, target_ulong imm)
|
|||
ctx->base.is_jmp = DISAS_NORETURN;
|
||||
}
|
||||
|
||||
/*
|
||||
* Generates address adjustment for PointerMasking
|
||||
*/
|
||||
static TCGv gen_pm_adjust_address(DisasContext *s, TCGv src)
|
||||
/* Compute a canonical address from a register plus offset. */
|
||||
static TCGv get_address(DisasContext *ctx, int rs1, int imm)
|
||||
{
|
||||
TCGv temp;
|
||||
if (!s->pm_enabled) {
|
||||
/* Load unmodified address */
|
||||
return src;
|
||||
} else {
|
||||
temp = temp_new(s);
|
||||
tcg_gen_andc_tl(temp, src, pm_mask);
|
||||
tcg_gen_or_tl(temp, temp, pm_base);
|
||||
return temp;
|
||||
TCGv addr = temp_new(ctx);
|
||||
TCGv src1 = get_gpr(ctx, rs1, EXT_NONE);
|
||||
|
||||
tcg_gen_addi_tl(addr, src1, imm);
|
||||
if (ctx->pm_enabled) {
|
||||
tcg_gen_and_tl(addr, addr, pm_mask);
|
||||
tcg_gen_or_tl(addr, addr, pm_base);
|
||||
} else if (get_xl(ctx) == MXL_RV32) {
|
||||
tcg_gen_ext32u_tl(addr, addr);
|
||||
}
|
||||
return addr;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_USER_ONLY
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue