mirror of
https://github.com/yuzu-emu/yuzu-mainline.git
synced 2024-12-12 18:24:17 +01:00
Favor switch case over jump table
Easier to read and will emit a jump table automatically.
This commit is contained in:
parent
b032ebdfee
commit
8118ea160b
@ -14,18 +14,6 @@ MICROPROFILE_DEFINE(MacroJitCompile, "GPU", "Compile macro JIT", MP_RGB(173, 255
|
|||||||
MICROPROFILE_DEFINE(MacroJitExecute, "GPU", "Execute macro JIT", MP_RGB(255, 255, 0));
|
MICROPROFILE_DEFINE(MacroJitExecute, "GPU", "Execute macro JIT", MP_RGB(255, 255, 0));
|
||||||
|
|
||||||
namespace Tegra {
|
namespace Tegra {
|
||||||
using JitFunction = void (MacroJITx64Impl::*)(Macro::Opcode opcode);
|
|
||||||
const std::array<JitFunction, 8> InstructionTable{
|
|
||||||
&MacroJITx64Impl::Compile_ALU,
|
|
||||||
&MacroJITx64Impl::Compile_AddImmediate,
|
|
||||||
&MacroJITx64Impl::Compile_ExtractInsert,
|
|
||||||
&MacroJITx64Impl::Compile_ExtractShiftLeftImmediate,
|
|
||||||
&MacroJITx64Impl::Compile_ExtractShiftLeftRegister,
|
|
||||||
&MacroJITx64Impl::Compile_Read,
|
|
||||||
nullptr,
|
|
||||||
&MacroJITx64Impl::Compile_Branch,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const Xbyak::Reg64 PARAMETERS = Xbyak::util::r9;
|
static const Xbyak::Reg64 PARAMETERS = Xbyak::util::r9;
|
||||||
static const Xbyak::Reg64 REGISTERS = Xbyak::util::r10;
|
static const Xbyak::Reg64 REGISTERS = Xbyak::util::r10;
|
||||||
static const Xbyak::Reg64 STATE = Xbyak::util::r11;
|
static const Xbyak::Reg64 STATE = Xbyak::util::r11;
|
||||||
@ -489,12 +477,31 @@ bool MacroJITx64Impl::Compile_NextInstruction() {
|
|||||||
|
|
||||||
L(labels[pc]);
|
L(labels[pc]);
|
||||||
|
|
||||||
const std::size_t op = static_cast<std::size_t>(opcode.operation.Value());
|
switch (opcode.operation) {
|
||||||
|
case Macro::Operation::ALU:
|
||||||
if (InstructionTable[op] == nullptr) {
|
Compile_ALU(opcode);
|
||||||
UNIMPLEMENTED_MSG("Unimplemented opcode {}", op);
|
break;
|
||||||
} else {
|
case Macro::Operation::AddImmediate:
|
||||||
((*this).*InstructionTable[op])(opcode);
|
Compile_AddImmediate(opcode);
|
||||||
|
break;
|
||||||
|
case Macro::Operation::ExtractInsert:
|
||||||
|
Compile_ExtractInsert(opcode);
|
||||||
|
break;
|
||||||
|
case Macro::Operation::ExtractShiftLeftImmediate:
|
||||||
|
Compile_ExtractShiftLeftImmediate(opcode);
|
||||||
|
break;
|
||||||
|
case Macro::Operation::ExtractShiftLeftRegister:
|
||||||
|
Compile_ExtractShiftLeftRegister(opcode);
|
||||||
|
break;
|
||||||
|
case Macro::Operation::Read:
|
||||||
|
Compile_Read(opcode);
|
||||||
|
break;
|
||||||
|
case Macro::Operation::Branch:
|
||||||
|
Compile_Branch(opcode);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
UNIMPLEMENTED_MSG("Unimplemented opcode {}", opcode.operation.Value());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optimizer.has_delayed_pc) {
|
if (optimizer.has_delayed_pc) {
|
||||||
|
@ -35,6 +35,7 @@ class MacroJITx64Impl : public Xbyak::CodeGenerator, public CachedMacro {
|
|||||||
public:
|
public:
|
||||||
MacroJITx64Impl(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& code);
|
MacroJITx64Impl(Engines::Maxwell3D& maxwell3d, const std::vector<u32>& code);
|
||||||
~MacroJITx64Impl();
|
~MacroJITx64Impl();
|
||||||
|
|
||||||
void Execute(std::vector<u32>& parameters, u32 method) override;
|
void Execute(std::vector<u32>& parameters, u32 method) override;
|
||||||
|
|
||||||
void Compile_ALU(Macro::Opcode opcode);
|
void Compile_ALU(Macro::Opcode opcode);
|
||||||
|
Loading…
Reference in New Issue
Block a user