JitRegCache: Init emitter in constructor

This commit is contained in:
Martino Fontana
2026-08-10 12:02:59 +02:00
parent 2f6b10035d
commit e9517cfea2
8 changed files with 16 additions and 24 deletions

View File

@@ -275,9 +275,6 @@ bool Jit64::Init()
js.fastmemLoadStore = false;
js.compilerPC = 0;
gpr.SetEmitter(this);
fpr.SetEmitter(this);
const size_t routines_size = asm_routines.CODE_SIZE;
const size_t trampolines_size = jo.memcheck ? TRAMPOLINE_CODE_SIZE_MMU : TRAMPOLINE_CODE_SIZE;
const size_t farcode_size = jo.memcheck ? FARCODE_SIZE_MMU : FARCODE_SIZE;

View File

@@ -286,8 +286,8 @@ private:
JitBlockCache blocks{*this};
TrampolineCache trampolines{*this};
GPRRegCache gpr{*this};
FPURegCache fpr{*this};
GPRRegCache gpr{*this, *this};
FPURegCache fpr{*this, *this};
JitCommon::ConstantPropagation m_constant_propagation;

View File

@@ -9,7 +9,7 @@
using namespace Gen;
FPURegCache::FPURegCache(Jit64& jit) : RegCache{jit}
FPURegCache::FPURegCache(Jit64& jit, XEmitter& emitter) : RegCache{jit, emitter}
{
}
@@ -48,7 +48,7 @@ void FPURegCache::StoreRegister(preg_t preg, const OpArg& new_loc,
{
if (m_regs[preg].IsInHostRegister())
{
m_emitter->MOVAPD(new_loc, m_regs[preg].GetHostRegister());
m_emitter.MOVAPD(new_loc, m_regs[preg].GetHostRegister());
}
else
{
@@ -60,7 +60,7 @@ void FPURegCache::StoreRegister(preg_t preg, const OpArg& new_loc,
void FPURegCache::LoadRegister(preg_t preg, X64Reg new_loc)
{
ASSERT_MSG(DYNA_REC, m_regs[preg].IsInPPCState(), "FPR {} not in PPCState", preg);
m_emitter->MOVAPD(new_loc, GetPPCStateLocation(preg));
m_emitter.MOVAPD(new_loc, GetPPCStateLocation(preg));
}
void FPURegCache::DiscardImm(preg_t preg)

View File

@@ -10,7 +10,7 @@ class Jit64;
class FPURegCache final : public RegCache
{
public:
explicit FPURegCache(Jit64& jit);
explicit FPURegCache(Jit64& jit, Gen::XEmitter& emitter);
bool IsImm(preg_t preg) const override;
u32 Imm32(preg_t preg) const override;

View File

@@ -9,7 +9,7 @@
using namespace Gen;
GPRRegCache::GPRRegCache(Jit64& jit) : RegCache{jit}
GPRRegCache::GPRRegCache(Jit64& jit, XEmitter& emitter) : RegCache{jit, emitter}
{
}
@@ -52,11 +52,11 @@ void GPRRegCache::StoreRegister(preg_t preg, const OpArg& new_loc,
{
if (m_regs[preg].IsInHostRegister())
{
m_emitter->MOV(32, new_loc, ::Gen::R(m_regs[preg].GetHostRegister()));
m_emitter.MOV(32, new_loc, ::Gen::R(m_regs[preg].GetHostRegister()));
}
else if (m_jit.GetConstantPropagation().HasGPR(preg))
{
m_emitter->MOV(32, new_loc, ::Gen::Imm32(m_jit.GetConstantPropagation().GetGPR(preg)));
m_emitter.MOV(32, new_loc, ::Gen::Imm32(m_jit.GetConstantPropagation().GetGPR(preg)));
}
else
{
@@ -70,12 +70,12 @@ void GPRRegCache::LoadRegister(preg_t preg, X64Reg new_loc)
const JitCommon::ConstantPropagation& constant_propagation = m_jit.GetConstantPropagation();
if (constant_propagation.HasGPR(preg))
{
m_emitter->MOV(32, ::Gen::R(new_loc), ::Gen::Imm32(constant_propagation.GetGPR(preg)));
m_emitter.MOV(32, ::Gen::R(new_loc), ::Gen::Imm32(constant_propagation.GetGPR(preg)));
}
else
{
ASSERT_MSG(DYNA_REC, m_regs[preg].IsInPPCState(), "GPR {} not in PPCState", preg);
m_emitter->MOV(32, ::Gen::R(new_loc), GetPPCStateLocation(preg));
m_emitter.MOV(32, ::Gen::R(new_loc), GetPPCStateLocation(preg));
}
}

View File

@@ -10,7 +10,7 @@ class Jit64;
class GPRRegCache final : public RegCache
{
public:
explicit GPRRegCache(Jit64& jit);
explicit GPRRegCache(Jit64& jit, Gen::XEmitter& emitter);
bool IsImm(preg_t preg) const override;
u32 Imm32(preg_t preg) const override;

View File

@@ -231,7 +231,7 @@ void RCForkGuard::EndFork()
rc = nullptr;
}
RegCache::RegCache(Jit64& jit) : m_jit{jit}
RegCache::RegCache(Jit64& jit, XEmitter& emitter) : m_jit{jit}, m_emitter(emitter)
{
}
@@ -242,11 +242,6 @@ void RegCache::Start()
m_constraints.fill({});
}
void RegCache::SetEmitter(XEmitter* emitter)
{
m_emitter = emitter;
}
bool RegCache::SanityCheck() const
{
for (size_t i = 0; i < m_regs.size(); i++)

View File

@@ -134,11 +134,10 @@ public:
Yes,
};
explicit RegCache(Jit64& jit);
explicit RegCache(Jit64& jit, Gen::XEmitter& emitter);
virtual ~RegCache() = default;
void Start();
void SetEmitter(Gen::XEmitter* emitter);
bool SanityCheck() const;
template <typename... Ts>
@@ -230,8 +229,9 @@ protected:
bool IsAnyConstraintActive() const;
Jit64& m_jit;
Gen::XEmitter& m_emitter;
std::array<PPCCachedReg, 32> m_regs;
std::array<X64CachedReg, NUM_XREGS> m_xregs;
std::array<RCConstraint, 32> m_constraints;
Gen::XEmitter* m_emitter = nullptr;
};