mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-03-11 03:52:56 +00:00
ir/opcodes: Implement IR::AreTypesCompatible
Type-checking is now occuring in more than one place.
This commit is contained in:
@@ -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("<type error: %s != %s>", GetNameOf(actual_type), GetNameOf(expected_type));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -56,5 +56,9 @@ const char* GetNameOf(Type type) {
|
||||
return names.at(static_cast<size_t>(type));
|
||||
}
|
||||
|
||||
bool AreTypesCompatible(Type t1, Type t2) {
|
||||
return t1 == t2 || t1 == Type::Opaque || t2 == Type::Opaque;
|
||||
}
|
||||
|
||||
} // namespace IR
|
||||
} // namespace Dynarmic
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user