Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial SPU LLVM Precompilation #14565

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion rpcs3/Emu/Cell/PPUModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,13 @@ static void ppu_check_patch_spu_images(const ppu_module& mod, const ppu_segment&

if (prog.p_type == 0x1u /* LOAD */ && prog.p_filesz > 0u)
{
if (prog.p_vaddr)
{
extern void utilize_spu_data_segment(u32 vaddr, const void* ls_data_vaddr, u32 size);

utilize_spu_data_segment(prog.p_vaddr, (elf_header + prog.p_offset), prog.p_filesz);
}

sha1_update(&sha2, (elf_header + prog.p_offset), prog.p_filesz);
}

Expand All @@ -1119,7 +1126,7 @@ static void ppu_check_patch_spu_images(const ppu_module& mod, const ppu_segment&

if (!name.empty())
{
fmt::append(dump, "\n\tSPUNAME: '%s'", name);
fmt::append(dump, "\n\tSPUNAME: '%s' (image addr: 0x%x)", name, seg.addr + i);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/PPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4030,7 +4030,7 @@ extern void ppu_initialize()

const std::string mount_point = vfs::get("/dev_flash/");

bool dev_flash_located = !Emu.GetCat().ends_with('P') && Emu.IsPathInsideDir(Emu.GetBoot(), mount_point) && g_cfg.core.ppu_llvm_precompilation;
bool dev_flash_located = !Emu.GetCat().ends_with('P') && Emu.IsPathInsideDir(Emu.GetBoot(), mount_point) && g_cfg.core.llvm_precompilation;

if (compile_fw || dev_flash_located)
{
Expand All @@ -4050,7 +4050,7 @@ extern void ppu_initialize()
}

// Avoid compilation if main's cache exists or it is a standalone SELF with no PARAM.SFO
if (compile_main && g_cfg.core.ppu_llvm_precompilation && !Emu.GetTitleID().empty() && !Emu.IsChildProcess())
if (compile_main && g_cfg.core.llvm_precompilation && !Emu.GetTitleID().empty() && !Emu.IsChildProcess())
{
// Try to add all related directories
const std::set<std::string> dirs = Emu.GetGameDirs();
Expand Down
12 changes: 12 additions & 0 deletions rpcs3/Emu/Cell/RawSPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,18 @@ void spu_load_exec(const spu_exec_object& elf)

spu->status_npc = {SPU_STATUS_RUNNING, elf.header.e_entry};
atomic_storage<u32>::release(spu->pc, elf.header.e_entry);

const auto funcs = spu->discover_functions(spu->ls, umax);

for (u32 addr : funcs)
{
spu_log.success("Found SPU function at: 0x%08x", addr);
}

if (!funcs.empty())
{
spu_log.success("Found %u SPU functions", funcs.size());
}
}

void spu_load_rel_exec(const spu_rel_object& elf)
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/Cell/SPUOpcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ union spu_opcode_t
bf_t<u32, 7, 18> i18; // 7..24
};

inline u32 spu_branch_target(u32 pc, u32 imm = 0)
constexpr u32 spu_branch_target(u32 pc, u32 imm = 0)
{
return (pc + (imm << 2)) & 0x3fffc;
}

inline u32 spu_ls_target(u32 pc, u32 imm = 0)
constexpr u32 spu_ls_target(u32 pc, u32 imm = 0)
{
return (pc + (imm << 2)) & 0x3fff0;
}

inline u32 spu_decode(u32 inst)
constexpr u32 spu_decode(u32 inst)
{
return inst >> 21;
}
Expand Down
Loading