From c0b043ecef71285bfa30d78c589b878484865b6a Mon Sep 17 00:00:00 2001 From: lizzie Date: Tue, 5 Aug 2025 01:04:29 +0100 Subject: [PATCH] [dynarmic] fix opcodes Signed-off-by: lizzie --- src/dynarmic/src/dynarmic/ir/opcodes.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/dynarmic/src/dynarmic/ir/opcodes.cpp b/src/dynarmic/src/dynarmic/ir/opcodes.cpp index e2059f1ef2..828cdb5109 100644 --- a/src/dynarmic/src/dynarmic/ir/opcodes.cpp +++ b/src/dynarmic/src/dynarmic/ir/opcodes.cpp @@ -35,9 +35,8 @@ constexpr Type Table = Type::Table; constexpr Type AccType = Type::AccType; struct Meta { - std::array arg_types; + std::vector arg_types; Type type; - uint8_t count; }; // Evil macro magic for Intel C++ compiler @@ -47,15 +46,21 @@ struct Meta { #define PP_ARG_N(_1, _2, _3, _4, _5, N, ...) N alignas(64) static const Meta opcode_info[] = { -#define OPCODE(name, type, ...) Meta{{__VA_ARGS__}, type, PP_EXPAND(PP_NARGS(__VA_ARGS__))}, -#define A32OPC(name, type, ...) Meta{{__VA_ARGS__}, type, PP_EXPAND(PP_NARGS(__VA_ARGS__))}, -#define A64OPC(name, type, ...) Meta{{__VA_ARGS__}, type, PP_EXPAND(PP_NARGS(__VA_ARGS__))}, +#define OPCODE(name, type, ...) Meta{{__VA_ARGS__}, type}, +#define A32OPC(name, type, ...) Meta{{__VA_ARGS__}, type}, +#define A64OPC(name, type, ...) Meta{{__VA_ARGS__}, type}, #include "./opcodes.inc" #undef OPCODE #undef A32OPC #undef A64OPC }; +// Be aware of trailing commas, they can cause PP_NARG to return 2! +static_assert(PP_EXPAND(PP_NARGS(u8,)) == 2); +static_assert(PP_EXPAND(PP_NARGS(u8)) == 1); +static_assert(PP_EXPAND(PP_NARGS(u8, u16)) == 2); +static_assert(PP_EXPAND(PP_NARGS(u8, u16, u32)) == 3); + } // namespace OpcodeInfo /// @brief Get return type of an opcode @@ -65,7 +70,7 @@ Type GetTypeOf(Opcode op) noexcept { /// @brief Get the number of arguments an opcode accepts size_t GetNumArgsOf(Opcode op) noexcept { - return OpcodeInfo::opcode_info[size_t(op)].count; + return OpcodeInfo::opcode_info[size_t(op)].arg_types.size(); } /// @brief Get the required type of an argument of an opcode