tcg/loongarch64: Use tcg_pcrel_diff in tcg_out_ldst

Take the w^x split into account when computing the
pc-relative distance to an absolute pointer.

Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2022-11-29 09:03:23 -08:00
parent 7bc76a4c2e
commit 21199bfbef
1 changed files with 1 additions and 1 deletions

View File

@ -702,7 +702,7 @@ static void tcg_out_ldst(TCGContext *s, LoongArchInsn opc, TCGReg data,
intptr_t imm12 = sextreg(offset, 0, 12); intptr_t imm12 = sextreg(offset, 0, 12);
if (offset != imm12) { if (offset != imm12) {
intptr_t diff = offset - (uintptr_t)s->code_ptr; intptr_t diff = tcg_pcrel_diff(s, (void *)offset);
if (addr == TCG_REG_ZERO && diff == (int32_t)diff) { if (addr == TCG_REG_ZERO && diff == (int32_t)diff) {
imm12 = sextreg(diff, 0, 12); imm12 = sextreg(diff, 0, 12);