CPU/NewRec: Clear needed on swapped delay slot

Fixes panic in BIOS on x86_64 Linux with PGXP enabled.
This commit is contained in:
Stenzek 2024-05-19 23:45:27 +10:00
parent 5b4f74122c
commit 09b43f962a
No known key found for this signature in database

View file

@ -1358,6 +1358,9 @@ void CPU::NewRec::Compiler::CompileBranchDelaySlot(bool dirty_pc /* = true */)
// Update load delay at the end of the previous instruction. // Update load delay at the end of the previous instruction.
UpdateLoadDelay(); UpdateLoadDelay();
// Don't need the branch instruction's inputs.
ClearHostRegsNeeded();
// TODO: Move cycle add before this. // TODO: Move cycle add before this.
inst++; inst++;
iinfo++; iinfo++;
@ -1500,7 +1503,18 @@ void CPU::NewRec::Compiler::CompileTemplate(void (Compiler::*const_func)(Compile
UpdateHostRegCounters(); UpdateHostRegCounters();
if (tflags & TF_CAN_SWAP_DELAY_SLOT && TrySwapDelaySlot(cf.MipsS(), cf.MipsT())) if (tflags & TF_CAN_SWAP_DELAY_SLOT && TrySwapDelaySlot(cf.MipsS(), cf.MipsT()))
{
// CompileBranchDelaySlot() clears needed, so need to reset.
cf.delay_slot_swapped = true; cf.delay_slot_swapped = true;
if (tflags & TF_READS_S)
MarkRegsNeeded(HR_TYPE_CPU_REG, rs);
if (tflags & TF_READS_T)
MarkRegsNeeded(HR_TYPE_CPU_REG, rt);
if (tflags & TF_READS_LO)
MarkRegsNeeded(HR_TYPE_CPU_REG, Reg::lo);
if (tflags & TF_READS_HI)
MarkRegsNeeded(HR_TYPE_CPU_REG, Reg::hi);
}
if (tflags & TF_READS_S && if (tflags & TF_READS_S &&
(tflags & TF_NEEDS_REG_S || !cf.const_s || (tflags & TF_WRITES_D && rd != Reg::zero && rd == rs))) (tflags & TF_NEEDS_REG_S || !cf.const_s || (tflags & TF_WRITES_D && rd != Reg::zero && rd == rs)))