mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-07 15:31:18 +12:00
PPCRec: Make register pool for RA configurable
This commit is contained in:
parent
c4fb7b74f8
commit
d420622da7
8 changed files with 330 additions and 362 deletions
|
@ -0,0 +1,94 @@
|
|||
|
||||
// container for storing a set of register indices
|
||||
// specifically optimized towards storing physical register indices (expected to be below 64)
|
||||
class IMLPhysRegisterSet
|
||||
{
|
||||
public:
|
||||
void SetAvailable(uint32 index)
|
||||
{
|
||||
cemu_assert_debug(index < 64);
|
||||
m_regBitmask |= ((uint64)1 << index);
|
||||
}
|
||||
|
||||
void SetReserved(uint32 index)
|
||||
{
|
||||
cemu_assert_debug(index < 64);
|
||||
m_regBitmask &= ~((uint64)1 << index);
|
||||
}
|
||||
|
||||
bool IsAvailable(uint32 index) const
|
||||
{
|
||||
return (m_regBitmask & (1 << index)) != 0;
|
||||
}
|
||||
|
||||
IMLPhysRegisterSet& operator&=(const IMLPhysRegisterSet& other)
|
||||
{
|
||||
this->m_regBitmask &= other.m_regBitmask;
|
||||
return *this;
|
||||
}
|
||||
|
||||
IMLPhysRegisterSet& operator=(const IMLPhysRegisterSet& other)
|
||||
{
|
||||
this->m_regBitmask = other.m_regBitmask;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool HasAnyAvailable() const
|
||||
{
|
||||
return m_regBitmask != 0;
|
||||
}
|
||||
|
||||
// returns index of first available register. Do not call when HasAnyAvailable() == false
|
||||
uint32 GetFirstAvailableReg()
|
||||
{
|
||||
cemu_assert_debug(m_regBitmask != 0);
|
||||
uint32 regIndex = 0;
|
||||
auto tmp = m_regBitmask;
|
||||
while ((tmp & 0xFF) == 0)
|
||||
{
|
||||
regIndex += 8;
|
||||
tmp >>= 8;
|
||||
}
|
||||
while ((tmp & 0x1) == 0)
|
||||
{
|
||||
regIndex++;
|
||||
tmp >>= 1;
|
||||
}
|
||||
return regIndex;
|
||||
}
|
||||
|
||||
// returns index of next available register (search includes any register index >= startIndex)
|
||||
// returns -1 if there is no more register
|
||||
sint32 GetNextAvailableReg(sint32 startIndex)
|
||||
{
|
||||
if (startIndex >= 64)
|
||||
return -1;
|
||||
uint32 regIndex = startIndex;
|
||||
auto tmp = m_regBitmask;
|
||||
tmp >>= regIndex;
|
||||
if (!tmp)
|
||||
return -1;
|
||||
while ((tmp & 0xFF) == 0)
|
||||
{
|
||||
regIndex += 8;
|
||||
tmp >>= 8;
|
||||
}
|
||||
while ((tmp & 0x1) == 0)
|
||||
{
|
||||
regIndex++;
|
||||
tmp >>= 1;
|
||||
}
|
||||
return regIndex;
|
||||
}
|
||||
|
||||
private:
|
||||
uint64 m_regBitmask{ 0 };
|
||||
};
|
||||
|
||||
|
||||
struct IMLRegisterAllocatorParameters
|
||||
{
|
||||
IMLPhysRegisterSet physicalRegisterPool;
|
||||
};
|
||||
|
||||
void IMLRegisterAllocator_AllocateRegisters(ppcImlGenContext_t* ppcImlGenContext, IMLRegisterAllocatorParameters& raParam);
|
Loading…
Add table
Add a link
Reference in a new issue