mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 07:09:48 -06:00
Common:X64ABI: Make proper stack frames
This commit is contained in:
@ -43,11 +43,18 @@ void XEmitter::ABI_CalculateFrameSize(BitSet32 mask, size_t rsp_alignment, size_
|
||||
size_t XEmitter::ABI_PushRegistersAndAdjustStack(BitSet32 mask, size_t rsp_alignment,
|
||||
size_t needed_frame_size)
|
||||
{
|
||||
mask[RSP] = false; // Stack pointer is never pushed
|
||||
size_t shadow, subtraction, xmm_offset;
|
||||
ABI_CalculateFrameSize(mask, rsp_alignment, needed_frame_size, &shadow, &subtraction,
|
||||
&xmm_offset);
|
||||
|
||||
for (int r : mask& ABI_ALL_GPRS)
|
||||
if (mask[RBP])
|
||||
{
|
||||
// Make a nice stack frame for any debuggers or profilers that might be looking at this
|
||||
PUSH(RBP);
|
||||
MOV(64, R(RBP), R(RSP));
|
||||
}
|
||||
for (int r : mask& ABI_ALL_GPRS & ~BitSet32{RBP})
|
||||
PUSH((X64Reg)r);
|
||||
|
||||
if (subtraction)
|
||||
@ -65,6 +72,7 @@ size_t XEmitter::ABI_PushRegistersAndAdjustStack(BitSet32 mask, size_t rsp_align
|
||||
void XEmitter::ABI_PopRegistersAndAdjustStack(BitSet32 mask, size_t rsp_alignment,
|
||||
size_t needed_frame_size)
|
||||
{
|
||||
mask[RSP] = false; // Stack pointer is never pushed
|
||||
size_t shadow, subtraction, xmm_offset;
|
||||
ABI_CalculateFrameSize(mask, rsp_alignment, needed_frame_size, &shadow, &subtraction,
|
||||
&xmm_offset);
|
||||
@ -80,9 +88,12 @@ void XEmitter::ABI_PopRegistersAndAdjustStack(BitSet32 mask, size_t rsp_alignmen
|
||||
|
||||
for (int r = 15; r >= 0; r--)
|
||||
{
|
||||
if (mask[r])
|
||||
if (r != RBP && mask[r])
|
||||
POP((X64Reg)r);
|
||||
}
|
||||
// RSP is pushed first and popped last to make debuggers/profilers happy
|
||||
if (mask[RBP])
|
||||
POP(RBP);
|
||||
}
|
||||
|
||||
void XEmitter::MOVTwo(int bits, Gen::X64Reg dst1, Gen::X64Reg src1, s32 offset1, Gen::X64Reg dst2,
|
||||
|
Reference in New Issue
Block a user