JitRegCache: Move implementation details into the cpp file where applicable

Any future changes to these register cache functions won't require everything that includes the register cache header to also be recompiled.
This commit is contained in:
Lioncash 2016-12-20 22:27:22 -05:00
parent d1fc694c02
commit 41d47dda93
2 changed files with 75 additions and 42 deletions

View File

@ -69,14 +69,9 @@ void RegCache::DiscardRegContentsIfCached(size_t preg)
} }
} }
void RegCache::FlushR(X64Reg reg) void RegCache::SetEmitter(XEmitter* emitter)
{ {
if (reg >= xregs.size()) emit = emitter;
PanicAlert("Flushing non existent reg");
if (!xregs[reg].free)
{
StoreFromRegister(xregs[reg].ppcReg);
}
} }
void RegCache::Flush(FlushMode mode, BitSet32 regsToFlush) void RegCache::Flush(FlushMode mode, BitSet32 regsToFlush)
@ -108,6 +103,36 @@ void RegCache::Flush(FlushMode mode, BitSet32 regsToFlush)
} }
} }
void RegCache::FlushR(X64Reg reg)
{
if (reg >= xregs.size())
PanicAlert("Flushing non existent reg");
if (!xregs[reg].free)
{
StoreFromRegister(xregs[reg].ppcReg);
}
}
void RegCache::FlushR(X64Reg reg, X64Reg reg2)
{
FlushR(reg);
FlushR(reg2);
}
void RegCache::FlushLockX(X64Reg reg)
{
FlushR(reg);
LockX(reg);
}
void RegCache::FlushLockX(X64Reg reg1, X64Reg reg2)
{
FlushR(reg1);
FlushR(reg2);
LockX(reg1);
LockX(reg2);
}
int RegCache::SanityCheck() const int RegCache::SanityCheck() const
{ {
for (size_t i = 0; i < regs.size(); i++) for (size_t i = 0; i < regs.size(); i++)
@ -211,6 +236,20 @@ void RegCache::StoreFromRegister(size_t i, FlushMode mode)
} }
} }
const OpArg& RegCache::R(size_t preg) const
{
return regs[preg].location;
}
X64Reg RegCache::RX(size_t preg) const
{
if (IsBound(preg))
return regs[preg].location.GetSimpleReg();
PanicAlert("Unbound register - %zu", preg);
return Gen::INVALID_REG;
}
void RegCache::UnlockAll() void RegCache::UnlockAll()
{ {
for (auto& reg : regs) for (auto& reg : regs)
@ -223,6 +262,16 @@ void RegCache::UnlockAllX()
xreg.locked = false; xreg.locked = false;
} }
bool RegCache::IsFreeX(size_t xreg) const
{
return xregs[xreg].free && !xregs[xreg].locked;
}
bool RegCache::IsBound(size_t preg) const
{
return regs[preg].away && regs[preg].location.IsSimpleReg();
}
X64Reg RegCache::GetFreeXReg() X64Reg RegCache::GetFreeXReg()
{ {
size_t aCount; size_t aCount;

View File

@ -40,33 +40,26 @@ class RegCache
{ {
public: public:
RegCache(); RegCache();
virtual ~RegCache() {} virtual ~RegCache() = default;
virtual void StoreRegister(size_t preg, const Gen::OpArg& new_loc) = 0;
virtual void LoadRegister(size_t preg, Gen::X64Reg new_loc) = 0;
virtual Gen::OpArg GetDefaultLocation(size_t reg) const = 0;
void Start(); void Start();
void DiscardRegContentsIfCached(size_t preg); void DiscardRegContentsIfCached(size_t preg);
void SetEmitter(Gen::XEmitter* emitter) { emit = emitter; } void SetEmitter(Gen::XEmitter* emitter);
void FlushR(Gen::X64Reg reg);
void FlushR(Gen::X64Reg reg, Gen::X64Reg reg2)
{
FlushR(reg);
FlushR(reg2);
}
void FlushLockX(Gen::X64Reg reg)
{
FlushR(reg);
LockX(reg);
}
void FlushLockX(Gen::X64Reg reg1, Gen::X64Reg reg2)
{
FlushR(reg1);
FlushR(reg2);
LockX(reg1);
LockX(reg2);
}
void Flush(FlushMode mode = FLUSH_ALL, BitSet32 regsToFlush = BitSet32::AllTrue(32)); void Flush(FlushMode mode = FLUSH_ALL, BitSet32 regsToFlush = BitSet32::AllTrue(32));
void Flush(PPCAnalyst::CodeOp* op) { Flush(); } void Flush(PPCAnalyst::CodeOp* op) { Flush(); }
void FlushR(Gen::X64Reg reg);
void FlushR(Gen::X64Reg reg, Gen::X64Reg reg2);
void FlushLockX(Gen::X64Reg reg);
void FlushLockX(Gen::X64Reg reg1, Gen::X64Reg reg2);
int SanityCheck() const; int SanityCheck() const;
void KillImmediate(size_t preg, bool doLoad, bool makeDirty); void KillImmediate(size_t preg, bool doLoad, bool makeDirty);
@ -74,19 +67,9 @@ public:
// read only will not set dirty flag // read only will not set dirty flag
void BindToRegister(size_t preg, bool doLoad = true, bool makeDirty = true); void BindToRegister(size_t preg, bool doLoad = true, bool makeDirty = true);
void StoreFromRegister(size_t preg, FlushMode mode = FLUSH_ALL); void StoreFromRegister(size_t preg, FlushMode mode = FLUSH_ALL);
virtual void StoreRegister(size_t preg, const Gen::OpArg& newLoc) = 0;
virtual void LoadRegister(size_t preg, Gen::X64Reg newLoc) = 0;
const Gen::OpArg& R(size_t preg) const { return regs[preg].location; } const Gen::OpArg& R(size_t preg) const;
Gen::X64Reg RX(size_t preg) const Gen::X64Reg RX(size_t preg) const;
{
if (IsBound(preg))
return regs[preg].location.GetSimpleReg();
PanicAlert("Unbound register - %zu", preg);
return Gen::INVALID_REG;
}
virtual Gen::OpArg GetDefaultLocation(size_t reg) const = 0;
// Register locking. // Register locking.
@ -135,8 +118,9 @@ public:
void UnlockAll(); void UnlockAll();
void UnlockAllX(); void UnlockAllX();
bool IsFreeX(size_t xreg) const { return xregs[xreg].free && !xregs[xreg].locked; } bool IsFreeX(size_t xreg) const;
bool IsBound(size_t preg) const { return regs[preg].away && regs[preg].location.IsSimpleReg(); } bool IsBound(size_t preg) const;
Gen::X64Reg GetFreeXReg(); Gen::X64Reg GetFreeXReg();
int NumFreeRegisters(); int NumFreeRegisters();