mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 13:31:27 +12:00
PPU LLVM: simplify module loading
This commit is contained in:
parent
e875c91121
commit
2ef2f0f63b
3 changed files with 29 additions and 14 deletions
|
@ -343,22 +343,30 @@ public:
|
||||||
LOG_SUCCESS(GENERAL, "LLVM: Created module: %s", module->getName().data());
|
LOG_SUCCESS(GENERAL, "LLVM: Created module: %s", module->getName().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<llvm::MemoryBuffer> getObject(const llvm::Module* module) override
|
static std::unique_ptr<llvm::MemoryBuffer> load(const std::string& path)
|
||||||
{
|
{
|
||||||
std::string name = m_path;
|
if (fs::file cached{path, fs::read})
|
||||||
name.append(module->getName());
|
|
||||||
|
|
||||||
if (fs::file cached{name, fs::read})
|
|
||||||
{
|
{
|
||||||
auto buf = llvm::MemoryBuffer::getNewUninitMemBuffer(cached.size());
|
auto buf = llvm::MemoryBuffer::getNewUninitMemBuffer(cached.size());
|
||||||
cached.read(const_cast<char*>(buf->getBufferStart()), buf->getBufferSize());
|
cached.read(const_cast<char*>(buf->getBufferStart()), buf->getBufferSize());
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<llvm::MemoryBuffer> getObject(const llvm::Module* module) override
|
||||||
|
{
|
||||||
|
std::string path = m_path;
|
||||||
|
path.append(module->getName());
|
||||||
|
|
||||||
|
if (auto buf = load(path))
|
||||||
|
{
|
||||||
LOG_SUCCESS(GENERAL, "LLVM: Loaded module: %s", module->getName().data());
|
LOG_SUCCESS(GENERAL, "LLVM: Loaded module: %s", module->getName().data());
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return nullptr;
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -430,6 +438,11 @@ void jit_compiler::add(std::unique_ptr<llvm::Module> module, const std::string&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void jit_compiler::add(const std::string& path)
|
||||||
|
{
|
||||||
|
m_engine->addObjectFile(std::move(llvm::object::ObjectFile::createObjectFile(*ObjectCache::load(path)).get()));
|
||||||
|
}
|
||||||
|
|
||||||
void jit_compiler::fin()
|
void jit_compiler::fin()
|
||||||
{
|
{
|
||||||
m_engine->finalizeObject();
|
m_engine->finalizeObject();
|
||||||
|
|
|
@ -49,9 +49,12 @@ public:
|
||||||
return m_context;
|
return m_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add module
|
// Add module (path to obj cache dir)
|
||||||
void add(std::unique_ptr<llvm::Module> module, const std::string& path);
|
void add(std::unique_ptr<llvm::Module> module, const std::string& path);
|
||||||
|
|
||||||
|
// Add object (path to obj file)
|
||||||
|
void add(const std::string& path);
|
||||||
|
|
||||||
// Finalize
|
// Finalize
|
||||||
void fin();
|
void fin();
|
||||||
|
|
||||||
|
|
|
@ -1142,7 +1142,8 @@ extern void ppu_initialize(const ppu_module& info)
|
||||||
if (fs::is_file(cache_path + obj_name))
|
if (fs::is_file(cache_path + obj_name))
|
||||||
{
|
{
|
||||||
semaphore_lock lock(jmutex);
|
semaphore_lock lock(jmutex);
|
||||||
ppu_initialize2(*jit, part, cache_path, obj_name);
|
jit->add(cache_path + obj_name);
|
||||||
|
LOG_SUCCESS(PPU, "LLVM: Loaded module %s", obj_name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1173,7 +1174,7 @@ extern void ppu_initialize(const ppu_module& info)
|
||||||
|
|
||||||
// Proceed with original JIT instance
|
// Proceed with original JIT instance
|
||||||
semaphore_lock lock(jmutex);
|
semaphore_lock lock(jmutex);
|
||||||
ppu_initialize2(*jit, part, cache_path, obj_name);
|
jit->add(cache_path + obj_name);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1286,8 +1287,6 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
|
||||||
|
|
||||||
std::shared_ptr<MsgDialogBase> dlg;
|
std::shared_ptr<MsgDialogBase> dlg;
|
||||||
|
|
||||||
// Check cached file
|
|
||||||
if (!fs::is_file(cache_path + obj_name))
|
|
||||||
{
|
{
|
||||||
legacy::FunctionPassManager pm(module.get());
|
legacy::FunctionPassManager pm(module.get());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue