Merge pull request #6521 from lioncash/enum
CachedInterpreter: Use an enum class for instruction type
This commit is contained in:
commit
df3309228c
|
@ -17,32 +17,35 @@
|
||||||
|
|
||||||
struct CachedInterpreter::Instruction
|
struct CachedInterpreter::Instruction
|
||||||
{
|
{
|
||||||
typedef void (*CommonCallback)(UGeckoInstruction);
|
using CommonCallback = void (*)(UGeckoInstruction);
|
||||||
typedef bool (*ConditionalCallback)(u32 data);
|
using ConditionalCallback = bool (*)(u32);
|
||||||
|
|
||||||
Instruction() : type(INSTRUCTION_ABORT) {}
|
Instruction() {}
|
||||||
Instruction(const CommonCallback c, UGeckoInstruction i)
|
Instruction(const CommonCallback c, UGeckoInstruction i)
|
||||||
: common_callback(c), data(i.hex), type(INSTRUCTION_TYPE_COMMON)
|
: common_callback(c), data(i.hex), type(Type::Common)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction(const ConditionalCallback c, u32 d)
|
Instruction(const ConditionalCallback c, u32 d)
|
||||||
: conditional_callback(c), data(d), type(INSTRUCTION_TYPE_CONDITIONAL)
|
: conditional_callback(c), data(d), type(Type::Conditional)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum class Type
|
||||||
|
{
|
||||||
|
Abort,
|
||||||
|
Common,
|
||||||
|
Conditional,
|
||||||
|
};
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
const CommonCallback common_callback;
|
const CommonCallback common_callback;
|
||||||
const ConditionalCallback conditional_callback;
|
const ConditionalCallback conditional_callback;
|
||||||
};
|
};
|
||||||
u32 data;
|
|
||||||
enum
|
u32 data = 0;
|
||||||
{
|
Type type = Type::Abort;
|
||||||
INSTRUCTION_ABORT,
|
|
||||||
INSTRUCTION_TYPE_COMMON,
|
|
||||||
INSTRUCTION_TYPE_CONDITIONAL,
|
|
||||||
} type;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CachedInterpreter::CachedInterpreter() : code_buffer(32000)
|
CachedInterpreter::CachedInterpreter() : code_buffer(32000)
|
||||||
|
@ -86,15 +89,15 @@ void CachedInterpreter::ExecuteOneBlock()
|
||||||
|
|
||||||
const Instruction* code = reinterpret_cast<const Instruction*>(normal_entry);
|
const Instruction* code = reinterpret_cast<const Instruction*>(normal_entry);
|
||||||
|
|
||||||
for (; code->type != Instruction::INSTRUCTION_ABORT; ++code)
|
for (; code->type != Instruction::Type::Abort; ++code)
|
||||||
{
|
{
|
||||||
switch (code->type)
|
switch (code->type)
|
||||||
{
|
{
|
||||||
case Instruction::INSTRUCTION_TYPE_COMMON:
|
case Instruction::Type::Common:
|
||||||
code->common_callback(UGeckoInstruction(code->data));
|
code->common_callback(UGeckoInstruction(code->data));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Instruction::INSTRUCTION_TYPE_CONDITIONAL:
|
case Instruction::Type::Conditional:
|
||||||
if (code->conditional_callback(code->data))
|
if (code->conditional_callback(code->data))
|
||||||
return;
|
return;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue