JitRegCache: Use preg_t for PPC register indexes

This commit is contained in:
MerryMage 2018-10-05 21:17:36 +01:00
parent d9e2b3ed98
commit 29d301e303
6 changed files with 44 additions and 42 deletions

View File

@ -14,12 +14,12 @@ FPURegCache::FPURegCache(Jit64& jit) : RegCache{jit}
{
}
void FPURegCache::StoreRegister(size_t preg, const OpArg& new_loc)
void FPURegCache::StoreRegister(preg_t preg, const OpArg& new_loc)
{
m_emitter->MOVAPD(new_loc, m_regs[preg].Location().GetSimpleReg());
}
void FPURegCache::LoadRegister(size_t preg, X64Reg new_loc)
void FPURegCache::LoadRegister(preg_t preg, X64Reg new_loc)
{
m_emitter->MOVAPD(new_loc, m_regs[preg].Location());
}
@ -32,9 +32,9 @@ const X64Reg* FPURegCache::GetAllocationOrder(size_t* count) const
return allocation_order;
}
OpArg FPURegCache::GetDefaultLocation(size_t reg) const
OpArg FPURegCache::GetDefaultLocation(preg_t preg) const
{
return PPCSTATE(ps[reg][0]);
return PPCSTATE(ps[preg][0]);
}
BitSet32 FPURegCache::GetRegUtilization() const
@ -42,7 +42,7 @@ BitSet32 FPURegCache::GetRegUtilization() const
return m_jit.js.op->gprInReg;
}
BitSet32 FPURegCache::CountRegsIn(size_t preg, u32 lookahead) const
BitSet32 FPURegCache::CountRegsIn(preg_t preg, u32 lookahead) const
{
BitSet32 regs_used;

View File

@ -12,12 +12,12 @@ class FPURegCache final : public RegCache
{
public:
explicit FPURegCache(Jit64& jit);
Gen::OpArg GetDefaultLocation(size_t reg) const override;
Gen::OpArg GetDefaultLocation(preg_t preg) const override;
protected:
void StoreRegister(size_t preg, const Gen::OpArg& newLoc) override;
void LoadRegister(size_t preg, Gen::X64Reg newLoc) override;
void StoreRegister(preg_t preg, const Gen::OpArg& newLoc) override;
void LoadRegister(preg_t preg, Gen::X64Reg newLoc) override;
const Gen::X64Reg* GetAllocationOrder(size_t* count) const override;
BitSet32 GetRegUtilization() const override;
BitSet32 CountRegsIn(size_t preg, u32 lookahead) const override;
BitSet32 CountRegsIn(preg_t preg, u32 lookahead) const override;
};

View File

@ -14,19 +14,19 @@ GPRRegCache::GPRRegCache(Jit64& jit) : RegCache{jit}
{
}
void GPRRegCache::StoreRegister(size_t preg, const OpArg& new_loc)
void GPRRegCache::StoreRegister(preg_t preg, const OpArg& new_loc)
{
m_emitter->MOV(32, new_loc, m_regs[preg].Location());
}
void GPRRegCache::LoadRegister(size_t preg, X64Reg new_loc)
void GPRRegCache::LoadRegister(preg_t preg, X64Reg new_loc)
{
m_emitter->MOV(32, ::Gen::R(new_loc), m_regs[preg].Location());
}
OpArg GPRRegCache::GetDefaultLocation(size_t reg) const
OpArg GPRRegCache::GetDefaultLocation(preg_t preg) const
{
return PPCSTATE(gpr[reg]);
return PPCSTATE(gpr[preg]);
}
const X64Reg* GPRRegCache::GetAllocationOrder(size_t* count) const
@ -46,7 +46,7 @@ const X64Reg* GPRRegCache::GetAllocationOrder(size_t* count) const
return allocation_order;
}
void GPRRegCache::SetImmediate32(size_t preg, u32 imm_value, bool dirty)
void GPRRegCache::SetImmediate32(preg_t preg, u32 imm_value, bool dirty)
{
// "dirty" can be false to avoid redundantly flushing an immediate when
// processing speculative constants.
@ -59,7 +59,7 @@ BitSet32 GPRRegCache::GetRegUtilization() const
return m_jit.js.op->gprInReg;
}
BitSet32 GPRRegCache::CountRegsIn(size_t preg, u32 lookahead) const
BitSet32 GPRRegCache::CountRegsIn(preg_t preg, u32 lookahead) const
{
BitSet32 regs_used;

View File

@ -12,13 +12,13 @@ class GPRRegCache final : public RegCache
{
public:
explicit GPRRegCache(Jit64& jit);
Gen::OpArg GetDefaultLocation(size_t reg) const override;
void SetImmediate32(size_t preg, u32 imm_value, bool dirty = true);
Gen::OpArg GetDefaultLocation(preg_t preg) const override;
void SetImmediate32(preg_t preg, u32 imm_value, bool dirty = true);
protected:
void StoreRegister(size_t preg, const Gen::OpArg& new_loc) override;
void LoadRegister(size_t preg, Gen::X64Reg new_loc) override;
void StoreRegister(preg_t preg, const Gen::OpArg& new_loc) override;
void LoadRegister(preg_t preg, Gen::X64Reg new_loc) override;
const Gen::X64Reg* GetAllocationOrder(size_t* count) const override;
BitSet32 GetRegUtilization() const override;
BitSet32 CountRegsIn(size_t preg, u32 lookahead) const override;
BitSet32 CountRegsIn(preg_t preg, u32 lookahead) const override;
};

View File

@ -33,7 +33,7 @@ void RegCache::Start()
}
}
void RegCache::DiscardRegContentsIfCached(size_t preg)
void RegCache::DiscardRegContentsIfCached(preg_t preg)
{
if (m_regs[preg].IsBound())
{
@ -117,7 +117,7 @@ int RegCache::SanityCheck() const
return 0;
}
void RegCache::KillImmediate(size_t preg, bool doLoad, bool makeDirty)
void RegCache::KillImmediate(preg_t preg, bool doLoad, bool makeDirty)
{
switch (m_regs[preg].GetLocationType())
{
@ -133,7 +133,7 @@ void RegCache::KillImmediate(size_t preg, bool doLoad, bool makeDirty)
}
}
void RegCache::BindToRegister(size_t i, bool doLoad, bool makeDirty)
void RegCache::BindToRegister(preg_t i, bool doLoad, bool makeDirty)
{
if (!m_regs[i].IsBound())
{
@ -166,7 +166,7 @@ void RegCache::BindToRegister(size_t i, bool doLoad, bool makeDirty)
ASSERT_MSG(DYNA_REC, !m_xregs[RX(i)].IsLocked(), "WTF, this reg should have been flushed");
}
void RegCache::StoreFromRegister(size_t i, FlushMode mode)
void RegCache::StoreFromRegister(preg_t i, FlushMode mode)
{
bool doStore = false;
@ -194,12 +194,12 @@ void RegCache::StoreFromRegister(size_t i, FlushMode mode)
m_regs[i].Flushed();
}
const OpArg& RegCache::R(size_t preg) const
const OpArg& RegCache::R(preg_t preg) const
{
return m_regs[preg].Location();
}
X64Reg RegCache::RX(size_t preg) const
X64Reg RegCache::RX(preg_t preg) const
{
ASSERT_MSG(DYNA_REC, m_regs[preg].IsBound(), "Unbound register - %zu", preg);
return m_regs[preg].Location().GetSimpleReg();
@ -243,7 +243,7 @@ X64Reg RegCache::GetFreeXReg()
for (size_t i = 0; i < aCount; i++)
{
X64Reg xreg = (X64Reg)aOrder[i];
size_t preg = m_xregs[xreg].Contents();
preg_t preg = m_xregs[xreg].Contents();
if (m_xregs[xreg].IsLocked() || m_regs[preg].IsLocked())
continue;
float score = ScoreRegister(xreg);
@ -291,7 +291,7 @@ void RegCache::FlushX(X64Reg reg)
// means more bad.
float RegCache::ScoreRegister(X64Reg xreg) const
{
size_t preg = m_xregs[xreg].Contents();
preg_t preg = m_xregs[xreg].Contents();
float score = 0;
// If it's not dirty, we don't need a store to write it back to the register file, so

View File

@ -13,6 +13,8 @@
class Jit64;
using preg_t = size_t;
class PPCCachedReg
{
public:
@ -87,9 +89,9 @@ private:
class X64CachedReg
{
public:
size_t Contents() const { return ppcReg; }
preg_t Contents() const { return ppcReg; }
void BoundTo(size_t ppcReg_, bool dirty_)
void BoundTo(preg_t ppcReg_, bool dirty_)
{
free = false;
ppcReg = ppcReg_;
@ -98,7 +100,7 @@ public:
void Flushed()
{
ppcReg = static_cast<size_t>(Gen::INVALID_REG);
ppcReg = static_cast<preg_t>(Gen::INVALID_REG);
free = true;
dirty = false;
}
@ -113,7 +115,7 @@ public:
void Unlock() { locked = false; }
private:
size_t ppcReg = static_cast<size_t>(Gen::INVALID_REG);
preg_t ppcReg = static_cast<preg_t>(Gen::INVALID_REG);
bool free = true;
bool dirty = false;
bool locked = false;
@ -133,11 +135,11 @@ public:
explicit RegCache(Jit64& jit);
virtual ~RegCache() = default;
virtual Gen::OpArg GetDefaultLocation(size_t reg) const = 0;
virtual Gen::OpArg GetDefaultLocation(preg_t preg) const = 0;
void Start();
void DiscardRegContentsIfCached(size_t preg);
void DiscardRegContentsIfCached(preg_t preg);
void SetEmitter(Gen::XEmitter* emitter);
void Flush(FlushMode mode = FlushMode::All, BitSet32 regsToFlush = BitSet32::AllTrue(32));
@ -146,15 +148,15 @@ public:
void FlushLockX(Gen::X64Reg reg1, Gen::X64Reg reg2);
int SanityCheck() const;
void KillImmediate(size_t preg, bool doLoad, bool makeDirty);
void KillImmediate(preg_t preg, bool doLoad, bool makeDirty);
// TODO - instead of doload, use "read", "write"
// read only will not set dirty flag
void BindToRegister(size_t preg, bool doLoad = true, bool makeDirty = true);
void StoreFromRegister(size_t preg, FlushMode mode = FlushMode::All);
void BindToRegister(preg_t preg, bool doLoad = true, bool makeDirty = true);
void StoreFromRegister(preg_t preg, FlushMode mode = FlushMode::All);
const Gen::OpArg& R(size_t preg) const;
Gen::X64Reg RX(size_t preg) const;
const Gen::OpArg& R(preg_t preg) const;
Gen::X64Reg RX(preg_t preg) const;
// Register locking.
@ -209,13 +211,13 @@ public:
int NumFreeRegisters() const;
protected:
virtual void StoreRegister(size_t preg, const Gen::OpArg& new_loc) = 0;
virtual void LoadRegister(size_t preg, Gen::X64Reg new_loc) = 0;
virtual void StoreRegister(preg_t preg, const Gen::OpArg& new_loc) = 0;
virtual void LoadRegister(preg_t preg, Gen::X64Reg new_loc) = 0;
virtual const Gen::X64Reg* GetAllocationOrder(size_t* count) const = 0;
virtual BitSet32 GetRegUtilization() const = 0;
virtual BitSet32 CountRegsIn(size_t preg, u32 lookahead) const = 0;
virtual BitSet32 CountRegsIn(preg_t preg, u32 lookahead) const = 0;
void FlushX(Gen::X64Reg reg);