JitArm64_RegCache: Mark several member functions as const
Many of these don't modify member state, so they can be marked as const.
This commit is contained in:
parent
e9aaa46c2f
commit
4ff597cf21
|
@ -27,7 +27,7 @@ void Arm64RegCache::Init(ARM64XEmitter* emitter)
|
|||
ARM64Reg Arm64RegCache::GetReg()
|
||||
{
|
||||
// If we have no registers left, dump the most stale register first
|
||||
if (!GetUnlockedRegisterCount())
|
||||
if (GetUnlockedRegisterCount() == 0)
|
||||
FlushMostStaleRegister();
|
||||
|
||||
for (auto& it : m_host_registers)
|
||||
|
@ -45,12 +45,14 @@ ARM64Reg Arm64RegCache::GetReg()
|
|||
return INVALID_REG;
|
||||
}
|
||||
|
||||
u32 Arm64RegCache::GetUnlockedRegisterCount()
|
||||
u32 Arm64RegCache::GetUnlockedRegisterCount() const
|
||||
{
|
||||
u32 unlocked_registers = 0;
|
||||
for (auto& it : m_host_registers)
|
||||
for (const auto& it : m_host_registers)
|
||||
{
|
||||
if (!it.IsLocked())
|
||||
++unlocked_registers;
|
||||
}
|
||||
return unlocked_registers;
|
||||
}
|
||||
|
||||
|
@ -105,7 +107,7 @@ void Arm64GPRCache::Start(PPCAnalyst::BlockRegStats& stats)
|
|||
{
|
||||
}
|
||||
|
||||
bool Arm64GPRCache::IsCalleeSaved(ARM64Reg reg)
|
||||
bool Arm64GPRCache::IsCalleeSaved(ARM64Reg reg) const
|
||||
{
|
||||
static constexpr std::array<ARM64Reg, 11> callee_regs{{
|
||||
X28,
|
||||
|
@ -351,12 +353,14 @@ void Arm64GPRCache::GetAllocationOrder()
|
|||
m_host_registers.push_back(HostReg(reg));
|
||||
}
|
||||
|
||||
BitSet32 Arm64GPRCache::GetCallerSavedUsed()
|
||||
BitSet32 Arm64GPRCache::GetCallerSavedUsed() const
|
||||
{
|
||||
BitSet32 registers(0);
|
||||
for (auto& it : m_host_registers)
|
||||
for (const auto& it : m_host_registers)
|
||||
{
|
||||
if (it.IsLocked() && !IsCalleeSaved(it.GetReg()))
|
||||
registers[DecodeReg(it.GetReg())] = 1;
|
||||
registers[DecodeReg(it.GetReg())] = true;
|
||||
}
|
||||
return registers;
|
||||
}
|
||||
|
||||
|
@ -622,7 +626,7 @@ void Arm64FPRCache::FlushByHost(ARM64Reg host_reg)
|
|||
}
|
||||
}
|
||||
|
||||
bool Arm64FPRCache::IsCalleeSaved(ARM64Reg reg)
|
||||
bool Arm64FPRCache::IsCalleeSaved(ARM64Reg reg) const
|
||||
{
|
||||
static constexpr std::array<ARM64Reg, 9> callee_regs{{
|
||||
Q8,
|
||||
|
@ -710,18 +714,20 @@ void Arm64FPRCache::FlushRegisters(BitSet32 regs, bool maintain_state)
|
|||
FlushRegister(j, maintain_state);
|
||||
}
|
||||
|
||||
BitSet32 Arm64FPRCache::GetCallerSavedUsed()
|
||||
BitSet32 Arm64FPRCache::GetCallerSavedUsed() const
|
||||
{
|
||||
BitSet32 registers(0);
|
||||
for (auto& it : m_host_registers)
|
||||
for (const auto& it : m_host_registers)
|
||||
{
|
||||
if (it.IsLocked())
|
||||
registers[it.GetReg() - Q0] = 1;
|
||||
registers[it.GetReg() - Q0] = true;
|
||||
}
|
||||
return registers;
|
||||
}
|
||||
|
||||
bool Arm64FPRCache::IsSingle(size_t preg, bool lower_only)
|
||||
bool Arm64FPRCache::IsSingle(size_t preg, bool lower_only) const
|
||||
{
|
||||
RegType type = m_guest_registers[preg].GetType();
|
||||
const RegType type = m_guest_registers[preg].GetType();
|
||||
return type == REG_REG_SINGLE || type == REG_DUP_SINGLE ||
|
||||
(lower_only && type == REG_LOWER_PAIR_SINGLE);
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ public:
|
|||
// Flushes the register cache in different ways depending on the mode
|
||||
virtual void Flush(FlushMode mode, PPCAnalyst::CodeOp* op) = 0;
|
||||
|
||||
virtual BitSet32 GetCallerSavedUsed() = 0;
|
||||
virtual BitSet32 GetCallerSavedUsed() const = 0;
|
||||
|
||||
// Returns a temporary register for use
|
||||
// Requires unlocking after done
|
||||
|
@ -183,7 +183,7 @@ protected:
|
|||
virtual void FlushRegister(size_t preg, bool maintain_state) = 0;
|
||||
|
||||
// Get available host registers
|
||||
u32 GetUnlockedRegisterCount();
|
||||
u32 GetUnlockedRegisterCount() const;
|
||||
|
||||
void IncrementAllUsed()
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ public:
|
|||
void BindToRegister(size_t preg, bool do_load) { BindToRegister(GetGuestGPR(preg), do_load); }
|
||||
// Binds a guest CR to a host register, optionally loading its value
|
||||
void BindCRToRegister(size_t preg, bool do_load) { BindToRegister(GetGuestCR(preg), do_load); }
|
||||
BitSet32 GetCallerSavedUsed() override;
|
||||
BitSet32 GetCallerSavedUsed() const override;
|
||||
|
||||
void StoreRegisters(BitSet32 regs) { FlushRegisters(regs, false); }
|
||||
void StoreCRRegisters(BitSet32 regs) { FlushCRRegisters(regs, false); }
|
||||
|
@ -249,7 +249,7 @@ protected:
|
|||
void FlushRegister(size_t index, bool maintain_state) override;
|
||||
|
||||
private:
|
||||
bool IsCalleeSaved(Arm64Gen::ARM64Reg reg);
|
||||
bool IsCalleeSaved(Arm64Gen::ARM64Reg reg) const;
|
||||
|
||||
struct GuestRegInfo
|
||||
{
|
||||
|
@ -285,9 +285,9 @@ public:
|
|||
|
||||
Arm64Gen::ARM64Reg RW(size_t preg, RegType type = REG_LOWER_PAIR);
|
||||
|
||||
BitSet32 GetCallerSavedUsed() override;
|
||||
BitSet32 GetCallerSavedUsed() const override;
|
||||
|
||||
bool IsSingle(size_t preg, bool lower_only = false);
|
||||
bool IsSingle(size_t preg, bool lower_only = false) const;
|
||||
|
||||
void FixSinglePrecision(size_t preg);
|
||||
|
||||
|
@ -303,7 +303,7 @@ protected:
|
|||
void FlushRegister(size_t preg, bool maintain_state) override;
|
||||
|
||||
private:
|
||||
bool IsCalleeSaved(Arm64Gen::ARM64Reg reg);
|
||||
bool IsCalleeSaved(Arm64Gen::ARM64Reg reg) const;
|
||||
|
||||
void FlushRegisters(BitSet32 regs, bool maintain_state);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue