Skip to content

Commit 09b43f9

Browse files
committed
CPU/NewRec: Clear needed on swapped delay slot
Fixes panic in BIOS on x86_64 Linux with PGXP enabled.
1 parent 5b4f741 commit 09b43f9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/core/cpu_newrec_compiler.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,9 @@ void CPU::NewRec::Compiler::CompileBranchDelaySlot(bool dirty_pc /* = true */)
13581358
// Update load delay at the end of the previous instruction.
13591359
UpdateLoadDelay();
13601360

1361+
// Don't need the branch instruction's inputs.
1362+
ClearHostRegsNeeded();
1363+
13611364
// TODO: Move cycle add before this.
13621365
inst++;
13631366
iinfo++;
@@ -1500,7 +1503,18 @@ void CPU::NewRec::Compiler::CompileTemplate(void (Compiler::*const_func)(Compile
15001503
UpdateHostRegCounters();
15011504

15021505
if (tflags & TF_CAN_SWAP_DELAY_SLOT && TrySwapDelaySlot(cf.MipsS(), cf.MipsT()))
1506+
{
1507+
// CompileBranchDelaySlot() clears needed, so need to reset.
15031508
cf.delay_slot_swapped = true;
1509+
if (tflags & TF_READS_S)
1510+
MarkRegsNeeded(HR_TYPE_CPU_REG, rs);
1511+
if (tflags & TF_READS_T)
1512+
MarkRegsNeeded(HR_TYPE_CPU_REG, rt);
1513+
if (tflags & TF_READS_LO)
1514+
MarkRegsNeeded(HR_TYPE_CPU_REG, Reg::lo);
1515+
if (tflags & TF_READS_HI)
1516+
MarkRegsNeeded(HR_TYPE_CPU_REG, Reg::hi);
1517+
}
15041518

15051519
if (tflags & TF_READS_S &&
15061520
(tflags & TF_NEEDS_REG_S || !cf.const_s || (tflags & TF_WRITES_D && rd != Reg::zero && rd == rs)))

0 commit comments

Comments
 (0)