mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 07:21:25 +12:00
PPU: preparations (no fixes)
This commit is contained in:
parent
061c92ba1f
commit
89f676de75
5 changed files with 43 additions and 18 deletions
|
@ -41,11 +41,33 @@ struct ppu_function
|
||||||
std::string name; // Function name
|
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
|
// PPU Module Information
|
||||||
struct ppu_module
|
struct ppu_module
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::vector<ppu_reloc> rels;
|
||||||
|
std::vector<ppu_segment> segs;
|
||||||
std::vector<ppu_function> funcs;
|
std::vector<ppu_function> funcs;
|
||||||
|
std::vector<ppu_segment> sections;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Aux
|
// Aux
|
||||||
|
|
|
@ -1224,13 +1224,15 @@ void ppu_load_exec(const ppu_exec_object& elf)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// Analyse executable
|
// Analyse executable (TODO)
|
||||||
std::vector<ppu_function> main_funcs = ppu_analyse(segments, sections, 0, elf.header.e_entry);
|
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
|
// Set for delayed initialization in ppu_initialize()
|
||||||
fxm::make<std::vector<ppu_function>>(std::move(main_funcs));
|
fxm::make<ppu_module>(std::move(_main));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set SDK version
|
// Set SDK version
|
||||||
|
|
|
@ -876,15 +876,15 @@ static bool adde_carry(u64 a, u64 b, bool c)
|
||||||
|
|
||||||
extern void ppu_initialize()
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize main module
|
// Initialize main module
|
||||||
ppu_initialize({"", std::move(*_funcs)});
|
ppu_initialize(*_main);
|
||||||
|
|
||||||
std::vector<lv2_prx*> prx_list;
|
std::vector<lv2_prx*> prx_list;
|
||||||
|
|
||||||
|
@ -985,7 +985,8 @@ extern void ppu_initialize(const ppu_module& info)
|
||||||
// Split module into fragments <= 1 MiB
|
// Split module into fragments <= 1 MiB
|
||||||
std::size_t fpos = 0;
|
std::size_t fpos = 0;
|
||||||
|
|
||||||
ppu_module part;
|
// Copy module information
|
||||||
|
ppu_module part = info;
|
||||||
|
|
||||||
while (fpos < info.funcs.size())
|
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()));
|
module->setTargetTriple(Triple::normalize(sys::getProcessTriple()));
|
||||||
|
|
||||||
// Initialize translator
|
// 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
|
// Define some types
|
||||||
const auto _void = Type::getVoidTy(jit.get_context());
|
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
|
// Initialize function list
|
||||||
for (const auto& func : module_part.funcs)
|
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
|
// Translate
|
||||||
const auto func = translator->Translate(module_part.funcs[fi]);
|
const auto func = translator.Translate(module_part.funcs[fi]);
|
||||||
|
|
||||||
// Run optimization passes
|
// Run optimization passes
|
||||||
pm.run(*func);
|
pm.run(*func);
|
||||||
|
|
|
@ -64,11 +64,11 @@ const ppu_decoder<PPUTranslator> s_ppu_decoder;
|
||||||
GetGpr(op.ra),\
|
GetGpr(op.ra),\
|
||||||
GetGpr(op.rb)))
|
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_context(context)
|
||||||
, m_module(module)
|
, m_module(module)
|
||||||
, m_base_addr(base)
|
|
||||||
, m_is_be(false)
|
, m_is_be(false)
|
||||||
|
, m_info(info)
|
||||||
, m_pure_attr(AttributeSet::get(m_context, AttributeSet::FunctionIndex, {Attribute::NoUnwind, Attribute::ReadNone}))
|
, m_pure_attr(AttributeSet::get(m_context, AttributeSet::FunctionIndex, {Attribute::NoUnwind, Attribute::ReadNone}))
|
||||||
{
|
{
|
||||||
// Memory base
|
// Memory base
|
||||||
|
|
|
@ -110,12 +110,12 @@ class PPUTranslator final //: public CPUTranslator
|
||||||
// Module to which all generated code is output to
|
// Module to which all generated code is output to
|
||||||
llvm::Module* const m_module;
|
llvm::Module* const m_module;
|
||||||
|
|
||||||
// Base address (TODO)
|
|
||||||
const u64 m_base_addr;
|
|
||||||
|
|
||||||
// Endianness, affects vector element numbering (TODO)
|
// Endianness, affects vector element numbering (TODO)
|
||||||
const bool m_is_be;
|
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
|
// Attributes for function calls which are "pure" and may be optimized away if their results are unused
|
||||||
const llvm::AttributeSet m_pure_attr;
|
const llvm::AttributeSet m_pure_attr;
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ public:
|
||||||
// Handle compilation errors
|
// Handle compilation errors
|
||||||
void CompilationError(const std::string& error);
|
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();
|
~PPUTranslator();
|
||||||
|
|
||||||
// Get thread context struct type
|
// Get thread context struct type
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue