From e93fb0ba2b903424174f30978a4ab61ff61d36cd Mon Sep 17 00:00:00 2001 From: MerryMage Date: Fri, 8 Jul 2016 15:28:56 +0800 Subject: [PATCH] EmitX64: remove emit_fns map, use a switch statement instead --- src/backend_x64/emit_x64.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/backend_x64/emit_x64.cpp b/src/backend_x64/emit_x64.cpp index 46c0d720..ca071cd6 100644 --- a/src/backend_x64/emit_x64.cpp +++ b/src/backend_x64/emit_x64.cpp @@ -29,13 +29,6 @@ static OpArg MJitStateCpsr() { return MDisp(R15, offsetof(JitState, Cpsr)); } -// Mapping from opcode to Emit* member function. -const static std::map emit_fns { -#define OPCODE(name, type, ...) { IR::Opcode::name, &EmitX64::Emit##name }, -#include "frontend/ir/opcodes.inc" -#undef OPCODE -}; - static IR::Inst* FindUseWithOpcode(IR::Inst* inst, IR::Opcode opcode) { // Gets first found use. auto uses = inst->GetUses(); @@ -50,12 +43,25 @@ CodePtr EmitX64::Emit(Arm::LocationDescriptor descriptor, Dynarmic::IR::Block bl code->INT3(); CodePtr code_ptr = code->GetCodePtr(); - // Call Emit* member function for each instruction. for (const auto& value : block.instructions) { if (inhibit_emission.count(value.get()) != 0) continue; - (this->*emit_fns.at(value->GetOpcode()))(value.get()); + // Call the relevant Emit* member function. + switch (value->GetOpcode()) { + +#define OPCODE(name, type, ...) \ + case IR::Opcode::name: \ + EmitX64::Emit##name(value.get()); \ + break; +#include "frontend/ir/opcodes.inc" +#undef OPCODE + + default: + ASSERT_MSG(false, "Invalid opcode %zu", static_cast(value->GetOpcode())); + break; + } + reg_alloc.EndOfAllocScope(); }