From 29d7cbd899fb02ee09cbc35afbe13280d707ec41 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Mon, 22 Feb 2021 00:27:16 +0000 Subject: [PATCH] thumb32: Ensure CPSR.IT state is always up to date --- src/frontend/A32/translate/impl/thumb16.cpp | 6 +++--- src/frontend/A32/translate/impl/thumb32_control.cpp | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/frontend/A32/translate/impl/thumb16.cpp b/src/frontend/A32/translate/impl/thumb16.cpp index 481e01f6..35d017b4 100644 --- a/src/frontend/A32/translate/impl/thumb16.cpp +++ b/src/frontend/A32/translate/impl/thumb16.cpp @@ -860,7 +860,7 @@ bool ThumbTranslatorVisitor::thumb16_SETEND(bool E) { return true; } - ir.SetTerm(IR::Term::LinkBlock{ir.current_location.AdvancePC(2).SetEFlag(E)}); + ir.SetTerm(IR::Term::LinkBlock{ir.current_location.AdvancePC(2).SetEFlag(E).AdvanceIT()}); return false; } @@ -967,8 +967,8 @@ bool ThumbTranslatorVisitor::thumb16_CBZ_CBNZ(bool nonzero, Imm<1> i, Imm<5> imm ir.SetCheckBit(ir.IsZero(rn)); const auto [cond_pass, cond_fail] = [this, imm, nonzero] { - const auto skip = IR::Term::LinkBlock{ir.current_location.AdvancePC(2)}; - const auto branch = IR::Term::LinkBlock{ir.current_location.AdvancePC(imm + 4)}; + const auto skip = IR::Term::LinkBlock{ir.current_location.AdvancePC(2).AdvanceIT()}; + const auto branch = IR::Term::LinkBlock{ir.current_location.AdvancePC(imm + 4).AdvanceIT()}; if (nonzero) { return std::make_pair(skip, branch); diff --git a/src/frontend/A32/translate/impl/thumb32_control.cpp b/src/frontend/A32/translate/impl/thumb32_control.cpp index d9a4b0a7..ed2dc29b 100644 --- a/src/frontend/A32/translate/impl/thumb32_control.cpp +++ b/src/frontend/A32/translate/impl/thumb32_control.cpp @@ -24,6 +24,7 @@ bool ThumbTranslatorVisitor::thumb32_DSB([[maybe_unused]] Imm<4> option) { bool ThumbTranslatorVisitor::thumb32_ISB([[maybe_unused]] Imm<4> option) { ir.InstructionSynchronizationBarrier(); + ir.UpdateUpperLocationDescriptor(); ir.BranchWritePC(ir.Imm32(ir.current_location.PC() + 4)); ir.SetTerm(IR::Term::ReturnToDispatch{}); return false;