mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
JitRegCache: Get rid of reliance on the jit global variable
This commit is contained in:
parent
8ece485a2f
commit
407f3af8c3
@ -4,11 +4,16 @@
|
||||
|
||||
#include "Core/PowerPC/Jit64/FPURegCache.h"
|
||||
|
||||
#include "Core/PowerPC/Jit64/Jit.h"
|
||||
#include "Core/PowerPC/Jit64Common/Jit64Base.h"
|
||||
#include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h"
|
||||
|
||||
using namespace Gen;
|
||||
|
||||
FPURegCache::FPURegCache(Jit64& jit) : RegCache{jit}
|
||||
{
|
||||
}
|
||||
|
||||
void FPURegCache::StoreRegister(size_t preg, const OpArg& new_loc)
|
||||
{
|
||||
m_emitter->MOVAPD(new_loc, m_regs[preg].location.GetSimpleReg());
|
||||
@ -34,7 +39,7 @@ OpArg FPURegCache::GetDefaultLocation(size_t reg) const
|
||||
|
||||
BitSet32 FPURegCache::GetRegUtilization()
|
||||
{
|
||||
return jit->js.op->gprInReg;
|
||||
return m_jit.js.op->gprInReg;
|
||||
}
|
||||
|
||||
BitSet32 FPURegCache::CountRegsIn(size_t preg, u32 lookahead)
|
||||
@ -43,7 +48,7 @@ BitSet32 FPURegCache::CountRegsIn(size_t preg, u32 lookahead)
|
||||
|
||||
for (u32 i = 1; i < lookahead; i++)
|
||||
{
|
||||
BitSet32 regs_in = jit->js.op[i].fregsIn;
|
||||
BitSet32 regs_in = m_jit.js.op[i].fregsIn;
|
||||
regs_used |= regs_in;
|
||||
if (regs_in[preg])
|
||||
return regs_used;
|
||||
|
@ -6,9 +6,13 @@
|
||||
|
||||
#include "Core/PowerPC/Jit64/JitRegCache.h"
|
||||
|
||||
class Jit64;
|
||||
|
||||
class FPURegCache final : public RegCache
|
||||
{
|
||||
public:
|
||||
explicit FPURegCache(Jit64& jit);
|
||||
|
||||
void StoreRegister(size_t preg, const Gen::OpArg& newLoc) override;
|
||||
void LoadRegister(size_t preg, Gen::X64Reg newLoc) override;
|
||||
const Gen::X64Reg* GetAllocationOrder(size_t* count) override;
|
||||
|
@ -4,11 +4,16 @@
|
||||
|
||||
#include "Core/PowerPC/Jit64/GPRRegCache.h"
|
||||
|
||||
#include "Core/PowerPC/Jit64/Jit.h"
|
||||
#include "Core/PowerPC/Jit64Common/Jit64Base.h"
|
||||
#include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h"
|
||||
|
||||
using namespace Gen;
|
||||
|
||||
GPRRegCache::GPRRegCache(Jit64& jit) : RegCache{jit}
|
||||
{
|
||||
}
|
||||
|
||||
void GPRRegCache::StoreRegister(size_t preg, const OpArg& new_loc)
|
||||
{
|
||||
m_emitter->MOV(32, new_loc, m_regs[preg].location);
|
||||
@ -52,7 +57,7 @@ void GPRRegCache::SetImmediate32(size_t preg, u32 imm_value, bool dirty)
|
||||
|
||||
BitSet32 GPRRegCache::GetRegUtilization()
|
||||
{
|
||||
return jit->js.op->gprInReg;
|
||||
return m_jit.js.op->gprInReg;
|
||||
}
|
||||
|
||||
BitSet32 GPRRegCache::CountRegsIn(size_t preg, u32 lookahead)
|
||||
@ -61,7 +66,7 @@ BitSet32 GPRRegCache::CountRegsIn(size_t preg, u32 lookahead)
|
||||
|
||||
for (u32 i = 1; i < lookahead; i++)
|
||||
{
|
||||
BitSet32 regs_in = jit->js.op[i].regsIn;
|
||||
BitSet32 regs_in = m_jit.js.op[i].regsIn;
|
||||
regs_used |= regs_in;
|
||||
if (regs_in[preg])
|
||||
return regs_used;
|
||||
|
@ -6,9 +6,13 @@
|
||||
|
||||
#include "Core/PowerPC/Jit64/JitRegCache.h"
|
||||
|
||||
class Jit64;
|
||||
|
||||
class GPRRegCache final : public RegCache
|
||||
{
|
||||
public:
|
||||
explicit GPRRegCache(Jit64& jit);
|
||||
|
||||
void StoreRegister(size_t preg, const Gen::OpArg& new_loc) override;
|
||||
void LoadRegister(size_t preg, Gen::X64Reg new_loc) override;
|
||||
Gen::OpArg GetDefaultLocation(size_t reg) const override;
|
||||
|
@ -35,8 +35,8 @@ private:
|
||||
void AllocStack();
|
||||
void FreeStack();
|
||||
|
||||
GPRRegCache gpr;
|
||||
FPURegCache fpr;
|
||||
GPRRegCache gpr{*this};
|
||||
FPURegCache fpr{*this};
|
||||
|
||||
// The default code buffer. We keep it around to not have to alloc/dealloc a
|
||||
// large chunk of memory for each recompiled block.
|
||||
|
@ -19,7 +19,7 @@
|
||||
using namespace Gen;
|
||||
using namespace PowerPC;
|
||||
|
||||
RegCache::RegCache()
|
||||
RegCache::RegCache(Jit64& jit) : m_jit{jit}
|
||||
{
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ float RegCache::ScoreRegister(X64Reg xr)
|
||||
// Don't look too far ahead; we don't want to have quadratic compilation times for
|
||||
// enormous block sizes!
|
||||
// This actually improves register allocation a tiny bit; I'm not sure why.
|
||||
u32 lookahead = std::min(jit->js.instructionsLeft, 64);
|
||||
u32 lookahead = std::min(m_jit.js.instructionsLeft, 64);
|
||||
// Count how many other registers are going to be used before we need this one again.
|
||||
u32 regs_in_count = CountRegsIn(preg, lookahead).Count();
|
||||
// Totally ad-hoc heuristic to bias based on how many other registers we'll need
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "Common/x64Emitter.h"
|
||||
#include "Core/PowerPC/PPCAnalyst.h"
|
||||
|
||||
class Jit64;
|
||||
|
||||
enum FlushMode
|
||||
{
|
||||
FLUSH_ALL,
|
||||
@ -36,7 +38,7 @@ class RegCache
|
||||
public:
|
||||
static constexpr size_t NUM_XREGS = 16;
|
||||
|
||||
RegCache();
|
||||
explicit RegCache(Jit64& jit);
|
||||
virtual ~RegCache() = default;
|
||||
|
||||
virtual void StoreRegister(size_t preg, const Gen::OpArg& new_loc) = 0;
|
||||
@ -128,6 +130,7 @@ protected:
|
||||
|
||||
float ScoreRegister(Gen::X64Reg xreg);
|
||||
|
||||
Jit64& m_jit;
|
||||
std::array<PPCCachedReg, 32> m_regs;
|
||||
std::array<X64CachedReg, NUM_XREGS> m_xregs;
|
||||
Gen::XEmitter* m_emitter = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user