From 9c82a12f8f7fe05711da5a8beaa63302c2dbe046 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sat, 13 Aug 2016 18:39:49 +0100 Subject: [PATCH] ir_opt: Update VerificationPass to current IR --- src/ir_opt/verification_pass.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/ir_opt/verification_pass.cpp b/src/ir_opt/verification_pass.cpp index 8668a619..2de47a5a 100644 --- a/src/ir_opt/verification_pass.cpp +++ b/src/ir_opt/verification_pass.cpp @@ -4,6 +4,8 @@ * General Public License version 2 or any later version. */ +#include + #include "common/assert.h" #include "frontend/ir/ir.h" #include "ir_opt/passes.h" @@ -12,11 +14,26 @@ namespace Dynarmic { namespace Optimization { void VerificationPass(const IR::Block& block) { -#if 0 for (const auto& inst : block.instructions) { - inst->AssertValid(); + 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); + } + } + + std::map actual_uses; + for (const auto& inst : block.instructions) { + for (size_t i = 0; i < inst.NumArgs(); i++) { + if (!inst.GetArg(i).IsImmediate()) { + actual_uses[inst.GetArg(i).GetInst()]++; + } + } + } + + for (const auto& pair : actual_uses) { + ASSERT(pair.first->use_count == pair.second); } -#endif } } // namespace Optimization