mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
Get rid of "module" keyword
Workaround some intellisense problems.
This commit is contained in:
parent
a6025df7de
commit
e1042bc631
@ -915,10 +915,10 @@ public:
|
||||
|
||||
~ObjectCache() override = default;
|
||||
|
||||
void notifyObjectCompiled(const llvm::Module* module, llvm::MemoryBufferRef obj) override
|
||||
void notifyObjectCompiled(const llvm::Module* _module, llvm::MemoryBufferRef obj) override
|
||||
{
|
||||
std::string name = m_path;
|
||||
name.append(module->getName().data());
|
||||
name.append(_module->getName().data());
|
||||
//fs::file(name, fs::rewrite).write(obj.getBufferStart(), obj.getBufferSize());
|
||||
name.append(".gz");
|
||||
|
||||
@ -948,14 +948,14 @@ public:
|
||||
}
|
||||
default:
|
||||
{
|
||||
jit_log.error("LLVM: Failed to compress module: %s", module->getName().data());
|
||||
jit_log.error("LLVM: Failed to compress module: %s", _module->getName().data());
|
||||
deflateEnd(&zs);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fs::file(name, fs::rewrite).write(zbuf.get(), zsz - zs.avail_out);
|
||||
jit_log.notice("LLVM: Created module: %s", module->getName().data());
|
||||
jit_log.notice("LLVM: Created module: %s", _module->getName().data());
|
||||
}
|
||||
|
||||
static std::unique_ptr<llvm::MemoryBuffer> load(const std::string& path)
|
||||
@ -1033,14 +1033,14 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<llvm::MemoryBuffer> getObject(const llvm::Module* module) override
|
||||
std::unique_ptr<llvm::MemoryBuffer> getObject(const llvm::Module* _module) override
|
||||
{
|
||||
std::string path = m_path;
|
||||
path.append(module->getName().data());
|
||||
path.append(_module->getName().data());
|
||||
|
||||
if (auto buf = load(path))
|
||||
{
|
||||
jit_log.notice("LLVM: Loaded module: %s", module->getName().data());
|
||||
jit_log.notice("LLVM: Loaded module: %s", _module->getName().data());
|
||||
return buf;
|
||||
}
|
||||
|
||||
@ -1166,13 +1166,13 @@ jit_compiler::~jit_compiler()
|
||||
{
|
||||
}
|
||||
|
||||
void jit_compiler::add(std::unique_ptr<llvm::Module> module, const std::string& path)
|
||||
void jit_compiler::add(std::unique_ptr<llvm::Module> _module, const std::string& path)
|
||||
{
|
||||
ObjectCache cache{path};
|
||||
m_engine->setObjectCache(&cache);
|
||||
|
||||
const auto ptr = module.get();
|
||||
m_engine->addModule(std::move(module));
|
||||
const auto ptr = _module.get();
|
||||
m_engine->addModule(std::move(_module));
|
||||
m_engine->generateCodeForModule(ptr);
|
||||
m_engine->setObjectCache(nullptr);
|
||||
|
||||
@ -1183,10 +1183,10 @@ void jit_compiler::add(std::unique_ptr<llvm::Module> module, const std::string&
|
||||
}
|
||||
}
|
||||
|
||||
void jit_compiler::add(std::unique_ptr<llvm::Module> module)
|
||||
void jit_compiler::add(std::unique_ptr<llvm::Module> _module)
|
||||
{
|
||||
const auto ptr = module.get();
|
||||
m_engine->addModule(std::move(module));
|
||||
const auto ptr = _module.get();
|
||||
m_engine->addModule(std::move(_module));
|
||||
m_engine->generateCodeForModule(ptr);
|
||||
|
||||
for (auto& func : ptr->functions())
|
||||
|
@ -163,10 +163,10 @@ public:
|
||||
}
|
||||
|
||||
// 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 module (not cached)
|
||||
void add(std::unique_ptr<llvm::Module> module);
|
||||
void add(std::unique_ptr<llvm::Module> _module);
|
||||
|
||||
// Add object (path to obj file)
|
||||
void add(const std::string& path);
|
||||
|
@ -1657,10 +1657,10 @@ static LONG exception_filter(PEXCEPTION_POINTERS pExp) noexcept
|
||||
//const auto uw = (u8*)(unwind_base + rtf->UnwindData);
|
||||
}
|
||||
|
||||
for (HMODULE module : modules)
|
||||
for (HMODULE _module : modules)
|
||||
{
|
||||
MODULEINFO info;
|
||||
if (GetModuleInformation(GetCurrentProcess(), module, &info, sizeof(info)))
|
||||
if (GetModuleInformation(GetCurrentProcess(), _module, &info, sizeof(info)))
|
||||
{
|
||||
const DWORD64 base = reinterpret_cast<DWORD64>(info.lpBaseOfDll);
|
||||
|
||||
@ -1670,7 +1670,7 @@ static LONG exception_filter(PEXCEPTION_POINTERS pExp) noexcept
|
||||
for (DWORD size = 15; module_name.size() != size;)
|
||||
{
|
||||
module_name.resize(size);
|
||||
size = GetModuleBaseNameA(GetCurrentProcess(), module, &module_name.front(), size + 1);
|
||||
size = GetModuleBaseNameA(GetCurrentProcess(), _module, &module_name.front(), size + 1);
|
||||
if (!size)
|
||||
{
|
||||
module_name.clear();
|
||||
|
@ -4,9 +4,9 @@
|
||||
|
||||
llvm::LLVMContext g_llvm_ctx;
|
||||
|
||||
cpu_translator::cpu_translator(llvm::Module* module, bool is_be)
|
||||
cpu_translator::cpu_translator(llvm::Module* _module, bool is_be)
|
||||
: m_context(g_llvm_ctx)
|
||||
, m_module(module)
|
||||
, m_module(_module)
|
||||
, m_is_be(is_be)
|
||||
{
|
||||
}
|
||||
|
@ -1009,8 +1009,8 @@ struct llvm_fshl
|
||||
|
||||
static llvm::Function* get_fshl(llvm::IRBuilder<>* ir)
|
||||
{
|
||||
const auto module = ir->GetInsertBlock()->getParent()->getParent();
|
||||
return llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::fshl, {llvm_value_t<T>::get_type(ir->getContext())});
|
||||
const auto _module = ir->GetInsertBlock()->getParent()->getParent();
|
||||
return llvm::Intrinsic::getDeclaration(_module, llvm::Intrinsic::fshl, {llvm_value_t<T>::get_type(ir->getContext())});
|
||||
}
|
||||
|
||||
static llvm::Value* fold(llvm::IRBuilder<>* ir, llvm::Value* v1, llvm::Value* v2, llvm::Value* v3)
|
||||
@ -1081,8 +1081,8 @@ struct llvm_fshr
|
||||
|
||||
static llvm::Function* get_fshr(llvm::IRBuilder<>* ir)
|
||||
{
|
||||
const auto module = ir->GetInsertBlock()->getParent()->getParent();
|
||||
return llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::fshr, {llvm_value_t<T>::get_type(ir->getContext())});
|
||||
const auto _module = ir->GetInsertBlock()->getParent()->getParent();
|
||||
return llvm::Intrinsic::getDeclaration(_module, llvm::Intrinsic::fshr, {llvm_value_t<T>::get_type(ir->getContext())});
|
||||
}
|
||||
|
||||
static llvm::Value* fold(llvm::IRBuilder<>* ir, llvm::Value* v1, llvm::Value* v2, llvm::Value* v3)
|
||||
@ -1642,7 +1642,7 @@ struct llvm_bitcast
|
||||
using type = U;
|
||||
|
||||
llvm_expr_t<A1> a1;
|
||||
llvm::Module* module;
|
||||
llvm::Module* _module;
|
||||
|
||||
static constexpr uint bitsize0 = llvm_value_t<T>::is_vector ? llvm_value_t<T>::is_vector * llvm_value_t<T>::esize : llvm_value_t<T>::esize;
|
||||
static constexpr uint bitsize1 = llvm_value_t<U>::is_vector ? llvm_value_t<U>::is_vector * llvm_value_t<U>::esize : llvm_value_t<U>::esize;
|
||||
@ -1668,7 +1668,7 @@ struct llvm_bitcast
|
||||
|
||||
if (const auto c1 = llvm::dyn_cast<llvm::Constant>(v1))
|
||||
{
|
||||
const auto result = llvm::ConstantFoldCastOperand(llvm::Instruction::BitCast, c1, rt, module->getDataLayout());
|
||||
const auto result = llvm::ConstantFoldCastOperand(llvm::Instruction::BitCast, c1, rt, _module->getDataLayout());
|
||||
|
||||
if (result)
|
||||
{
|
||||
@ -1714,7 +1714,7 @@ struct llvm_bitcast
|
||||
const auto target = llvm_value_t<T>::get_type(c->getContext());
|
||||
|
||||
// Reverse bitcast on a constant
|
||||
if (llvm::Value* cv = llvm::ConstantFoldCastOperand(llvm::Instruction::BitCast, c, target, module->getDataLayout()))
|
||||
if (llvm::Value* cv = llvm::ConstantFoldCastOperand(llvm::Instruction::BitCast, c, target, _module->getDataLayout()))
|
||||
{
|
||||
if (auto r1 = a1.match(cv); cv)
|
||||
{
|
||||
@ -2029,8 +2029,8 @@ struct llvm_add_sat
|
||||
|
||||
static llvm::Function* get_add_sat(llvm::IRBuilder<>* ir)
|
||||
{
|
||||
const auto module = ir->GetInsertBlock()->getParent()->getParent();
|
||||
return llvm::Intrinsic::getDeclaration(module, intr, {llvm_value_t<T>::get_type(ir->getContext())});
|
||||
const auto _module = ir->GetInsertBlock()->getParent()->getParent();
|
||||
return llvm::Intrinsic::getDeclaration(_module, intr, {llvm_value_t<T>::get_type(ir->getContext())});
|
||||
}
|
||||
|
||||
llvm::Value* eval(llvm::IRBuilder<>* ir) const
|
||||
@ -2100,8 +2100,8 @@ struct llvm_sub_sat
|
||||
|
||||
static llvm::Function* get_sub_sat(llvm::IRBuilder<>* ir)
|
||||
{
|
||||
const auto module = ir->GetInsertBlock()->getParent()->getParent();
|
||||
return llvm::Intrinsic::getDeclaration(module, intr, {llvm_value_t<T>::get_type(ir->getContext())});
|
||||
const auto _module = ir->GetInsertBlock()->getParent()->getParent();
|
||||
return llvm::Intrinsic::getDeclaration(_module, intr, {llvm_value_t<T>::get_type(ir->getContext())});
|
||||
}
|
||||
|
||||
llvm::Value* eval(llvm::IRBuilder<>* ir) const
|
||||
@ -2403,7 +2403,7 @@ struct llvm_shuffle2
|
||||
class cpu_translator
|
||||
{
|
||||
protected:
|
||||
cpu_translator(llvm::Module* module, bool is_be);
|
||||
cpu_translator(llvm::Module* _module, bool is_be);
|
||||
|
||||
// LLVM context
|
||||
std::reference_wrapper<llvm::LLVMContext> m_context;
|
||||
@ -2695,8 +2695,8 @@ public:
|
||||
template <typename... Types>
|
||||
llvm::Function* get_intrinsic(llvm::Intrinsic::ID id)
|
||||
{
|
||||
const auto module = m_ir->GetInsertBlock()->getParent()->getParent();
|
||||
return llvm::Intrinsic::getDeclaration(module, id, {get_type<Types>()...});
|
||||
const auto _module = m_ir->GetInsertBlock()->getParent()->getParent();
|
||||
return llvm::Intrinsic::getDeclaration(_module, id, {get_type<Types>()...});
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
@ -83,7 +83,7 @@ bool statichle_handler::load_patterns()
|
||||
dapat.crc16_length = ::narrow<u8>(char_to_u8(pattern[1][0], pattern[1][1]), HERE);
|
||||
dapat.crc16 = (char_to_u8(pattern[2][0], pattern[2][1]) << 8) | char_to_u8(pattern[2][2], pattern[2][3]);
|
||||
dapat.total_length = (char_to_u8(pattern[3][0], pattern[3][1]) << 8) | char_to_u8(pattern[3][2], pattern[3][3]);
|
||||
dapat.module = pattern[4];
|
||||
dapat._module = pattern[4];
|
||||
dapat.name = pattern[5];
|
||||
|
||||
dapat.fnid = ppu_generate_id(dapat.name.c_str());
|
||||
@ -153,11 +153,11 @@ bool statichle_handler::check_against_patterns(vm::cptr<u8>& data, u32 size, u32
|
||||
static_hle.success("Found function %s at 0x%x", pat.name, addr);
|
||||
|
||||
// patch the code
|
||||
const auto smodule = ppu_module_manager::get_module(pat.module);
|
||||
const auto smodule = ppu_module_manager::get_module(pat._module);
|
||||
|
||||
if (smodule == nullptr)
|
||||
{
|
||||
static_hle.error("Couldn't find module: %s", pat.module);
|
||||
static_hle.error("Couldn't find module: %s", pat._module);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ struct shle_pattern
|
||||
u8 crc16_length;
|
||||
u16 crc16;
|
||||
u16 total_length;
|
||||
std::string module;
|
||||
std::string _module;
|
||||
std::string name;
|
||||
|
||||
u32 fnid;
|
||||
|
@ -380,7 +380,7 @@ struct CellSpursTraceMapData
|
||||
|
||||
struct CellSpursTraceStartData
|
||||
{
|
||||
char module[4];
|
||||
char _module[4];
|
||||
be_t<u16> level;
|
||||
be_t<u16> ls;
|
||||
};
|
||||
|
@ -904,7 +904,7 @@ void spursSysServiceMain(spu_thread& spu, u32 pollStatus)
|
||||
// Trace - START: Module='SYS '
|
||||
CellSpursTracePacket pkt{};
|
||||
pkt.header.tag = CELL_SPURS_TRACE_TAG_START;
|
||||
memcpy(pkt.data.start.module, "SYS ", 4);
|
||||
std::memcpy(pkt.data.start._module, "SYS ", 4);
|
||||
pkt.data.start.level = 1; // Policy module
|
||||
pkt.data.start.ls = 0xA00 >> 2;
|
||||
cellSpursModulePutTrace(&pkt, ctxt->dmaTagId);
|
||||
@ -1958,7 +1958,7 @@ void spursTasksetInit(spu_thread& spu, u32 pollStatus)
|
||||
// Trace - START: Module='TKST'
|
||||
CellSpursTracePacket pkt{};
|
||||
pkt.header.tag = 0x52; // Its not clear what this tag means exactly but it seems similar to CELL_SPURS_TRACE_TAG_START
|
||||
memcpy(pkt.data.start.module, "TKST", 4);
|
||||
std::memcpy(pkt.data.start._module, "TKST", 4);
|
||||
pkt.data.start.level = 2;
|
||||
pkt.data.start.ls = 0xA00 >> 2;
|
||||
cellSpursModulePutTrace(&pkt, ctxt->dmaTagId);
|
||||
|
@ -640,9 +640,9 @@ extern std::string ppu_get_syscall_name(u64 code)
|
||||
}
|
||||
|
||||
// Get function name by FNID
|
||||
extern std::string ppu_get_function_name(const std::string& module, u32 fnid)
|
||||
extern std::string ppu_get_function_name(const std::string& _module, u32 fnid)
|
||||
{
|
||||
if (module.empty()) switch (fnid)
|
||||
if (_module.empty()) switch (fnid)
|
||||
{
|
||||
case 0x0d10fd3f: return "module_prologue";
|
||||
case 0x330f7005: return "module_epilogue";
|
||||
@ -652,7 +652,7 @@ extern std::string ppu_get_function_name(const std::string& module, u32 fnid)
|
||||
}
|
||||
|
||||
// Check known FNIDs
|
||||
if (module == "sys_libc" || module == "sys_libm") switch (fnid)
|
||||
if (_module == "sys_libc" || _module == "sys_libm") switch (fnid)
|
||||
{
|
||||
case 0x00acf0e5: return "spu_printf_finalize";
|
||||
case 0x00fb4a6b: return "spu_thread_sprintf";
|
||||
@ -1727,7 +1727,7 @@ extern std::string ppu_get_function_name(const std::string& module, u32 fnid)
|
||||
case 0xfffe79bf: return "_LCmulcc";
|
||||
}
|
||||
|
||||
if (module == "sys_libstdcxx") switch (fnid)
|
||||
if (_module == "sys_libstdcxx") switch (fnid)
|
||||
{
|
||||
case 0x002c338b: return "_ZNKSt8time_getIcSt19istreambuf_iteratorIcSt11char_traitsIcEEE16do_get_monthnameES3_S3_RSt8ios_baseRNSt5_IosbIiE8_IostateEPSt2tm";
|
||||
case 0x002e18d8: return "_ZNSt6locale7_LocimpD0Ev";
|
||||
@ -2287,7 +2287,7 @@ extern std::string ppu_get_function_name(const std::string& module, u32 fnid)
|
||||
case 0xfff6ef55: return "_ZNKSt7num_getIwSt19istreambuf_iteratorIwSt11char_traitsIwEEE6do_getES3_S3_RSt8ios_baseRNSt5_IosbIiE8_IostateERb";
|
||||
}
|
||||
|
||||
if (module == "sysPrxForUser") switch (fnid)
|
||||
if (_module == "sysPrxForUser") switch (fnid)
|
||||
{
|
||||
case 0x02e20ec1: return "__sys_printf_basename";
|
||||
case 0x0341bb97: return "sys_prx_get_module_id_by_address";
|
||||
@ -2422,7 +2422,7 @@ extern std::string ppu_get_function_name(const std::string& module, u32 fnid)
|
||||
}
|
||||
|
||||
// Check registered functions
|
||||
if (const auto sm = ppu_module_manager::get_module(module))
|
||||
if (const auto sm = ppu_module_manager::get_module(_module))
|
||||
{
|
||||
const auto found = sm->functions.find(fnid);
|
||||
|
||||
@ -2436,15 +2436,15 @@ extern std::string ppu_get_function_name(const std::string& module, u32 fnid)
|
||||
}
|
||||
|
||||
// Get variable name by VNID
|
||||
extern std::string ppu_get_variable_name(const std::string& module, u32 vnid)
|
||||
extern std::string ppu_get_variable_name(const std::string& _module, u32 vnid)
|
||||
{
|
||||
if (module.empty()) switch (vnid)
|
||||
if (_module.empty()) switch (vnid)
|
||||
{
|
||||
// these arent the actual hash, but its close enough
|
||||
case 0xd7f43016: return "module_info";
|
||||
}
|
||||
// Check known FNIDs
|
||||
if (module == "sys_libc") switch (vnid)
|
||||
if (_module == "sys_libc") switch (vnid)
|
||||
{
|
||||
case 0x071928b0: return "_LNan";
|
||||
case 0x0a331920: return "_Clocale";
|
||||
@ -2496,7 +2496,7 @@ extern std::string ppu_get_variable_name(const std::string& module, u32 vnid)
|
||||
case 0xff2f0cc7: return "_FEps";
|
||||
}
|
||||
|
||||
if (module == "sys_libm") switch (vnid)
|
||||
if (_module == "sys_libm") switch (vnid)
|
||||
{
|
||||
case 0x1cf745bc: return "_LErf_one";
|
||||
case 0x2259ef96: return "_LGamma_big";
|
||||
@ -2511,7 +2511,7 @@ extern std::string ppu_get_variable_name(const std::string& module, u32 vnid)
|
||||
}
|
||||
|
||||
// Check registered variables
|
||||
if (const auto sm = ppu_module_manager::get_module(module))
|
||||
if (const auto sm = ppu_module_manager::get_module(_module))
|
||||
{
|
||||
const auto found = sm->variables.find(vnid);
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
LOG_CHANNEL(ppu_loader);
|
||||
|
||||
extern void ppu_initialize_syscalls();
|
||||
extern std::string ppu_get_function_name(const std::string& module, u32 fnid);
|
||||
extern std::string ppu_get_variable_name(const std::string& module, u32 vnid);
|
||||
extern std::string ppu_get_function_name(const std::string& _module, u32 fnid);
|
||||
extern std::string ppu_get_variable_name(const std::string& _module, u32 vnid);
|
||||
extern void ppu_register_range(u32 addr, u32 size);
|
||||
extern void ppu_register_function_at(u32 addr, u32 size, ppu_function_t ptr);
|
||||
extern void ppu_initialize(const ppu_module& info);
|
||||
@ -68,30 +68,30 @@ std::unordered_map<std::string, ppu_static_module*>& ppu_module_manager::access(
|
||||
return map;
|
||||
}
|
||||
|
||||
void ppu_module_manager::register_module(ppu_static_module* module)
|
||||
void ppu_module_manager::register_module(ppu_static_module* _module)
|
||||
{
|
||||
access().emplace(module->name, module);
|
||||
access().emplace(_module->name, _module);
|
||||
}
|
||||
|
||||
ppu_static_function& ppu_module_manager::access_static_function(const char* module, u32 fnid)
|
||||
ppu_static_function& ppu_module_manager::access_static_function(const char* _module, u32 fnid)
|
||||
{
|
||||
auto& res = access().at(module)->functions[fnid];
|
||||
auto& res = access().at(_module)->functions[fnid];
|
||||
|
||||
if (res.name)
|
||||
{
|
||||
fmt::throw_exception("PPU FNID duplication in module %s (%s, 0x%x)", module, res.name, fnid);
|
||||
fmt::throw_exception("PPU FNID duplication in module %s (%s, 0x%x)", _module, res.name, fnid);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
ppu_static_variable& ppu_module_manager::access_static_variable(const char* module, u32 vnid)
|
||||
ppu_static_variable& ppu_module_manager::access_static_variable(const char* _module, u32 vnid)
|
||||
{
|
||||
auto& res = access().at(module)->variables[vnid];
|
||||
auto& res = access().at(_module)->variables[vnid];
|
||||
|
||||
if (res.name)
|
||||
{
|
||||
fmt::throw_exception("PPU VNID duplication in module %s (%s, 0x%x)", module, res.name, vnid);
|
||||
fmt::throw_exception("PPU VNID duplication in module %s (%s, 0x%x)", _module, res.name, vnid);
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -107,7 +107,7 @@ const ppu_static_module* ppu_module_manager::get_module(const std::string& name)
|
||||
// Global linkage information
|
||||
struct ppu_linkage_info
|
||||
{
|
||||
struct module
|
||||
struct module_data
|
||||
{
|
||||
struct info
|
||||
{
|
||||
@ -127,7 +127,7 @@ struct ppu_linkage_info
|
||||
};
|
||||
|
||||
// Module map
|
||||
std::unordered_map<std::string, module> modules;
|
||||
std::unordered_map<std::string, module_data> modules;
|
||||
};
|
||||
|
||||
// Initialize static modules.
|
||||
@ -289,23 +289,23 @@ static void ppu_initialize_modules(ppu_linkage_info* link)
|
||||
u32 alloc_addr = 0;
|
||||
|
||||
// "Use" all the modules for correct linkage
|
||||
for (auto& module : registered)
|
||||
for (auto& _module : registered)
|
||||
{
|
||||
ppu_loader.trace("Registered static module: %s", module->name);
|
||||
ppu_loader.trace("Registered static module: %s", _module->name);
|
||||
}
|
||||
|
||||
for (auto& pair : ppu_module_manager::get())
|
||||
{
|
||||
const auto module = pair.second;
|
||||
auto& linkage = link->modules[module->name];
|
||||
const auto _module = pair.second;
|
||||
auto& linkage = link->modules[_module->name];
|
||||
|
||||
for (auto& function : module->functions)
|
||||
for (auto& function : _module->functions)
|
||||
{
|
||||
ppu_loader.trace("** 0x%08X: %s", function.first, function.second.name);
|
||||
|
||||
if (is_first)
|
||||
{
|
||||
g_ppu_function_names[function.second.index] = fmt::format("%s.%s", module->name, function.second.name);
|
||||
g_ppu_function_names[function.second.index] = fmt::format("%s.%s", _module->name, function.second.name);
|
||||
}
|
||||
|
||||
if ((function.second.flags & MFF_HIDDEN) == 0)
|
||||
@ -318,7 +318,7 @@ static void ppu_initialize_modules(ppu_linkage_info* link)
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& variable : module->variables)
|
||||
for (auto& variable : _module->variables)
|
||||
{
|
||||
ppu_loader.trace("** &0x%08X: %s (size=0x%x, align=0x%x)", variable.first, variable.second.name, variable.second.size, variable.second.align);
|
||||
|
||||
@ -350,7 +350,7 @@ static void ppu_initialize_modules(ppu_linkage_info* link)
|
||||
variable.second.var->set(variable.second.addr);
|
||||
}
|
||||
|
||||
ppu_loader.trace("Allocated HLE variable %s.%s at 0x%x", module->name, variable.second.name, variable.second.var->addr());
|
||||
ppu_loader.trace("Allocated HLE variable %s.%s at 0x%x", _module->name, variable.second.name, variable.second.var->addr());
|
||||
|
||||
// Initialize HLE variable
|
||||
if (variable.second.init)
|
||||
@ -996,14 +996,14 @@ void ppu_unload_prx(const lv2_prx& prx)
|
||||
// Clean linkage info
|
||||
for (auto& imp : prx.imports)
|
||||
{
|
||||
auto pinfo = static_cast<ppu_linkage_info::module::info*>(imp.second);
|
||||
auto pinfo = static_cast<ppu_linkage_info::module_data::info*>(imp.second);
|
||||
pinfo->frefss.erase(imp.first);
|
||||
pinfo->imports.erase(imp.first);
|
||||
}
|
||||
|
||||
//for (auto& exp : prx.exports)
|
||||
//{
|
||||
// auto pinfo = static_cast<ppu_linkage_info::module::info*>(exp.second);
|
||||
// auto pinfo = static_cast<ppu_linkage_info::module_data::info*>(exp.second);
|
||||
// if (pinfo->static_func)
|
||||
// {
|
||||
// pinfo->export_addr = ppu_function_manager::addr + 8 * pinfo->static_func->index;
|
||||
|
@ -103,11 +103,11 @@ class ppu_module_manager final
|
||||
|
||||
static std::unordered_map<std::string, ppu_static_module*>& access();
|
||||
|
||||
static void register_module(ppu_static_module* module);
|
||||
static void register_module(ppu_static_module*);
|
||||
|
||||
static ppu_static_function& access_static_function(const char* module, u32 fnid);
|
||||
static ppu_static_function& access_static_function(const char* _module, u32 fnid);
|
||||
|
||||
static ppu_static_variable& access_static_variable(const char* module, u32 vnid);
|
||||
static ppu_static_variable& access_static_variable(const char* _module, u32 vnid);
|
||||
|
||||
// Global variable for each registered function
|
||||
template <auto* Func>
|
||||
@ -120,9 +120,9 @@ public:
|
||||
static const ppu_static_module* get_module(const std::string& name);
|
||||
|
||||
template <auto* Func>
|
||||
static auto& register_static_function(const char* module, const char* name, ppu_function_t func, u32 fnid)
|
||||
static auto& register_static_function(const char* _module, const char* name, ppu_function_t func, u32 fnid)
|
||||
{
|
||||
auto& info = access_static_function(module, fnid);
|
||||
auto& info = access_static_function(_module, fnid);
|
||||
|
||||
info.name = name;
|
||||
info.index = ppu_function_manager::register_function<decltype(Func), Func>(func);
|
||||
@ -141,13 +141,13 @@ public:
|
||||
}
|
||||
|
||||
template <auto* Var>
|
||||
static auto& register_static_variable(const char* module, const char* name, u32 vnid)
|
||||
static auto& register_static_variable(const char* _module, const char* name, u32 vnid)
|
||||
{
|
||||
using gvar = std::decay_t<decltype(*Var)>;
|
||||
|
||||
static_assert(std::is_same<u32, typename gvar::addr_type>::value, "Static variable registration: vm::gvar<T> expected");
|
||||
|
||||
auto& info = access_static_variable(module, vnid);
|
||||
auto& info = access_static_variable(_module, vnid);
|
||||
|
||||
info.name = name;
|
||||
info.var = reinterpret_cast<vm::gvar<char>*>(Var);
|
||||
@ -286,12 +286,12 @@ inline RT ppu_execute(ppu_thread& ppu, Args... args)
|
||||
return func(ppu, args...);
|
||||
}
|
||||
|
||||
#define REG_FNID(module, nid, func) ppu_module_manager::register_static_function<&func>(#module, ppu_select_name(#func, nid), BIND_FUNC(func, ppu.cia = static_cast<u32>(ppu.lr) & ~3), ppu_generate_id(nid))
|
||||
#define REG_FNID(_module, nid, func) ppu_module_manager::register_static_function<&func>(#_module, ppu_select_name(#func, nid), BIND_FUNC(func, ppu.cia = static_cast<u32>(ppu.lr) & ~3), ppu_generate_id(nid))
|
||||
|
||||
#define REG_FUNC(module, func) REG_FNID(module, #func, func)
|
||||
#define REG_FUNC(_module, func) REG_FNID(_module, #func, func)
|
||||
|
||||
#define REG_VNID(module, nid, var) ppu_module_manager::register_static_variable<&var>(#module, ppu_select_name(#var, nid), ppu_generate_id(nid))
|
||||
#define REG_VNID(_module, nid, var) ppu_module_manager::register_static_variable<&var>(#_module, ppu_select_name(#var, nid), ppu_generate_id(nid))
|
||||
|
||||
#define REG_VAR(module, var) REG_VNID(module, #var, var)
|
||||
#define REG_VAR(_module, var) REG_VNID(_module, #var, var)
|
||||
|
||||
#define UNIMPLEMENTED_FUNC(module) module.todo("%s()", __func__)
|
||||
#define UNIMPLEMENTED_FUNC(_module) _module.todo("%s()", __func__)
|
||||
|
@ -1804,14 +1804,14 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
|
||||
using namespace llvm;
|
||||
|
||||
// Create LLVM module
|
||||
std::unique_ptr<Module> module = std::make_unique<Module>(obj_name, jit.get_context());
|
||||
std::unique_ptr<Module> _module = std::make_unique<Module>(obj_name, jit.get_context());
|
||||
|
||||
// Initialize target
|
||||
module->setTargetTriple(Triple::normalize(sys::getProcessTriple()));
|
||||
module->setDataLayout(jit.get_engine().getTargetMachine()->createDataLayout());
|
||||
_module->setTargetTriple(Triple::normalize(sys::getProcessTriple()));
|
||||
_module->setDataLayout(jit.get_engine().getTargetMachine()->createDataLayout());
|
||||
|
||||
// Initialize translator
|
||||
PPUTranslator translator(jit.get_context(), module.get(), module_part, jit.get_engine());
|
||||
PPUTranslator translator(jit.get_context(), _module.get(), module_part, jit.get_engine());
|
||||
|
||||
// Define some types
|
||||
const auto _void = Type::getVoidTy(jit.get_context());
|
||||
@ -1822,13 +1822,13 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
|
||||
{
|
||||
if (func.size)
|
||||
{
|
||||
const auto f = cast<Function>(module->getOrInsertFunction(func.name, _func).getCallee());
|
||||
const auto f = cast<Function>(_module->getOrInsertFunction(func.name, _func).getCallee());
|
||||
f->addAttribute(1, Attribute::NoAlias);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
legacy::FunctionPassManager pm(module.get());
|
||||
legacy::FunctionPassManager pm(_module.get());
|
||||
|
||||
// Basic optimizations
|
||||
//pm.add(createCFGSimplificationPass());
|
||||
@ -1888,12 +1888,12 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
|
||||
|
||||
if (g_cfg.core.llvm_logs)
|
||||
{
|
||||
out << *module; // print IR
|
||||
out << *_module; // print IR
|
||||
fs::file(cache_path + obj_name + ".log", fs::rewrite).write(out.str());
|
||||
result.clear();
|
||||
}
|
||||
|
||||
if (verifyModule(*module, &out))
|
||||
if (verifyModule(*_module, &out))
|
||||
{
|
||||
out.flush();
|
||||
ppu_log.error("LLVM: Verification failed for %s:\n%s", obj_name, result);
|
||||
@ -1901,10 +1901,10 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
|
||||
return;
|
||||
}
|
||||
|
||||
ppu_log.notice("LLVM: %zu functions generated", module->getFunctionList().size());
|
||||
ppu_log.notice("LLVM: %zu functions generated", _module->getFunctionList().size());
|
||||
}
|
||||
|
||||
// Load or compile module
|
||||
jit.add(std::move(module), cache_path);
|
||||
jit.add(std::move(_module), cache_path);
|
||||
#endif // LLVM_AVAILABLE
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ using namespace llvm;
|
||||
constexpr ppu_decoder<PPUTranslator> s_ppu_decoder;
|
||||
constexpr ppu_decoder<ppu_iname> s_ppu_iname;
|
||||
|
||||
PPUTranslator::PPUTranslator(LLVMContext& context, Module* module, const ppu_module& info, ExecutionEngine& engine)
|
||||
: cpu_translator(module, false)
|
||||
PPUTranslator::PPUTranslator(LLVMContext& context, Module* _module, const ppu_module& info, ExecutionEngine& engine)
|
||||
: cpu_translator(_module, false)
|
||||
, m_info(info)
|
||||
, m_pure_attr(AttributeList::get(m_context, AttributeList::FunctionIndex, {Attribute::NoUnwind, Attribute::ReadNone}))
|
||||
{
|
||||
@ -25,7 +25,7 @@ PPUTranslator::PPUTranslator(LLVMContext& context, Module* module, const ppu_mod
|
||||
const u32 gsuffix = m_info.name.empty() ? info.funcs[0].addr : info.funcs[0].addr - m_info.segs[0].addr;
|
||||
|
||||
// Memory base
|
||||
m_base = new GlobalVariable(*module, ArrayType::get(GetType<char>(), 0x100000000)->getPointerTo(), true, GlobalValue::ExternalLinkage, 0, fmt::format("__mptr%x", gsuffix));
|
||||
m_base = new GlobalVariable(*_module, ArrayType::get(GetType<char>(), 0x100000000)->getPointerTo(), true, GlobalValue::ExternalLinkage, 0, fmt::format("__mptr%x", gsuffix));
|
||||
m_base->setInitializer(ConstantPointerNull::get(cast<PointerType>(m_base->getType()->getPointerElementType())));
|
||||
m_base->setExternallyInitialized(true);
|
||||
|
||||
@ -50,7 +50,7 @@ PPUTranslator::PPUTranslator(LLVMContext& context, Module* module, const ppu_mod
|
||||
m_thread_type = StructType::create(m_context, thread_struct, "context_t");
|
||||
|
||||
// Callable
|
||||
m_call = new GlobalVariable(*module, ArrayType::get(GetType<u32>(), 0x80000000)->getPointerTo(), true, GlobalValue::ExternalLinkage, 0, fmt::format("__cptr%x", gsuffix));
|
||||
m_call = new GlobalVariable(*_module, ArrayType::get(GetType<u32>(), 0x80000000)->getPointerTo(), true, GlobalValue::ExternalLinkage, 0, fmt::format("__cptr%x", gsuffix));
|
||||
m_call->setInitializer(ConstantPointerNull::get(cast<PointerType>(m_call->getType()->getPointerElementType())));
|
||||
m_call->setExternallyInitialized(true);
|
||||
|
||||
@ -65,7 +65,7 @@ PPUTranslator::PPUTranslator(LLVMContext& context, Module* module, const ppu_mod
|
||||
// Create segment variables
|
||||
for (const auto& seg : m_info.segs)
|
||||
{
|
||||
auto gv = new GlobalVariable(*module, GetType<u64>(), true, GlobalValue::ExternalLinkage, 0, fmt::format("__seg%u_%x", m_segs.size(), gsuffix));
|
||||
auto gv = new GlobalVariable(*_module, GetType<u64>(), true, GlobalValue::ExternalLinkage, 0, fmt::format("__seg%u_%x", m_segs.size(), gsuffix));
|
||||
gv->setInitializer(ConstantInt::get(GetType<u64>(), seg.addr));
|
||||
gv->setExternallyInitialized(true);
|
||||
m_segs.emplace_back(gv);
|
||||
|
@ -315,7 +315,7 @@ public:
|
||||
// Handle compilation errors
|
||||
void CompilationError(const std::string& error);
|
||||
|
||||
PPUTranslator(llvm::LLVMContext& context, llvm::Module* module, const ppu_module& info, llvm::ExecutionEngine& engine);
|
||||
PPUTranslator(llvm::LLVMContext& context, llvm::Module* _module, const ppu_module& info, llvm::ExecutionEngine& engine);
|
||||
~PPUTranslator();
|
||||
|
||||
// Get thread context struct type
|
||||
|
@ -4261,10 +4261,10 @@ public:
|
||||
m_engine->clearAllGlobalMappings();
|
||||
|
||||
// Create LLVM module
|
||||
std::unique_ptr<Module> module = std::make_unique<Module>(m_hash + ".obj", m_context);
|
||||
module->setTargetTriple(Triple::normalize("x86_64-unknown-linux-gnu"));
|
||||
module->setDataLayout(m_jit.get_engine().getTargetMachine()->createDataLayout());
|
||||
m_module = module.get();
|
||||
std::unique_ptr<Module> _module = std::make_unique<Module>(m_hash + ".obj", m_context);
|
||||
_module->setTargetTriple(Triple::normalize("x86_64-unknown-linux-gnu"));
|
||||
_module->setDataLayout(m_jit.get_engine().getTargetMachine()->createDataLayout());
|
||||
m_module = _module.get();
|
||||
|
||||
// Initialize IR Builder
|
||||
IRBuilder<> irb(m_context);
|
||||
@ -4450,7 +4450,7 @@ public:
|
||||
m_ir->CreateUnreachable();
|
||||
}
|
||||
|
||||
m_dispatch = cast<Function>(module->getOrInsertFunction("spu-null", entry_chunk->chunk->getFunctionType()).getCallee());
|
||||
m_dispatch = cast<Function>(_module->getOrInsertFunction("spu-null", entry_chunk->chunk->getFunctionType()).getCallee());
|
||||
m_dispatch->setLinkage(llvm::GlobalValue::InternalLinkage);
|
||||
m_dispatch->setCallingConv(entry_chunk->chunk->getCallingConv());
|
||||
set_function(m_dispatch);
|
||||
@ -4709,7 +4709,7 @@ public:
|
||||
}
|
||||
|
||||
// Initialize pass manager
|
||||
legacy::FunctionPassManager pm(module.get());
|
||||
legacy::FunctionPassManager pm(_module.get());
|
||||
|
||||
// Basic optimizations
|
||||
pm.add(createEarlyCSEPass());
|
||||
@ -4765,11 +4765,11 @@ public:
|
||||
if (g_cfg.core.spu_debug)
|
||||
{
|
||||
fmt::append(log, "LLVM IR at 0x%x:\n", func.entry_point);
|
||||
out << *module; // print IR
|
||||
out << *_module; // print IR
|
||||
out << "\n\n";
|
||||
}
|
||||
|
||||
if (verifyModule(*module, &out))
|
||||
if (verifyModule(*_module, &out))
|
||||
{
|
||||
out.flush();
|
||||
spu_log.error("LLVM: Verification failed at 0x%x:\n%s", func.entry_point, log);
|
||||
@ -4785,11 +4785,11 @@ public:
|
||||
if (g_cfg.core.spu_debug)
|
||||
{
|
||||
// Testing only
|
||||
m_jit.add(std::move(module), m_spurt->get_cache_path() + "llvm/");
|
||||
m_jit.add(std::move(_module), m_spurt->get_cache_path() + "llvm/");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_jit.add(std::move(module));
|
||||
m_jit.add(std::move(_module));
|
||||
}
|
||||
|
||||
m_jit.fin();
|
||||
@ -4861,10 +4861,10 @@ public:
|
||||
m_engine->clearAllGlobalMappings();
|
||||
|
||||
// Create LLVM module
|
||||
std::unique_ptr<Module> module = std::make_unique<Module>("spu_interpreter.obj", m_context);
|
||||
module->setTargetTriple(Triple::normalize("x86_64-unknown-linux-gnu"));
|
||||
module->setDataLayout(m_jit.get_engine().getTargetMachine()->createDataLayout());
|
||||
m_module = module.get();
|
||||
std::unique_ptr<Module> _module = std::make_unique<Module>("spu_interpreter.obj", m_context);
|
||||
_module->setTargetTriple(Triple::normalize("x86_64-unknown-linux-gnu"));
|
||||
_module->setDataLayout(m_jit.get_engine().getTargetMachine()->createDataLayout());
|
||||
m_module = _module.get();
|
||||
|
||||
// Initialize IR Builder
|
||||
IRBuilder<> irb(m_context);
|
||||
@ -4876,7 +4876,7 @@ public:
|
||||
m_function_table = new GlobalVariable(*m_module, ArrayType::get(if_type->getPointerTo(), 1ull << m_interp_magn), true, GlobalValue::InternalLinkage, nullptr);
|
||||
|
||||
// Add return function
|
||||
const auto ret_func = cast<Function>(module->getOrInsertFunction("spu_ret", if_type).getCallee());
|
||||
const auto ret_func = cast<Function>(_module->getOrInsertFunction("spu_ret", if_type).getCallee());
|
||||
ret_func->setCallingConv(CallingConv::GHC);
|
||||
ret_func->setLinkage(GlobalValue::InternalLinkage);
|
||||
m_ir->SetInsertPoint(BasicBlock::Create(m_context, "", ret_func));
|
||||
@ -4966,7 +4966,7 @@ public:
|
||||
}
|
||||
|
||||
// Decode instruction name, access function
|
||||
const auto f = cast<Function>(module->getOrInsertFunction(fname, if_type).getCallee());
|
||||
const auto f = cast<Function>(_module->getOrInsertFunction(fname, if_type).getCallee());
|
||||
|
||||
// Build if necessary
|
||||
if (f->empty())
|
||||
@ -5179,7 +5179,7 @@ public:
|
||||
m_function_table = nullptr;
|
||||
|
||||
// Initialize pass manager
|
||||
legacy::FunctionPassManager pm(module.get());
|
||||
legacy::FunctionPassManager pm(_module.get());
|
||||
|
||||
// Basic optimizations
|
||||
pm.add(createEarlyCSEPass());
|
||||
@ -5195,11 +5195,11 @@ public:
|
||||
if (g_cfg.core.spu_debug)
|
||||
{
|
||||
fmt::append(log, "LLVM IR (interpreter):\n");
|
||||
out << *module; // print IR
|
||||
out << *_module; // print IR
|
||||
out << "\n\n";
|
||||
}
|
||||
|
||||
if (verifyModule(*module, &out))
|
||||
if (verifyModule(*_module, &out))
|
||||
{
|
||||
out.flush();
|
||||
spu_log.error("LLVM: Verification failed:\n%s", log);
|
||||
@ -5215,11 +5215,11 @@ public:
|
||||
if (g_cfg.core.spu_debug)
|
||||
{
|
||||
// Testing only
|
||||
m_jit.add(std::move(module), m_spurt->get_cache_path() + "llvm/");
|
||||
m_jit.add(std::move(_module), m_spurt->get_cache_path() + "llvm/");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_jit.add(std::move(module));
|
||||
m_jit.add(std::move(_module));
|
||||
}
|
||||
|
||||
m_jit.fin();
|
||||
@ -7445,7 +7445,7 @@ public:
|
||||
const auto mb = eval(sext<s32[4]>(fcmp_uno(b != fsplat<f32[4]>(0.))));
|
||||
const auto ca = eval(bitcast<f32[4]>(bitcast<s32[4]>(a) & mb));
|
||||
const auto cb = eval(bitcast<f32[4]>(bitcast<s32[4]>(b) & ma));
|
||||
|
||||
|
||||
// Optimization: Emit only a floating multiply if the addend is zero
|
||||
// This is odd since SPU code could just use the FM instruction, but it seems common enough
|
||||
if (auto cv = llvm::dyn_cast<llvm::Constant>(c.value))
|
||||
|
@ -784,7 +784,7 @@ void main_window::DecryptSPRXLibraries()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!m_gui_settings->GetBootConfirmation(this))
|
||||
{
|
||||
return;
|
||||
@ -797,9 +797,9 @@ void main_window::DecryptSPRXLibraries()
|
||||
|
||||
gui_log.notice("Decrypting binaries...");
|
||||
|
||||
for (const QString& module : modules)
|
||||
for (const QString& _module : modules)
|
||||
{
|
||||
const std::string old_path = sstr(module);
|
||||
const std::string old_path = sstr(_module);
|
||||
|
||||
fs::file elf_file(old_path);
|
||||
|
||||
@ -809,7 +809,7 @@ void main_window::DecryptSPRXLibraries()
|
||||
|
||||
if (elf_file)
|
||||
{
|
||||
const std::string bin_ext = module.toLower().endsWith(".sprx") ? ".prx" : ".elf";
|
||||
const std::string bin_ext = _module.toLower().endsWith(".sprx") ? ".prx" : ".elf";
|
||||
const std::string new_path = old_path.substr(0, old_path.find_last_of('.')) + bin_ext;
|
||||
|
||||
if (fs::file new_file{new_path, fs::rewrite})
|
||||
|
Loading…
Reference in New Issue
Block a user