SPU LLVM Precompilation Fixup

This commit is contained in:
Elad Ashkenazi 2023-08-28 12:20:17 +03:00
parent b5faf5800b
commit 3d2229ca05
2 changed files with 17 additions and 36 deletions

View File

@ -699,7 +699,19 @@ void spu_cache::initialize()
auto data_list = std::move(g_fxo->get<spu_section_data>().data);
g_fxo->get<spu_section_data>().had_been_used = true;
atomic_t<usz> data_indexer{};
const bool spu_precompilation_enabled = func_list.empty() && g_cfg.core.spu_cache && g_cfg.core.llvm_precompilation;
if (spu_precompilation_enabled)
{
// What compiles in this case goes straight to disk
g_fxo->get<spu_cache>() = std::move(cache);
}
else
{
data_list.clear();
}
atomic_t<usz> data_indexer = 0;
if (g_cfg.core.spu_decoder == spu_decoder_type::dynamic || g_cfg.core.spu_decoder == spu_decoder_type::llvm)
{
@ -742,12 +754,9 @@ void spu_cache::initialize()
u32 add_count = ::size32(func_list);
if (func_list.empty())
for (auto& sec : data_list)
{
for (auto& sec : data_list)
{
add_count += sec.funcs.size();
}
add_count += sec.funcs.size();
}
g_progr_ptotal += add_count;
@ -847,12 +856,6 @@ void spu_cache::initialize()
result++;
}
if (!func_list.empty() || !g_cfg.core.llvm_precompilation)
{
// Cache has already been initiated or the user does not want to precompile SPU programs
return result;
}
u32 last_sec_idx = umax;
for (usz func_i = data_indexer++;; func_i = data_indexer++, g_progr_pdone++)
@ -1077,7 +1080,7 @@ void spu_cache::initialize()
}
// Initialize global cache instance
if (g_cfg.core.spu_cache)
if (g_cfg.core.spu_cache && cache)
{
g_fxo->get<spu_cache>() = std::move(cache);
}
@ -2900,8 +2903,6 @@ spu_program spu_recompiler_base::analyse(const be_t<u32>* ls, u32 entry_point)
}
}
spu_program result2 = result;
while (lsa > 0 || limit < 0x40000)
{
const u32 initial_size = ::size32(result.data);
@ -3348,13 +3349,7 @@ spu_program spu_recompiler_base::analyse(const be_t<u32>* ls, u32 entry_point)
{
workload.clear();
workload.push_back(entry_point);
if (!m_bbs.count(entry_point))
{
std::string func_bad;
dump(result2, func_bad);
spu_log.error("%s", func_bad);
return {};
}
ensure(m_bbs.count(entry_point));
std::basic_string<u32> new_entries;

View File

@ -487,20 +487,6 @@ std::array<u32, 2> op_branch_targets(u32 pc, spu_opcode_t op)
case spu_itype::BRASL:
{
const int index = (type == spu_itype::BR || type == spu_itype::BRA || type == spu_itype::BRSL || type == spu_itype::BRASL ? 0 : 1);
// if (type == spu_itype::BRASL || type == spu_itype::BRA)
// {
// res[index] = spu_branch_target(0, op.i16);
// }
// else
// {
// // Treat i16 as signed, this allows the caller to detect "overflows" and "underflows" in address in order to detect invalid branches
// // Example:
// // [0x3fffc] BR +4 -> BR 0 -> invalid
// // [0x3fffc] BR 0x3fff4 -> BR 0 -> invalid
// const u32 add = static_cast<s16>(op.si16);
// }
res[index] = (spu_branch_target(type == spu_itype::BRASL || type == spu_itype::BRA ? 0 : pc, op.i16));
if (res[0] == res[1])