Interpreter: Pass Interpreter to CPU instruction functions.

This commit is contained in:
Admiral H. Curtiss committed 2023-03-19 03:05:11 +01:00
1 parent a4d3342419
commit 919182eda2
13 files changed
+489 -476

No files matched your search

@@ -19,6 +19,7 @@ struct CachedInterpreter::Instruction
{
using CommonCallback = void (*)(UGeckoInstruction);
using ConditionalCallback = bool (*)(u32);
using InterpreterCallback = void (*)(Interpreter&, UGeckoInstruction);
Instruction() {}
Instruction(const CommonCallback c, UGeckoInstruction i)
@@ -31,17 +32,24 @@ struct CachedInterpreter::Instruction
{
}
Instruction(const InterpreterCallback c, UGeckoInstruction i)
: interpreter_callback(c), data(i.hex), type(Type::Interpreter)
{
}
enum class Type
{
Abort,
Common,
Conditional,
Interpreter,
};
union
{
const CommonCallback common_callback = nullptr;
const ConditionalCallback conditional_callback;
const InterpreterCallback interpreter_callback;
};
u32 data = 0;
@@ -100,6 +108,10 @@ void CachedInterpreter::ExecuteOneBlock()
return;
break;
case Instruction::Type::Interpreter:
code->interpreter_callback(*Interpreter::getInstance(), UGeckoInstruction(code->data));
break;
default:
ERROR_LOG_FMT(POWERPC, "Unknown CachedInterpreter Instruction: {}",
static_cast<int>(code->type));