diff --git a/src/frontend/ir/opcodes.cpp b/src/frontend/ir/opcodes.cpp index 3df6db39..b2122c31 100644 --- a/src/frontend/ir/opcodes.cpp +++ b/src/frontend/ir/opcodes.cpp @@ -4,7 +4,6 @@ */ #include -#include #include #include #include @@ -44,34 +43,32 @@ constexpr Type NZCV = Type::NZCVFlags; constexpr Type Cond = Type::Cond; constexpr Type Table = Type::Table; -static const std::map opcode_info {{ -#define OPCODE(name, type, ...) { Opcode::name, { #name, type, { __VA_ARGS__ } } }, -#define A32OPC(name, type, ...) { Opcode::A32##name, { #name, type, { __VA_ARGS__ } } }, -#define A64OPC(name, type, ...) { Opcode::A64##name, { #name, type, { __VA_ARGS__ } } }, +static const std::array opcode_info { +#define OPCODE(name, type, ...) Meta{#name, type, {__VA_ARGS__}}, +#define A32OPC(name, type, ...) Meta{#name, type, {__VA_ARGS__}}, +#define A64OPC(name, type, ...) Meta{#name, type, {__VA_ARGS__}}, #include "opcodes.inc" #undef OPCODE #undef A32OPC #undef A64OPC -}}; +}; } // namespace OpcodeInfo Type GetTypeOf(Opcode op) { - return OpcodeInfo::opcode_info.at(op).type; + return OpcodeInfo::opcode_info.at(static_cast(op)).type; } size_t GetNumArgsOf(Opcode op) { - return OpcodeInfo::opcode_info.at(op).arg_types.size(); + return OpcodeInfo::opcode_info.at(static_cast(op)).arg_types.size(); } Type GetArgTypeOf(Opcode op, size_t arg_index) { - return OpcodeInfo::opcode_info.at(op).arg_types.at(arg_index); + return OpcodeInfo::opcode_info.at(static_cast(op)).arg_types.at(arg_index); } std::string GetNameOf(Opcode op) { - if (OpcodeInfo::opcode_info.count(op) == 0) - return fmt::format("Unknown Opcode {}", static_cast(op)); - return OpcodeInfo::opcode_info.at(op).name; + return OpcodeInfo::opcode_info.at(static_cast(op)).name; } std::ostream& operator<<(std::ostream& o, Opcode opcode) {