mirror of https://github.com/xemu-project/xemu.git
target/m68k: Always return a temporary from gen_lea_mode
Returning a raw areg does not preserve the value if the areg is subsequently modified. Fixes, e.g. "jsr (sp)", where the return address is pushed before the branch. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2483 Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20240813000737.228470-1-richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
parent
3213da7b95
commit
352cc9f300
|
@ -720,7 +720,9 @@ static TCGv gen_lea_mode(CPUM68KState *env, DisasContext *s,
|
||||||
}
|
}
|
||||||
/* fallthru */
|
/* fallthru */
|
||||||
case 2: /* Indirect register */
|
case 2: /* Indirect register */
|
||||||
return get_areg(s, reg0);
|
tmp = tcg_temp_new();
|
||||||
|
tcg_gen_mov_i32(tmp, get_areg(s, reg0));
|
||||||
|
return tmp;
|
||||||
case 4: /* Indirect predecrememnt. */
|
case 4: /* Indirect predecrememnt. */
|
||||||
if (opsize == OS_UNSIZED) {
|
if (opsize == OS_UNSIZED) {
|
||||||
return NULL_QREG;
|
return NULL_QREG;
|
||||||
|
@ -747,20 +749,23 @@ static TCGv gen_lea_mode(CPUM68KState *env, DisasContext *s,
|
||||||
switch (reg0) {
|
switch (reg0) {
|
||||||
case 0: /* Absolute short. */
|
case 0: /* Absolute short. */
|
||||||
offset = (int16_t)read_im16(env, s);
|
offset = (int16_t)read_im16(env, s);
|
||||||
return tcg_constant_i32(offset);
|
break;
|
||||||
case 1: /* Absolute long. */
|
case 1: /* Absolute long. */
|
||||||
offset = read_im32(env, s);
|
offset = read_im32(env, s);
|
||||||
return tcg_constant_i32(offset);
|
break;
|
||||||
case 2: /* pc displacement */
|
case 2: /* pc displacement */
|
||||||
offset = s->pc;
|
offset = s->pc;
|
||||||
offset += (int16_t)read_im16(env, s);
|
offset += (int16_t)read_im16(env, s);
|
||||||
return tcg_constant_i32(offset);
|
break;
|
||||||
case 3: /* pc index+displacement. */
|
case 3: /* pc index+displacement. */
|
||||||
return gen_lea_indexed(env, s, NULL_QREG);
|
return gen_lea_indexed(env, s, NULL_QREG);
|
||||||
case 4: /* Immediate. */
|
case 4: /* Immediate. */
|
||||||
default:
|
default:
|
||||||
return NULL_QREG;
|
return NULL_QREG;
|
||||||
}
|
}
|
||||||
|
tmp = tcg_temp_new();
|
||||||
|
tcg_gen_movi_i32(tmp, offset);
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
/* Should never happen. */
|
/* Should never happen. */
|
||||||
return NULL_QREG;
|
return NULL_QREG;
|
||||||
|
|
Loading…
Reference in New Issue