diff --git a/src/frontend/ir/basic_block.cpp b/src/frontend/ir/basic_block.cpp index e4d3ec3a..b8a32de7 100644 --- a/src/frontend/ir/basic_block.cpp +++ b/src/frontend/ir/basic_block.cpp @@ -77,7 +77,7 @@ std::string DumpBlock(const IR::Block& block) { 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) { + if (!AreTypesCompatible(actual_type, expected_type)) { ret += Common::StringFromFormat("", GetNameOf(actual_type), GetNameOf(expected_type)); } } diff --git a/src/frontend/ir/microinstruction.cpp b/src/frontend/ir/microinstruction.cpp index 2a0f5c98..4dd6811c 100644 --- a/src/frontend/ir/microinstruction.cpp +++ b/src/frontend/ir/microinstruction.cpp @@ -19,7 +19,7 @@ Value Inst::GetArg(size_t index) const { void Inst::SetArg(size_t index, Value value) { DEBUG_ASSERT(index < GetNumArgsOf(op)); - DEBUG_ASSERT(value.GetType() == GetArgTypeOf(op, index) || Type::Opaque == GetArgTypeOf(op, index)); + DEBUG_ASSERT(AreTypesCompatible(value.GetType(), GetArgTypeOf(op, index))); if (!args[index].IsImmediate()) { UndoUse(args[index]); diff --git a/src/frontend/ir/opcodes.cpp b/src/frontend/ir/opcodes.cpp index 2d1cdf2a..d63ff9f2 100644 --- a/src/frontend/ir/opcodes.cpp +++ b/src/frontend/ir/opcodes.cpp @@ -56,5 +56,9 @@ const char* GetNameOf(Type type) { return names.at(static_cast(type)); } +bool AreTypesCompatible(Type t1, Type t2) { + return t1 == t2 || t1 == Type::Opaque || t2 == Type::Opaque; +} + } // namespace IR } // namespace Dynarmic diff --git a/src/frontend/ir/opcodes.h b/src/frontend/ir/opcodes.h index 50c53fbb..44bcbbe7 100644 --- a/src/frontend/ir/opcodes.h +++ b/src/frontend/ir/opcodes.h @@ -56,5 +56,8 @@ const char* GetNameOf(Opcode op); /// Get the name of a type. const char* GetNameOf(Type type); +/// @returns true if t1 and t2 are compatible types +bool AreTypesCompatible(Type t1, Type t2); + } // namespace Arm } // namespace Dynarmic diff --git a/src/ir_opt/verification_pass.cpp b/src/ir_opt/verification_pass.cpp index 295edafd..67036ed5 100644 --- a/src/ir_opt/verification_pass.cpp +++ b/src/ir_opt/verification_pass.cpp @@ -20,7 +20,7 @@ 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); - if (t1 != t2 && t1 != IR::Type::Opaque && t2 != IR::Type::Opaque) { + if (!IR::AreTypesCompatible(t1, t2)) { puts(IR::DumpBlock(block).c_str()); ASSERT(false); }