llvm: Implement trap instructions

This commit is contained in:
Vincent Lejeune 2015-12-29 21:06:04 +01:00
parent 2da52d0309
commit 082815f93e
2 changed files with 101 additions and 4 deletions

View file

@ -362,6 +362,17 @@ static void wrapped_fast_stop(PPUThread &CPU)
CPU.fast_stop();
}
static void wrapped_trap(PPUThread &CPU, u32) noexcept {
try
{
throw EXCEPTION("trap");
}
catch (...)
{
CPU.pending_exception = std::current_exception();
}
}
std::pair<Executable, llvm::ExecutionEngine *> RecompilationEngine::compile(const std::string & name, u32 start_address, u32 instruction_count) {
std::unique_ptr<llvm::Module> module = Compiler::create_module(m_llvm_context);
@ -375,6 +386,7 @@ std::pair<Executable, llvm::ExecutionEngine *> RecompilationEngine::compile(cons
function_ptrs["get_timebased_time"] = reinterpret_cast<void*>(get_timebased_time);
function_ptrs["wrappedExecutePPUFuncByIndex"] = reinterpret_cast<void*>(wrappedExecutePPUFuncByIndex);
function_ptrs["wrappedDoSyscall"] = reinterpret_cast<void*>(wrappedDoSyscall);
function_ptrs["trap"] = reinterpret_cast<void*>(wrapped_trap);
#define REGISTER_FUNCTION_PTR(name) \
function_ptrs[#name] = reinterpret_cast<void*>(PPUInterpreter::name##_impl);