CPU/NewRec: Fix register corruption in swl/swr
This commit is contained in:
@ -2071,7 +2071,13 @@ void CPU::NewRec::RISCV64Compiler::Compile_swx(CompileFlags cf, MemoryAccessSize
|
||||
{
|
||||
DebugAssert(size == MemoryAccessSize::Word && !sign);
|
||||
|
||||
// TODO: this can take over rt's value if it's no longer needed
|
||||
// NOTE: can't trust T in cf because of the alloc
|
||||
const GPR addr = GPR(AllocateTempHostReg(HR_CALLEE_SAVED));
|
||||
const GPR value = g_settings.gpu_pgxp_enable ? GPR(AllocateTempHostReg(HR_CALLEE_SAVED)) : RARG2;
|
||||
if (g_settings.gpu_pgxp_enable)
|
||||
MoveMIPSRegToReg(value, inst->r.rt);
|
||||
|
||||
FlushForLoadStore(address, true, use_fastmem);
|
||||
|
||||
// TODO: if address is constant, this can be simplified..
|
||||
@ -2080,20 +2086,13 @@ void CPU::NewRec::RISCV64Compiler::Compile_swx(CompileFlags cf, MemoryAccessSize
|
||||
rvAsm->ANDI(RARG1, addr, ~0x3u);
|
||||
GenerateLoad(RARG1, MemoryAccessSize::Word, false, use_fastmem, []() { return RRET; });
|
||||
|
||||
// TODO: this can take over rt's value if it's no longer needed
|
||||
// NOTE: can't trust T in cf because of the flush
|
||||
const Reg rt = inst->r.rt;
|
||||
const GPR value = g_settings.gpu_pgxp_enable ? GPR(AllocateTempHostReg(HR_CALLEE_SAVED)) : RARG2;
|
||||
MoveMIPSRegToReg(value, rt);
|
||||
|
||||
rvAsm->ANDI(RSCRATCH, addr, 3);
|
||||
rvAsm->SLLIW(RSCRATCH, RSCRATCH, 3); // *8
|
||||
rvAsm->ANDI(addr, addr, ~0x3u);
|
||||
|
||||
// Don't need the original address anymore.
|
||||
// Need to load down here for PGXP-off, because it's in a volatile reg that can get overwritten by flush.
|
||||
if (!g_settings.gpu_pgxp_enable)
|
||||
FreeHostReg(addr.Index());
|
||||
else
|
||||
rvAsm->ANDI(addr, addr, ~0x3u);
|
||||
MoveMIPSRegToReg(value, inst->r.rt);
|
||||
|
||||
if (inst->op == InstructionOp::swl)
|
||||
{
|
||||
@ -2122,12 +2121,15 @@ void CPU::NewRec::RISCV64Compiler::Compile_swx(CompileFlags cf, MemoryAccessSize
|
||||
rvAsm->OR(value, value, RRET);
|
||||
}
|
||||
|
||||
FreeHostReg(addr.Index());
|
||||
|
||||
GenerateStore(addr, value, MemoryAccessSize::Word, use_fastmem);
|
||||
|
||||
if (g_settings.gpu_pgxp_enable)
|
||||
if (!g_settings.gpu_pgxp_enable)
|
||||
{
|
||||
GenerateStore(addr, value, MemoryAccessSize::Word, use_fastmem);
|
||||
FreeHostReg(addr.Index());
|
||||
}
|
||||
else
|
||||
{
|
||||
GenerateStore(addr, value, MemoryAccessSize::Word, use_fastmem);
|
||||
|
||||
Flush(FLUSH_FOR_C_CALL);
|
||||
rvAsm->MV(RARG3, value);
|
||||
FreeHostReg(value.Index());
|
||||
|
||||
Reference in New Issue
Block a user