mirror of https://github.com/xqemu/xqemu.git
Fix handling of conditional branches in delay slot of a conditional branch
Check whether dc->npc is dynamic before using its value for branch. Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
6546bc3713
commit
548f66db33
|
@ -1286,7 +1286,6 @@ static inline void gen_cond_reg(TCGv r_dst, int cond, TCGv r_src)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* XXX: potentially incorrect if dynamic npc */
|
|
||||||
static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,
|
static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,
|
||||||
TCGv r_cond)
|
TCGv r_cond)
|
||||||
{
|
{
|
||||||
|
@ -1321,13 +1320,17 @@ static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,
|
||||||
} else {
|
} else {
|
||||||
dc->pc = dc->npc;
|
dc->pc = dc->npc;
|
||||||
dc->jump_pc[0] = target;
|
dc->jump_pc[0] = target;
|
||||||
dc->jump_pc[1] = dc->npc + 4;
|
if (unlikely(dc->npc == DYNAMIC_PC)) {
|
||||||
dc->npc = JUMP_PC;
|
dc->jump_pc[1] = DYNAMIC_PC;
|
||||||
|
tcg_gen_addi_tl(cpu_pc, cpu_npc, 4);
|
||||||
|
} else {
|
||||||
|
dc->jump_pc[1] = dc->npc + 4;
|
||||||
|
dc->npc = JUMP_PC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX: potentially incorrect if dynamic npc */
|
|
||||||
static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,
|
static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,
|
||||||
TCGv r_cond)
|
TCGv r_cond)
|
||||||
{
|
{
|
||||||
|
@ -1362,14 +1365,18 @@ static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc,
|
||||||
} else {
|
} else {
|
||||||
dc->pc = dc->npc;
|
dc->pc = dc->npc;
|
||||||
dc->jump_pc[0] = target;
|
dc->jump_pc[0] = target;
|
||||||
dc->jump_pc[1] = dc->npc + 4;
|
if (unlikely(dc->npc == DYNAMIC_PC)) {
|
||||||
dc->npc = JUMP_PC;
|
dc->jump_pc[1] = DYNAMIC_PC;
|
||||||
|
tcg_gen_addi_tl(cpu_pc, cpu_npc, 4);
|
||||||
|
} else {
|
||||||
|
dc->jump_pc[1] = dc->npc + 4;
|
||||||
|
dc->npc = JUMP_PC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TARGET_SPARC64
|
#ifdef TARGET_SPARC64
|
||||||
/* XXX: potentially incorrect if dynamic npc */
|
|
||||||
static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn,
|
static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn,
|
||||||
TCGv r_cond, TCGv r_reg)
|
TCGv r_cond, TCGv r_reg)
|
||||||
{
|
{
|
||||||
|
@ -1384,8 +1391,13 @@ static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn,
|
||||||
} else {
|
} else {
|
||||||
dc->pc = dc->npc;
|
dc->pc = dc->npc;
|
||||||
dc->jump_pc[0] = target;
|
dc->jump_pc[0] = target;
|
||||||
dc->jump_pc[1] = dc->npc + 4;
|
if (unlikely(dc->npc == DYNAMIC_PC)) {
|
||||||
dc->npc = JUMP_PC;
|
dc->jump_pc[1] = DYNAMIC_PC;
|
||||||
|
tcg_gen_addi_tl(cpu_pc, cpu_npc, 4);
|
||||||
|
} else {
|
||||||
|
dc->jump_pc[1] = dc->npc + 4;
|
||||||
|
dc->npc = JUMP_PC;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue