1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

Add proper transform pass management

This commit is contained in:
kd-11 2024-08-24 02:08:48 +03:00 committed by kd-11
parent 09ea858dbf
commit 4da30e9eca
4 changed files with 32 additions and 4 deletions

View File

@ -403,6 +403,24 @@ void cpu_translator::run_transforms(llvm::Function& f)
}
}
void cpu_translator::register_transform_pass(std::unique_ptr<translator_pass>& pass)
{
m_transform_passes.emplace_back(std::move(pass));
}
void cpu_translator::clear_transforms()
{
m_transform_passes.clear();
}
void cpu_translator::reset_transforms()
{
for (auto& pass : m_transform_passes)
{
pass->reset();
}
}
void cpu_translator::erase_stores(llvm::ArrayRef<llvm::Value*> args)
{
for (auto v : args)

View File

@ -3094,10 +3094,13 @@ protected:
public:
// Register a transformation pass to be run before final compilation by llvm
void register_transform_pass(std::unique_ptr<translator_pass>& pass)
{
m_transform_passes.emplace_back(std::move(pass));
}
void register_transform_pass(std::unique_ptr<translator_pass>& pass);
// Delete all transform passes
void clear_transforms();
// Reset internal state of all passes to evict caches and such. Use when resetting a JIT.
void reset_transforms();
// Convert a C++ type to an LLVM type (TODO: remove)
template <typename T>

View File

@ -35,6 +35,8 @@ PPUTranslator::PPUTranslator(LLVMContext& context, Module* _module, const ppu_mo
cpu_translator::initialize(context, engine);
// Initialize transform passes
clear_transforms();
#ifdef ARCH_ARM64
{
// Base reg table definition
@ -63,6 +65,8 @@ PPUTranslator::PPUTranslator(LLVMContext& context, Module* _module, const ppu_mo
}
#endif
reset_transforms();
// Thread context struct (TODO: safer member access)
const u32 off0 = offset32(&ppu_thread::state);
const u32 off1 = offset32(&ppu_thread::gpr);

View File

@ -1474,6 +1474,7 @@ public:
m_md_unlikely = llvm::MDTuple::get(m_context, {md_name, md_low, md_high});
// Initialize transform passes
clear_transforms();
#ifdef ARCH_ARM64
{
auto should_exclude_function = [](const std::string& fn_name)
@ -1498,6 +1499,8 @@ public:
}
#endif
}
reset_transforms();
}
void init_luts()