mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-08 16:01:42 +12:00
PPU: HACK instruction removed
Breakpoints fixed
This commit is contained in:
parent
ddd6ebc58d
commit
3bfe17a14f
20 changed files with 155 additions and 379 deletions
|
@ -102,7 +102,6 @@ const ppu_decoder<ppu_interpreter_fast> s_ppu_interpreter_fast;
|
|||
extern void ppu_initialize();
|
||||
extern void ppu_initialize(const ppu_module& info);
|
||||
extern void ppu_execute_syscall(ppu_thread& ppu, u64 code);
|
||||
extern void ppu_execute_function(ppu_thread& ppu, u32 index);
|
||||
|
||||
const auto s_ppu_compiled = static_cast<u32*>(utils::memory_reserve(0x100000000));
|
||||
|
||||
|
@ -157,24 +156,34 @@ extern void ppu_register_range(u32 addr, u32 size)
|
|||
|
||||
extern void ppu_register_function_at(u32 addr, u32 size, ppu_function_t ptr)
|
||||
{
|
||||
// Initialize specific function
|
||||
if (ptr)
|
||||
{
|
||||
s_ppu_compiled[addr / 4] = ::narrow<u32>(reinterpret_cast<std::uintptr_t>(ptr));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!size)
|
||||
{
|
||||
LOG_ERROR(PPU, "ppu_register_function_at(0x%x): empty range", addr);
|
||||
return;
|
||||
}
|
||||
|
||||
ppu_register_range(addr, size);
|
||||
|
||||
if (g_cfg_ppu_decoder.get() == ppu_decoder_type::llvm)
|
||||
{
|
||||
s_ppu_compiled[addr / 4] = ::narrow<u32>(reinterpret_cast<std::uintptr_t>(ptr));
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize interpreter cache
|
||||
const u32 fallback = ::narrow<u32>(reinterpret_cast<std::uintptr_t>(ppu_fallback));
|
||||
|
||||
while (size)
|
||||
{
|
||||
s_ppu_compiled[addr / 4] = ppu_cache(addr);
|
||||
if (s_ppu_compiled[addr / 4] == fallback)
|
||||
{
|
||||
s_ppu_compiled[addr / 4] = ppu_cache(addr);
|
||||
}
|
||||
|
||||
addr += 4;
|
||||
size -= 4;
|
||||
}
|
||||
|
@ -354,7 +363,7 @@ void ppu_thread::cpu_task()
|
|||
}
|
||||
case ppu_cmd::hle_call:
|
||||
{
|
||||
cmd_pop(), ppu_execute_function(*this, arg);
|
||||
cmd_pop(), ppu_function_manager::get().at(arg)(*this);
|
||||
break;
|
||||
}
|
||||
case ppu_cmd::initialize:
|
||||
|
@ -379,7 +388,8 @@ void ppu_thread::exec_task()
|
|||
{
|
||||
if (g_cfg_ppu_decoder.get() == ppu_decoder_type::llvm)
|
||||
{
|
||||
return reinterpret_cast<ppu_function_t>((std::uintptr_t)s_ppu_compiled[cia / 4])(*this);
|
||||
reinterpret_cast<ppu_function_t>(static_cast<std::uintptr_t>(s_ppu_compiled[cia / 4]))(*this);
|
||||
return;
|
||||
}
|
||||
|
||||
const auto base = vm::_ptr<const u8>(0);
|
||||
|
@ -558,7 +568,7 @@ void ppu_thread::fast_call(u32 addr, u32 rtoc)
|
|||
|
||||
cia = addr;
|
||||
gpr[2] = rtoc;
|
||||
lr = Emu.GetCPUThreadStop();
|
||||
lr = ppu_function_manager::addr + 8; // HLE stop address
|
||||
last_function = nullptr;
|
||||
|
||||
g_tls_log_prefix = []
|
||||
|
@ -662,8 +672,6 @@ const ppu_decoder<ppu_itype> s_ppu_itype;
|
|||
extern u64 get_timebased_time();
|
||||
extern ppu_function_t ppu_get_syscall(u64 code);
|
||||
extern std::string ppu_get_syscall_name(u64 code);
|
||||
extern ppu_function_t ppu_get_function(u32 index);
|
||||
extern std::string ppu_get_module_function_name(u32 index);
|
||||
|
||||
extern __m128 sse_exp2_ps(__m128 A);
|
||||
extern __m128 sse_log2_ps(__m128 A);
|
||||
|
@ -782,25 +790,6 @@ extern void ppu_initialize()
|
|||
return;
|
||||
}
|
||||
|
||||
if (g_cfg_ppu_decoder.get() != ppu_decoder_type::llvm || _funcs->empty())
|
||||
{
|
||||
if (!Emu.GetCPUThreadStop())
|
||||
{
|
||||
auto ppu_thr_stop_data = vm::ptr<u32>::make(vm::alloc(2 * 4, vm::main));
|
||||
Emu.SetCPUThreadStop(ppu_thr_stop_data.addr());
|
||||
ppu_thr_stop_data[0] = ppu_instructions::HACK(1);
|
||||
ppu_thr_stop_data[1] = ppu_instructions::BLR();
|
||||
ppu_register_function_at(ppu_thr_stop_data.addr(), 8, nullptr);
|
||||
}
|
||||
|
||||
for (const auto& func : *_funcs)
|
||||
{
|
||||
ppu_register_function_at(func.addr, func.size, nullptr);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::size_t fpos = 0;
|
||||
|
||||
while (fpos < _funcs->size())
|
||||
|
@ -891,7 +880,6 @@ extern void ppu_initialize(const ppu_module& info)
|
|||
{ "__end", (u64)&ppu_unreachable },
|
||||
{ "__check", (u64)&ppu_check },
|
||||
{ "__trace", (u64)&ppu_trace },
|
||||
{ "__hlecall", (u64)&ppu_execute_function },
|
||||
{ "__syscall", (u64)&ppu_execute_syscall },
|
||||
{ "__get_tb", (u64)&get_timebased_time },
|
||||
{ "__lwarx", (u64)&ppu_lwarx },
|
||||
|
@ -918,18 +906,6 @@ extern void ppu_initialize(const ppu_module& info)
|
|||
}
|
||||
}
|
||||
|
||||
for (u64 index = 1; ; index++)
|
||||
{
|
||||
if (auto func = ppu_get_function(index))
|
||||
{
|
||||
link_table.emplace(ppu_get_module_function_name(index), (u64)func);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const auto jit = fxm::make<jit_compiler>(std::move(link_table), g_cfg_llvm_cpu.get());
|
||||
|
||||
LOG_SUCCESS(PPU, "LLVM: JIT initialized (%s)", jit->cpu());
|
||||
|
@ -1058,7 +1034,6 @@ extern void ppu_initialize(const ppu_module& info)
|
|||
pm.run(*func);
|
||||
|
||||
const auto _syscall = module->getFunction("__syscall");
|
||||
const auto _hlecall = module->getFunction("__hlecall");
|
||||
|
||||
for (auto i = inst_begin(*func), end = inst_end(*func); i != end;)
|
||||
{
|
||||
|
@ -1084,20 +1059,6 @@ extern void ppu_initialize(const ppu_module& info)
|
|||
}
|
||||
}
|
||||
|
||||
if (cif == _hlecall && op1 && isa<ConstantInt>(op1))
|
||||
{
|
||||
const u32 index = static_cast<u32>(cast<ConstantInt>(op1)->getZExtValue());
|
||||
|
||||
if (const auto ptr = ppu_get_function(index))
|
||||
{
|
||||
const auto n = ppu_get_module_function_name(index);
|
||||
const auto f = cast<Function>(module->getOrInsertFunction(n, _func));
|
||||
|
||||
// Call the function directly
|
||||
ReplaceInstWithInst(ci, CallInst::Create(f, {ci->getArgOperand(0)}));
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue