PPU LLVM: allow to drop setting SAT flag (optimization, module-wide)

Implement ppu_attr::has_mfvscr (partially, module-wide search).
If this instruction isn't found, allow to drop setting SAT flag.
It's based on presumption that only MFVSCR can retrieve SAT flag.
This commit is contained in:
Nekotekina 2021-06-25 10:50:42 +03:00
parent 86b194014b
commit c9d8e59dbf
5 changed files with 57 additions and 1 deletions

View file

@ -3099,6 +3099,44 @@ bool ppu_initialize(const ppu_module& info, bool check_only)
bool compiled_new = false;
bool has_mfvscr = false;
for (auto& func : info.funcs)
{
if (func.size == 0)
{
continue;
}
for (const auto& [addr, size] : func.blocks)
{
if (size == 0)
{
continue;
}
for (u32 i = addr; i < addr + size; i += 4)
{
if (g_ppu_itype.decode(vm::read32(i)) == ppu_itype::MFVSCR)
{
ppu_log.warning("MFVSCR found");
has_mfvscr = true;
break;
}
}
if (has_mfvscr)
{
break;
}
}
if (has_mfvscr)
{
break;
}
}
while (!jit_mod.init && fpos < info.funcs.size())
{
// Initialize compiler instance
@ -3140,6 +3178,12 @@ bool ppu_initialize(const ppu_module& info, bool check_only)
// Fixup some information
entry.name = fmt::format("__0x%x", entry.addr - reloc);
if (has_mfvscr)
{
// TODO
entry.attr += ppu_attr::has_mfvscr;
}
if (entry.blocks.empty())
{
entry.blocks.emplace(func.addr, func.size);
@ -3257,6 +3301,7 @@ bool ppu_initialize(const ppu_module& info, bool check_only)
accurate_cache_line_stores,
reservations_128_byte,
greedy_mode,
has_mfvscr,
__bitset_enum_max
};
@ -3278,6 +3323,8 @@ bool ppu_initialize(const ppu_module& info, bool check_only)
settings += ppu_settings::reservations_128_byte;
if (g_cfg.core.ppu_llvm_greedy_mode)
settings += ppu_settings::greedy_mode;
if (has_mfvscr)
settings += ppu_settings::has_mfvscr;
// Write version, hash, CPU, settings
fmt::append(obj_name, "v5-kusa-%s-%s-%s.obj", fmt::base57(output, 16), fmt::base57(settings), jit_compiler::cpu(g_cfg.core.llvm_cpu));