From 7a82cae2bd0a0163630b84f20d5d32efb296c007 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 19 Oct 2020 00:13:08 +1000 Subject: [PATCH] CPU/Recompiler: Use register pairs for pop callee saved too --- src/core/cpu_recompiler_register_cache.cpp | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/core/cpu_recompiler_register_cache.cpp b/src/core/cpu_recompiler_register_cache.cpp index 1a4a69d40..75f6e7bb9 100644 --- a/src/core/cpu_recompiler_register_cache.cpp +++ b/src/core/cpu_recompiler_register_cache.cpp @@ -356,11 +356,30 @@ u32 RegisterCache::PopCalleeSavedRegisters(bool commit) DebugAssert((m_state.host_reg_state[reg] & (HostRegState::CalleeSaved | HostRegState::CalleeSavedAllocated)) == (HostRegState::CalleeSaved | HostRegState::CalleeSavedAllocated)); - m_code_generator.EmitPopHostReg(reg, i - 1); - if (commit) - m_state.host_reg_state[reg] &= ~HostRegState::CalleeSavedAllocated; - count++; - i--; + if (i > 1) + { + const HostReg reg2 = m_state.callee_saved_order[i - 2]; + DebugAssert((m_state.host_reg_state[reg2] & (HostRegState::CalleeSaved | HostRegState::CalleeSavedAllocated)) == + (HostRegState::CalleeSaved | HostRegState::CalleeSavedAllocated)); + + m_code_generator.EmitPopHostRegPair(reg2, reg, i - 1); + i -= 2; + count += 2; + + if (commit) + { + m_state.host_reg_state[reg] &= ~HostRegState::CalleeSavedAllocated; + m_state.host_reg_state[reg2] &= ~HostRegState::CalleeSavedAllocated; + } + } + else + { + m_code_generator.EmitPopHostReg(reg, i - 1); + if (commit) + m_state.host_reg_state[reg] &= ~HostRegState::CalleeSavedAllocated; + count++; + i--; + } } while (i > 0); if (commit) m_state.callee_saved_order_count = 0;