mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-10 14:39:01 +01:00
JitRegCache: Use preg_t for PPC register indexes
This commit is contained in:
parent
d9e2b3ed98
commit
29d301e303
@ -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());
|
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());
|
m_emitter->MOVAPD(new_loc, m_regs[preg].Location());
|
||||||
}
|
}
|
||||||
@ -32,9 +32,9 @@ const X64Reg* FPURegCache::GetAllocationOrder(size_t* count) const
|
|||||||
return allocation_order;
|
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
|
BitSet32 FPURegCache::GetRegUtilization() const
|
||||||
@ -42,7 +42,7 @@ BitSet32 FPURegCache::GetRegUtilization() const
|
|||||||
return m_jit.js.op->gprInReg;
|
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;
|
BitSet32 regs_used;
|
||||||
|
|
||||||
|
@ -12,12 +12,12 @@ class FPURegCache final : public RegCache
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit FPURegCache(Jit64& jit);
|
explicit FPURegCache(Jit64& jit);
|
||||||
Gen::OpArg GetDefaultLocation(size_t reg) const override;
|
Gen::OpArg GetDefaultLocation(preg_t preg) const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void StoreRegister(size_t preg, const Gen::OpArg& newLoc) override;
|
void StoreRegister(preg_t preg, const Gen::OpArg& newLoc) override;
|
||||||
void LoadRegister(size_t preg, Gen::X64Reg newLoc) override;
|
void LoadRegister(preg_t preg, Gen::X64Reg newLoc) override;
|
||||||
const Gen::X64Reg* GetAllocationOrder(size_t* count) const override;
|
const Gen::X64Reg* GetAllocationOrder(size_t* count) const override;
|
||||||
BitSet32 GetRegUtilization() const override;
|
BitSet32 GetRegUtilization() const override;
|
||||||
BitSet32 CountRegsIn(size_t preg, u32 lookahead) const override;
|
BitSet32 CountRegsIn(preg_t preg, u32 lookahead) const override;
|
||||||
};
|
};
|
||||||
|
@ -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());
|
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());
|
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
|
const X64Reg* GPRRegCache::GetAllocationOrder(size_t* count) const
|
||||||
@ -46,7 +46,7 @@ const X64Reg* GPRRegCache::GetAllocationOrder(size_t* count) const
|
|||||||
return allocation_order;
|
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
|
// "dirty" can be false to avoid redundantly flushing an immediate when
|
||||||
// processing speculative constants.
|
// processing speculative constants.
|
||||||
@ -59,7 +59,7 @@ BitSet32 GPRRegCache::GetRegUtilization() const
|
|||||||
return m_jit.js.op->gprInReg;
|
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;
|
BitSet32 regs_used;
|
||||||
|
|
||||||
|
@ -12,13 +12,13 @@ class GPRRegCache final : public RegCache
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit GPRRegCache(Jit64& jit);
|
explicit GPRRegCache(Jit64& jit);
|
||||||
Gen::OpArg GetDefaultLocation(size_t reg) const override;
|
Gen::OpArg GetDefaultLocation(preg_t preg) const override;
|
||||||
void SetImmediate32(size_t preg, u32 imm_value, bool dirty = true);
|
void SetImmediate32(preg_t preg, u32 imm_value, bool dirty = true);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void StoreRegister(size_t preg, const Gen::OpArg& new_loc) override;
|
void StoreRegister(preg_t preg, const Gen::OpArg& new_loc) override;
|
||||||
void LoadRegister(size_t preg, Gen::X64Reg new_loc) override;
|
void LoadRegister(preg_t preg, Gen::X64Reg new_loc) override;
|
||||||
const Gen::X64Reg* GetAllocationOrder(size_t* count) const override;
|
const Gen::X64Reg* GetAllocationOrder(size_t* count) const override;
|
||||||
BitSet32 GetRegUtilization() const override;
|
BitSet32 GetRegUtilization() const override;
|
||||||
BitSet32 CountRegsIn(size_t preg, u32 lookahead) const override;
|
BitSet32 CountRegsIn(preg_t preg, u32 lookahead) const override;
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,7 @@ void RegCache::Start()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegCache::DiscardRegContentsIfCached(size_t preg)
|
void RegCache::DiscardRegContentsIfCached(preg_t preg)
|
||||||
{
|
{
|
||||||
if (m_regs[preg].IsBound())
|
if (m_regs[preg].IsBound())
|
||||||
{
|
{
|
||||||
@ -117,7 +117,7 @@ int RegCache::SanityCheck() const
|
|||||||
return 0;
|
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())
|
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())
|
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");
|
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;
|
bool doStore = false;
|
||||||
|
|
||||||
@ -194,12 +194,12 @@ void RegCache::StoreFromRegister(size_t i, FlushMode mode)
|
|||||||
m_regs[i].Flushed();
|
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();
|
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);
|
ASSERT_MSG(DYNA_REC, m_regs[preg].IsBound(), "Unbound register - %zu", preg);
|
||||||
return m_regs[preg].Location().GetSimpleReg();
|
return m_regs[preg].Location().GetSimpleReg();
|
||||||
@ -243,7 +243,7 @@ X64Reg RegCache::GetFreeXReg()
|
|||||||
for (size_t i = 0; i < aCount; i++)
|
for (size_t i = 0; i < aCount; i++)
|
||||||
{
|
{
|
||||||
X64Reg xreg = (X64Reg)aOrder[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())
|
if (m_xregs[xreg].IsLocked() || m_regs[preg].IsLocked())
|
||||||
continue;
|
continue;
|
||||||
float score = ScoreRegister(xreg);
|
float score = ScoreRegister(xreg);
|
||||||
@ -291,7 +291,7 @@ void RegCache::FlushX(X64Reg reg)
|
|||||||
// means more bad.
|
// means more bad.
|
||||||
float RegCache::ScoreRegister(X64Reg xreg) const
|
float RegCache::ScoreRegister(X64Reg xreg) const
|
||||||
{
|
{
|
||||||
size_t preg = m_xregs[xreg].Contents();
|
preg_t preg = m_xregs[xreg].Contents();
|
||||||
float score = 0;
|
float score = 0;
|
||||||
|
|
||||||
// If it's not dirty, we don't need a store to write it back to the register file, so
|
// If it's not dirty, we don't need a store to write it back to the register file, so
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
class Jit64;
|
class Jit64;
|
||||||
|
|
||||||
|
using preg_t = size_t;
|
||||||
|
|
||||||
class PPCCachedReg
|
class PPCCachedReg
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -87,9 +89,9 @@ private:
|
|||||||
class X64CachedReg
|
class X64CachedReg
|
||||||
{
|
{
|
||||||
public:
|
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;
|
free = false;
|
||||||
ppcReg = ppcReg_;
|
ppcReg = ppcReg_;
|
||||||
@ -98,7 +100,7 @@ public:
|
|||||||
|
|
||||||
void Flushed()
|
void Flushed()
|
||||||
{
|
{
|
||||||
ppcReg = static_cast<size_t>(Gen::INVALID_REG);
|
ppcReg = static_cast<preg_t>(Gen::INVALID_REG);
|
||||||
free = true;
|
free = true;
|
||||||
dirty = false;
|
dirty = false;
|
||||||
}
|
}
|
||||||
@ -113,7 +115,7 @@ public:
|
|||||||
void Unlock() { locked = false; }
|
void Unlock() { locked = false; }
|
||||||
|
|
||||||
private:
|
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 free = true;
|
||||||
bool dirty = false;
|
bool dirty = false;
|
||||||
bool locked = false;
|
bool locked = false;
|
||||||
@ -133,11 +135,11 @@ public:
|
|||||||
explicit RegCache(Jit64& jit);
|
explicit RegCache(Jit64& jit);
|
||||||
virtual ~RegCache() = default;
|
virtual ~RegCache() = default;
|
||||||
|
|
||||||
virtual Gen::OpArg GetDefaultLocation(size_t reg) const = 0;
|
virtual Gen::OpArg GetDefaultLocation(preg_t preg) const = 0;
|
||||||
|
|
||||||
void Start();
|
void Start();
|
||||||
|
|
||||||
void DiscardRegContentsIfCached(size_t preg);
|
void DiscardRegContentsIfCached(preg_t preg);
|
||||||
void SetEmitter(Gen::XEmitter* emitter);
|
void SetEmitter(Gen::XEmitter* emitter);
|
||||||
|
|
||||||
void Flush(FlushMode mode = FlushMode::All, BitSet32 regsToFlush = BitSet32::AllTrue(32));
|
void Flush(FlushMode mode = FlushMode::All, BitSet32 regsToFlush = BitSet32::AllTrue(32));
|
||||||
@ -146,15 +148,15 @@ public:
|
|||||||
void FlushLockX(Gen::X64Reg reg1, Gen::X64Reg reg2);
|
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(preg_t preg, bool doLoad, bool makeDirty);
|
||||||
|
|
||||||
// TODO - instead of doload, use "read", "write"
|
// TODO - instead of doload, use "read", "write"
|
||||||
// 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(preg_t preg, bool doLoad = true, bool makeDirty = true);
|
||||||
void StoreFromRegister(size_t preg, FlushMode mode = FlushMode::All);
|
void StoreFromRegister(preg_t preg, FlushMode mode = FlushMode::All);
|
||||||
|
|
||||||
const Gen::OpArg& R(size_t preg) const;
|
const Gen::OpArg& R(preg_t preg) const;
|
||||||
Gen::X64Reg RX(size_t preg) const;
|
Gen::X64Reg RX(preg_t preg) const;
|
||||||
|
|
||||||
// Register locking.
|
// Register locking.
|
||||||
|
|
||||||
@ -209,13 +211,13 @@ public:
|
|||||||
int NumFreeRegisters() const;
|
int NumFreeRegisters() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void StoreRegister(size_t preg, const Gen::OpArg& new_loc) = 0;
|
virtual void StoreRegister(preg_t preg, const Gen::OpArg& new_loc) = 0;
|
||||||
virtual void LoadRegister(size_t preg, Gen::X64Reg 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 const Gen::X64Reg* GetAllocationOrder(size_t* count) const = 0;
|
||||||
|
|
||||||
virtual BitSet32 GetRegUtilization() 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);
|
void FlushX(Gen::X64Reg reg);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user