Jit_SystemRegisters: Make mfspr PIE-compliant
This commit is contained in:
parent
38917a151d
commit
19eb09b086
|
@ -282,18 +282,21 @@ void Jit64::mfspr(UGeckoInstruction inst)
|
||||||
// no register choice
|
// no register choice
|
||||||
|
|
||||||
gpr.FlushLockX(RDX, RAX);
|
gpr.FlushLockX(RDX, RAX);
|
||||||
|
gpr.FlushLockX(RCX);
|
||||||
|
|
||||||
|
MOV(64, R(RCX), ImmPtr(&CoreTiming::g));
|
||||||
|
|
||||||
// An inline implementation of CoreTiming::GetFakeTimeBase, since in timer-heavy games the
|
// An inline implementation of CoreTiming::GetFakeTimeBase, since in timer-heavy games the
|
||||||
// cost of calling out to C for this is actually significant.
|
// cost of calling out to C for this is actually significant.
|
||||||
// Scale downcount by the CPU overclocking factor.
|
// Scale downcount by the CPU overclocking factor.
|
||||||
CVTSI2SS(XMM0, PPCSTATE(downcount));
|
CVTSI2SS(XMM0, PPCSTATE(downcount));
|
||||||
MULSS(XMM0, M(&CoreTiming::g_last_OC_factor_inverted));
|
MULSS(XMM0, MDisp(RCX, offsetof(CoreTiming::Globals, last_OC_factor_inverted)));
|
||||||
CVTSS2SI(RDX, R(XMM0)); // RDX is downcount scaled by the overclocking factor
|
CVTSS2SI(RDX, R(XMM0)); // RDX is downcount scaled by the overclocking factor
|
||||||
MOV(32, R(RAX), M(&CoreTiming::g_slice_length));
|
MOV(32, R(RAX), MDisp(RCX, offsetof(CoreTiming::Globals, slice_length)));
|
||||||
SUB(64, R(RAX), R(RDX)); // cycles since the last CoreTiming::Advance() event is (slicelength -
|
SUB(64, R(RAX), R(RDX)); // cycles since the last CoreTiming::Advance() event is (slicelength -
|
||||||
// Scaled_downcount)
|
// Scaled_downcount)
|
||||||
ADD(64, R(RAX), M(&CoreTiming::g_global_timer));
|
ADD(64, R(RAX), MDisp(RCX, offsetof(CoreTiming::Globals, global_timer)));
|
||||||
SUB(64, R(RAX), M(&CoreTiming::g_fake_TB_start_ticks));
|
SUB(64, R(RAX), MDisp(RCX, offsetof(CoreTiming::Globals, fake_TB_start_ticks)));
|
||||||
// It might seem convenient to correct the timer for the block position here for even more
|
// It might seem convenient to correct the timer for the block position here for even more
|
||||||
// accurate
|
// accurate
|
||||||
// timing, but as of currently, this can break games. If we end up reading a time *after* the
|
// timing, but as of currently, this can break games. If we end up reading a time *after* the
|
||||||
|
@ -309,7 +312,7 @@ void Jit64::mfspr(UGeckoInstruction inst)
|
||||||
// a / 12 = (a * 0xAAAAAAAAAAAAAAAB) >> 67
|
// a / 12 = (a * 0xAAAAAAAAAAAAAAAB) >> 67
|
||||||
MOV(64, R(RDX), Imm64(0xAAAAAAAAAAAAAAABULL));
|
MOV(64, R(RDX), Imm64(0xAAAAAAAAAAAAAAABULL));
|
||||||
MUL(64, R(RDX));
|
MUL(64, R(RDX));
|
||||||
MOV(64, R(RAX), M(&CoreTiming::g_fake_TB_start_value));
|
MOV(64, R(RAX), MDisp(RCX, offsetof(CoreTiming::Globals, fake_TB_start_value)));
|
||||||
SHR(64, R(RDX), Imm8(3));
|
SHR(64, R(RDX), Imm8(3));
|
||||||
ADD(64, R(RAX), R(RDX));
|
ADD(64, R(RAX), R(RDX));
|
||||||
MOV(64, PPCSTATE(spr[SPR_TL]), R(RAX));
|
MOV(64, PPCSTATE(spr[SPR_TL]), R(RAX));
|
||||||
|
|
Loading…
Reference in New Issue