mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
PPU: preparations (no fixes)
This commit is contained in:
parent
061c92ba1f
commit
89f676de75
@ -41,11 +41,33 @@ struct ppu_function
|
||||
std::string name; // Function name
|
||||
};
|
||||
|
||||
// PPU Relocation Information
|
||||
struct ppu_reloc
|
||||
{
|
||||
u32 type;
|
||||
u32 off;
|
||||
u32 ptr;
|
||||
u8 index_value;
|
||||
u8 index_addr;
|
||||
};
|
||||
|
||||
// PPU Segment Information
|
||||
struct ppu_segment
|
||||
{
|
||||
u32 addr;
|
||||
u32 size;
|
||||
u32 type;
|
||||
u32 flags;
|
||||
};
|
||||
|
||||
// PPU Module Information
|
||||
struct ppu_module
|
||||
{
|
||||
std::string name;
|
||||
std::vector<ppu_reloc> rels;
|
||||
std::vector<ppu_segment> segs;
|
||||
std::vector<ppu_function> funcs;
|
||||
std::vector<ppu_segment> sections;
|
||||
};
|
||||
|
||||
// Aux
|
||||
|
@ -1224,13 +1224,15 @@ void ppu_load_exec(const ppu_exec_object& elf)
|
||||
}
|
||||
|
||||
{
|
||||
// Analyse executable
|
||||
std::vector<ppu_function> main_funcs = ppu_analyse(segments, sections, 0, elf.header.e_entry);
|
||||
// Analyse executable (TODO)
|
||||
ppu_module _main;
|
||||
_main.funcs = ppu_analyse(segments, sections, 0, elf.header.e_entry);
|
||||
|
||||
ppu_validate(vfs::get(Emu.GetPath()), main_funcs, 0);
|
||||
// Validate analyser results (not required)
|
||||
ppu_validate(vfs::get(Emu.GetPath()), _main.funcs, 0);
|
||||
|
||||
// Share function list
|
||||
fxm::make<std::vector<ppu_function>>(std::move(main_funcs));
|
||||
// Set for delayed initialization in ppu_initialize()
|
||||
fxm::make<ppu_module>(std::move(_main));
|
||||
}
|
||||
|
||||
// Set SDK version
|
||||
|
@ -876,15 +876,15 @@ static bool adde_carry(u64 a, u64 b, bool c)
|
||||
|
||||
extern void ppu_initialize()
|
||||
{
|
||||
const auto _funcs = fxm::withdraw<std::vector<ppu_function>>();
|
||||
const auto _main = fxm::withdraw<ppu_module>();
|
||||
|
||||
if (!_funcs)
|
||||
if (!_main)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize main module
|
||||
ppu_initialize({"", std::move(*_funcs)});
|
||||
ppu_initialize(*_main);
|
||||
|
||||
std::vector<lv2_prx*> prx_list;
|
||||
|
||||
@ -985,7 +985,8 @@ extern void ppu_initialize(const ppu_module& info)
|
||||
// Split module into fragments <= 1 MiB
|
||||
std::size_t fpos = 0;
|
||||
|
||||
ppu_module part;
|
||||
// Copy module information
|
||||
ppu_module part = info;
|
||||
|
||||
while (fpos < info.funcs.size())
|
||||
{
|
||||
@ -1157,11 +1158,11 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
|
||||
module->setTargetTriple(Triple::normalize(sys::getProcessTriple()));
|
||||
|
||||
// Initialize translator
|
||||
std::unique_ptr<PPUTranslator> translator = std::make_unique<PPUTranslator>(jit.get_context(), module.get(), 0);
|
||||
PPUTranslator translator(jit.get_context(), module.get(), module_part);
|
||||
|
||||
// Define some types
|
||||
const auto _void = Type::getVoidTy(jit.get_context());
|
||||
const auto _func = FunctionType::get(_void, {translator->GetContextType()->getPointerTo()}, false);
|
||||
const auto _func = FunctionType::get(_void, {translator.GetContextType()->getPointerTo()}, false);
|
||||
|
||||
// Initialize function list
|
||||
for (const auto& func : module_part.funcs)
|
||||
@ -1240,7 +1241,7 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module& module_part, co
|
||||
});
|
||||
|
||||
// Translate
|
||||
const auto func = translator->Translate(module_part.funcs[fi]);
|
||||
const auto func = translator.Translate(module_part.funcs[fi]);
|
||||
|
||||
// Run optimization passes
|
||||
pm.run(*func);
|
||||
|
@ -64,11 +64,11 @@ const ppu_decoder<PPUTranslator> s_ppu_decoder;
|
||||
GetGpr(op.ra),\
|
||||
GetGpr(op.rb)))
|
||||
|
||||
PPUTranslator::PPUTranslator(LLVMContext& context, Module* module, u64 base)
|
||||
PPUTranslator::PPUTranslator(LLVMContext& context, Module* module, const ppu_module& info)
|
||||
: m_context(context)
|
||||
, m_module(module)
|
||||
, m_base_addr(base)
|
||||
, m_is_be(false)
|
||||
, m_info(info)
|
||||
, m_pure_attr(AttributeSet::get(m_context, AttributeSet::FunctionIndex, {Attribute::NoUnwind, Attribute::ReadNone}))
|
||||
{
|
||||
// Memory base
|
||||
|
@ -110,12 +110,12 @@ class PPUTranslator final //: public CPUTranslator
|
||||
// Module to which all generated code is output to
|
||||
llvm::Module* const m_module;
|
||||
|
||||
// Base address (TODO)
|
||||
const u64 m_base_addr;
|
||||
|
||||
// Endianness, affects vector element numbering (TODO)
|
||||
const bool m_is_be;
|
||||
|
||||
// PPU Module
|
||||
const ppu_module& m_info;
|
||||
|
||||
// Attributes for function calls which are "pure" and may be optimized away if their results are unused
|
||||
const llvm::AttributeSet m_pure_attr;
|
||||
|
||||
@ -402,7 +402,7 @@ public:
|
||||
// Handle compilation errors
|
||||
void CompilationError(const std::string& error);
|
||||
|
||||
PPUTranslator(llvm::LLVMContext& context, llvm::Module* module, u64 base);
|
||||
PPUTranslator(llvm::LLVMContext& context, llvm::Module* module, const ppu_module& info);
|
||||
~PPUTranslator();
|
||||
|
||||
// Get thread context struct type
|
||||
|
Loading…
Reference in New Issue
Block a user