Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x86emitter: Backup and restore non-volatile SSE registers #12183

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions common/emitter/x86emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading