diff --git a/src/frontend/ir/basic_block.cpp b/src/frontend/ir/basic_block.cpp index 7bb13937..e4d3ec3a 100644 --- a/src/frontend/ir/basic_block.cpp +++ b/src/frontend/ir/basic_block.cpp @@ -70,8 +70,16 @@ std::string DumpBlock(const IR::Block& block) { const size_t arg_count = GetNumArgsOf(op); for (size_t arg_index = 0; arg_index < arg_count; arg_index++) { + const Value arg = inst->GetArg(arg_index); + ret += arg_index != 0 ? ", " : " "; - ret += arg_to_string(inst->GetArg(arg_index)); + ret += arg_to_string(arg); + + Type actual_type = arg.GetType(); + Type expected_type = GetArgTypeOf(op, arg_index); + if (actual_type != expected_type && actual_type != Type::Opaque && expected_type != Type::Opaque) { + ret += Common::StringFromFormat("", GetNameOf(actual_type), GetNameOf(expected_type)); + } } ret += "\n"; diff --git a/src/frontend/ir/opcodes.cpp b/src/frontend/ir/opcodes.cpp index 5f7856b0..2d1cdf2a 100644 --- a/src/frontend/ir/opcodes.cpp +++ b/src/frontend/ir/opcodes.cpp @@ -4,6 +4,7 @@ * General Public License version 2 or any later version. */ +#include #include #include @@ -48,5 +49,12 @@ const char* GetNameOf(Opcode op) { return OpcodeInfo::opcode_info.at(op).name; } +const char* GetNameOf(Type type) { + const static std::array names = { + "Void", "RegRef", "ExtRegRef", "Opaque", "U1", "U8", "U16", "U32", "U64", "F32", "F64" + }; + return names.at(static_cast(type)); +} + } // namespace IR } // namespace Dynarmic diff --git a/src/frontend/ir/opcodes.h b/src/frontend/ir/opcodes.h index d6cdf911..50c53fbb 100644 --- a/src/frontend/ir/opcodes.h +++ b/src/frontend/ir/opcodes.h @@ -28,17 +28,17 @@ constexpr size_t OpcodeCount = static_cast(Opcode::NUM_OPCODE); * The intermediate representation is typed. These are the used by our IR. */ enum class Type { - Void = 1 << 0, - RegRef = 1 << 1, - ExtRegRef = 1 << 2, - Opaque = 1 << 3, - U1 = 1 << 4, - U8 = 1 << 5, - U16 = 1 << 6, - U32 = 1 << 7, - U64 = 1 << 8, - F32 = 1 << 9, - F64 = 1 << 10, + Void, + RegRef, + ExtRegRef, + Opaque, + U1, + U8, + U16, + U32, + U64, + F32, + F64, }; /// Get return type of an opcode @@ -53,5 +53,8 @@ Type GetArgTypeOf(Opcode op, size_t arg_index); /// Get the name of an opcode. const char* GetNameOf(Opcode op); +/// Get the name of a type. +const char* GetNameOf(Type type); + } // namespace Arm } // namespace Dynarmic diff --git a/src/ir_opt/verification_pass.cpp b/src/ir_opt/verification_pass.cpp index 983b9892..295edafd 100644 --- a/src/ir_opt/verification_pass.cpp +++ b/src/ir_opt/verification_pass.cpp @@ -20,7 +20,10 @@ void VerificationPass(const IR::Block& block) { for (size_t i = 0; i < inst.NumArgs(); i++) { IR::Type t1 = inst.GetArg(i).GetType(); IR::Type t2 = IR::GetArgTypeOf(inst.GetOpcode(), i); - ASSERT(t1 == t2 || t1 == IR::Type::Opaque || t2 == IR::Type::Opaque); + if (t1 != t2 && t1 != IR::Type::Opaque && t2 != IR::Type::Opaque) { + puts(IR::DumpBlock(block).c_str()); + ASSERT(false); + } } }