x86emitter: Backup and restore non-volatile SSE registers

XMM6-XMM15 are non-volatile on Windows
This commit is contained in:
TheLastRar 2025-01-11 23:17:40 +00:00
parent 33b366180e
commit aeb9ed82dc
1 changed files with 18 additions and 5 deletions

View File

@ -1224,22 +1224,35 @@ const xRegister32
#ifdef _WIN32
xPUSH(rdi);
xPUSH(rsi);
xSUB(rsp, 32); // Windows calling convention specifies additional space for the callee to spill registers
m_offset += 48;
#endif
m_offset += 16;
// Align for movaps, in addition to any following instructions
stackAlign(m_offset, true);
xSUB(rsp, 16 * 10);
for (u32 i = 6; i < 16; i++)
xMOVAPS(ptr128[rsp + (i - 6) * 16], xRegisterSSE(i));
xSUB(rsp, 32); // Windows calling convention specifies additional space for the callee to spill registers
#else
// Align for any following instructions
stackAlign(m_offset, true);
#endif
}
xScopedStackFrame::~xScopedStackFrame()
{
stackAlign(m_offset, false);
// Restore the register context
#ifdef _WIN32
xADD(rsp, 32);
for (u32 i = 6; i < 16; i++)
xMOVAPS(xRegisterSSE::GetInstance(i), ptr[rsp + (i - 6) * 16]);
xADD(rsp, 16 * 10);
stackAlign(m_offset, false);
xPOP(rsi);
xPOP(rdi);
#else
stackAlign(m_offset, false);
#endif
xPOP(r15);
xPOP(r14);