From 285e617e35c7e3ad299b2cae5b41c20ccd6a86c9 Mon Sep 17 00:00:00 2001 From: Merry Date: Tue, 12 Jul 2022 00:13:52 +0100 Subject: [PATCH] Revert "frontend: Add option to halt after memory accesses (#682)" This reverts commit 5ad1d02351bf4fee681a3d701d210b419f41a505. --- src/dynarmic/backend/x64/a32_interface.cpp | 3 +- src/dynarmic/backend/x64/a64_interface.cpp | 2 +- .../frontend/A32/translate/a32_translate.h | 6 -- .../A32/translate/impl/a32_translate_impl.cpp | 9 -- .../A32/translate/impl/a32_translate_impl.h | 1 - .../impl/asimd_load_store_structures.cpp | 10 +- .../A32/translate/impl/load_store.cpp | 100 +++++++++--------- .../A32/translate/impl/synchronization.cpp | 48 ++++----- .../frontend/A32/translate/impl/thumb16.cpp | 46 ++++---- .../A32/translate/impl/thumb32_load_byte.cpp | 6 +- .../translate/impl/thumb32_load_halfword.cpp | 6 +- .../impl/thumb32_load_store_dual.cpp | 30 +++--- .../impl/thumb32_load_store_multiple.cpp | 40 ++++--- .../A32/translate/impl/thumb32_load_word.cpp | 30 ++---- .../frontend/A32/translate/impl/vfp.cpp | 16 +-- .../frontend/A64/translate/a64_translate.h | 6 -- .../frontend/A64/translate/impl/impl.cpp | 9 -- .../frontend/A64/translate/impl/impl.h | 1 - .../translate/impl/load_store_exclusive.cpp | 4 +- .../impl/load_store_load_literal.cpp | 6 +- .../impl/load_store_multiple_structures.cpp | 2 +- .../impl/load_store_register_immediate.cpp | 4 +- .../impl/load_store_register_pair.cpp | 4 +- .../load_store_register_register_offset.cpp | 4 +- .../impl/load_store_register_unprivileged.cpp | 8 +- .../impl/load_store_single_structure.cpp | 2 +- src/dynarmic/interface/A32/config.h | 4 - src/dynarmic/interface/A64/config.h | 4 - 28 files changed, 172 insertions(+), 239 deletions(-) diff --git a/src/dynarmic/backend/x64/a32_interface.cpp b/src/dynarmic/backend/x64/a32_interface.cpp index 6d2bf610..860c70bc 100644 --- a/src/dynarmic/backend/x64/a32_interface.cpp +++ b/src/dynarmic/backend/x64/a32_interface.cpp @@ -171,8 +171,7 @@ private: PerformCacheInvalidation(); } - IR::Block ir_block = A32::Translate(A32::LocationDescriptor{descriptor}, conf.callbacks, - {conf.arch_version, conf.define_unpredictable_behaviour, conf.hook_hint_instructions, conf.check_halt_on_memory_access}); + IR::Block ir_block = A32::Translate(A32::LocationDescriptor{descriptor}, conf.callbacks, {conf.arch_version, conf.define_unpredictable_behaviour, conf.hook_hint_instructions}); Optimization::PolyfillPass(ir_block, polyfill_options); if (conf.HasOptimization(OptimizationFlag::GetSetElimination)) { Optimization::A32GetSetElimination(ir_block); diff --git a/src/dynarmic/backend/x64/a64_interface.cpp b/src/dynarmic/backend/x64/a64_interface.cpp index fcc289b1..9a8714fb 100644 --- a/src/dynarmic/backend/x64/a64_interface.cpp +++ b/src/dynarmic/backend/x64/a64_interface.cpp @@ -269,7 +269,7 @@ private: // JIT Compile const auto get_code = [this](u64 vaddr) { return conf.callbacks->MemoryReadCode(vaddr); }; IR::Block ir_block = A64::Translate(A64::LocationDescriptor{current_location}, get_code, - {conf.define_unpredictable_behaviour, conf.wall_clock_cntpct, conf.hook_hint_instructions, conf.check_halt_on_memory_access}); + {conf.define_unpredictable_behaviour, conf.wall_clock_cntpct}); Optimization::PolyfillPass(ir_block, polyfill_options); Optimization::A64CallbackConfigPass(ir_block, conf); if (conf.HasOptimization(OptimizationFlag::GetSetElimination)) { diff --git a/src/dynarmic/frontend/A32/translate/a32_translate.h b/src/dynarmic/frontend/A32/translate/a32_translate.h index 23a63d11..0f2c3a12 100644 --- a/src/dynarmic/frontend/A32/translate/a32_translate.h +++ b/src/dynarmic/frontend/A32/translate/a32_translate.h @@ -29,12 +29,6 @@ struct TranslationOptions { /// If this is false, we treat the instruction as a NOP. /// If this is true, we emit an ExceptionRaised instruction. bool hook_hint_instructions = true; - - /// This changes what IR we emit when we translate a memory instruction. - /// If this is false, memory accesses are not considered terminal. - /// If this is true, memory access are considered terminal. This allows - /// accurately emulating protection fault handlers. - bool check_halt_on_memory_access = false; }; /** diff --git a/src/dynarmic/frontend/A32/translate/impl/a32_translate_impl.cpp b/src/dynarmic/frontend/A32/translate/impl/a32_translate_impl.cpp index ae20c5a1..276f8384 100644 --- a/src/dynarmic/frontend/A32/translate/impl/a32_translate_impl.cpp +++ b/src/dynarmic/frontend/A32/translate/impl/a32_translate_impl.cpp @@ -53,15 +53,6 @@ bool TranslatorVisitor::RaiseException(Exception exception) { return false; } -bool TranslatorVisitor::MemoryInstructionContinues() { - if (options.check_halt_on_memory_access) { - ir.SetTerm(IR::Term::LinkBlock{ir.current_location.AdvancePC(static_cast(current_instruction_size))}); - return false; - } - - return true; -} - IR::UAny TranslatorVisitor::I(size_t bitsize, u64 value) { switch (bitsize) { case 8: diff --git a/src/dynarmic/frontend/A32/translate/impl/a32_translate_impl.h b/src/dynarmic/frontend/A32/translate/impl/a32_translate_impl.h index 551528ee..61a97b1c 100644 --- a/src/dynarmic/frontend/A32/translate/impl/a32_translate_impl.h +++ b/src/dynarmic/frontend/A32/translate/impl/a32_translate_impl.h @@ -41,7 +41,6 @@ struct TranslatorVisitor final { bool UndefinedInstruction(); bool DecodeError(); bool RaiseException(Exception exception); - bool MemoryInstructionContinues(); struct ImmAndCarry { u32 imm32; diff --git a/src/dynarmic/frontend/A32/translate/impl/asimd_load_store_structures.cpp b/src/dynarmic/frontend/A32/translate/impl/asimd_load_store_structures.cpp index 1b6c97d5..d444e023 100644 --- a/src/dynarmic/frontend/A32/translate/impl/asimd_load_store_structures.cpp +++ b/src/dynarmic/frontend/A32/translate/impl/asimd_load_store_structures.cpp @@ -119,7 +119,7 @@ bool TranslatorVisitor::v8_VST_multiple(bool D, Reg n, size_t Vd, Imm<4> type, s } } - return MemoryInstructionContinues(); + return true; } bool TranslatorVisitor::v8_VLD_multiple(bool D, Reg n, size_t Vd, Imm<4> type, size_t size, size_t align, Reg m) { @@ -176,7 +176,7 @@ bool TranslatorVisitor::v8_VLD_multiple(bool D, Reg n, size_t Vd, Imm<4> type, s } } - return MemoryInstructionContinues(); + return true; } bool TranslatorVisitor::v8_VLD_all_lanes(bool D, Reg n, size_t Vd, size_t nn, size_t sz, bool T, bool a, Reg m) { @@ -241,7 +241,7 @@ bool TranslatorVisitor::v8_VLD_all_lanes(bool D, Reg n, size_t Vd, size_t nn, si } } - return MemoryInstructionContinues(); + return true; } bool TranslatorVisitor::v8_VST_single(bool D, Reg n, size_t Vd, size_t sz, size_t nn, size_t index_align, Reg m) { @@ -305,7 +305,7 @@ bool TranslatorVisitor::v8_VST_single(bool D, Reg n, size_t Vd, size_t sz, size_ } } - return MemoryInstructionContinues(); + return true; } bool TranslatorVisitor::v8_VLD_single(bool D, Reg n, size_t Vd, size_t sz, size_t nn, size_t index_align, Reg m) { @@ -370,6 +370,6 @@ bool TranslatorVisitor::v8_VLD_single(bool D, Reg n, size_t Vd, size_t sz, size_ } } - return MemoryInstructionContinues(); + return true; } } // namespace Dynarmic::A32 diff --git a/src/dynarmic/frontend/A32/translate/impl/load_store.cpp b/src/dynarmic/frontend/A32/translate/impl/load_store.cpp index a7fc8886..7ef8b7e8 100644 --- a/src/dynarmic/frontend/A32/translate/impl/load_store.cpp +++ b/src/dynarmic/frontend/A32/translate/impl/load_store.cpp @@ -83,7 +83,7 @@ bool TranslatorVisitor::arm_LDR_lit(Cond cond, bool U, Reg t, Imm<12> imm12) { } ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDR , [, #+/-]{!} @@ -120,7 +120,7 @@ bool TranslatorVisitor::arm_LDR_imm(Cond cond, bool P, bool U, bool W, Reg n, Re } ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDR , [, #+/-]{!} @@ -150,7 +150,7 @@ bool TranslatorVisitor::arm_LDR_reg(Cond cond, bool P, bool U, bool W, Reg n, Re } ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRB , [PC, #+/-] @@ -170,7 +170,7 @@ bool TranslatorVisitor::arm_LDRB_lit(Cond cond, bool U, Reg t, Imm<12> imm12) { const auto data = ir.ZeroExtendByteToWord(ir.ReadMemory8(ir.Imm32(address), IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRB , [, #+/-]{!} @@ -199,7 +199,7 @@ bool TranslatorVisitor::arm_LDRB_imm(Cond cond, bool P, bool U, bool W, Reg n, R const auto data = ir.ZeroExtendByteToWord(ir.ReadMemory8(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRB , [, #+/-]{!} @@ -223,7 +223,7 @@ bool TranslatorVisitor::arm_LDRB_reg(Cond cond, bool P, bool U, bool W, Reg n, R const auto data = ir.ZeroExtendByteToWord(ir.ReadMemory8(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRD , , [PC, #+/-] @@ -257,7 +257,7 @@ bool TranslatorVisitor::arm_LDRD_lit(Cond cond, bool U, Reg t, Imm<4> imm8a, Imm ir.SetRegister(t, ir.LeastSignificantWord(data)); ir.SetRegister(t2, ir.MostSignificantWord(data).result); } - return MemoryInstructionContinues(); + return true; } // LDRD , [, #+/-]{!} @@ -303,7 +303,7 @@ bool TranslatorVisitor::arm_LDRD_imm(Cond cond, bool P, bool U, bool W, Reg n, R ir.SetRegister(t, ir.LeastSignificantWord(data)); ir.SetRegister(t2, ir.MostSignificantWord(data).result); } - return MemoryInstructionContinues(); + return true; } // LDRD , [, #+/-]{!} @@ -343,7 +343,7 @@ bool TranslatorVisitor::arm_LDRD_reg(Cond cond, bool P, bool U, bool W, Reg n, R ir.SetRegister(t, ir.LeastSignificantWord(data)); ir.SetRegister(t2, ir.MostSignificantWord(data).result); } - return MemoryInstructionContinues(); + return true; } // LDRH , [PC, #-/+] @@ -368,7 +368,7 @@ bool TranslatorVisitor::arm_LDRH_lit(Cond cond, bool P, bool U, bool W, Reg t, I const auto data = ir.ZeroExtendHalfToWord(ir.ReadMemory16(ir.Imm32(address), IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRH , [, #+/-]{!} @@ -397,7 +397,7 @@ bool TranslatorVisitor::arm_LDRH_imm(Cond cond, bool P, bool U, bool W, Reg n, R const auto data = ir.ZeroExtendHalfToWord(ir.ReadMemory16(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRH , [, #+/-]{!} @@ -421,7 +421,7 @@ bool TranslatorVisitor::arm_LDRH_reg(Cond cond, bool P, bool U, bool W, Reg n, R const auto data = ir.ZeroExtendHalfToWord(ir.ReadMemory16(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRSB , [PC, #+/-] @@ -442,7 +442,7 @@ bool TranslatorVisitor::arm_LDRSB_lit(Cond cond, bool U, Reg t, Imm<4> imm8a, Im const auto data = ir.SignExtendByteToWord(ir.ReadMemory8(ir.Imm32(address), IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRSB , [, #+/-]{!} @@ -471,7 +471,7 @@ bool TranslatorVisitor::arm_LDRSB_imm(Cond cond, bool P, bool U, bool W, Reg n, const auto data = ir.SignExtendByteToWord(ir.ReadMemory8(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRSB , [, #+/-]{!} @@ -495,7 +495,7 @@ bool TranslatorVisitor::arm_LDRSB_reg(Cond cond, bool P, bool U, bool W, Reg n, const auto data = ir.SignExtendByteToWord(ir.ReadMemory8(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRSH , [PC, #-/+] @@ -515,7 +515,7 @@ bool TranslatorVisitor::arm_LDRSH_lit(Cond cond, bool U, Reg t, Imm<4> imm8a, Im const auto data = ir.SignExtendHalfToWord(ir.ReadMemory16(ir.Imm32(address), IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRSH , [, #+/-]{!} @@ -544,7 +544,7 @@ bool TranslatorVisitor::arm_LDRSH_imm(Cond cond, bool P, bool U, bool W, Reg n, const auto data = ir.SignExtendHalfToWord(ir.ReadMemory16(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRSH , [, #+/-]{!} @@ -568,7 +568,7 @@ bool TranslatorVisitor::arm_LDRSH_reg(Cond cond, bool P, bool U, bool W, Reg n, const auto data = ir.SignExtendHalfToWord(ir.ReadMemory16(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // STR , [, #+/-]{!} @@ -585,7 +585,7 @@ bool TranslatorVisitor::arm_STR_imm(Cond cond, bool P, bool U, bool W, Reg n, Re const auto offset = ir.Imm32(imm12.ZeroExtend()); const auto address = GetAddress(ir, P, U, W, n, offset); ir.WriteMemory32(address, ir.GetRegister(t), IR::AccType::NORMAL); - return MemoryInstructionContinues(); + return true; } // STR , [, #+/-]{!} @@ -606,7 +606,7 @@ bool TranslatorVisitor::arm_STR_reg(Cond cond, bool P, bool U, bool W, Reg n, Re const auto offset = EmitImmShift(ir.GetRegister(m), shift, imm5, ir.GetCFlag()).result; const auto address = GetAddress(ir, P, U, W, n, offset); ir.WriteMemory32(address, ir.GetRegister(t), IR::AccType::NORMAL); - return MemoryInstructionContinues(); + return true; } // STRB , [, #+/-]{!} @@ -627,7 +627,7 @@ bool TranslatorVisitor::arm_STRB_imm(Cond cond, bool P, bool U, bool W, Reg n, R const auto offset = ir.Imm32(imm12.ZeroExtend()); const auto address = GetAddress(ir, P, U, W, n, offset); ir.WriteMemory8(address, ir.LeastSignificantByte(ir.GetRegister(t)), IR::AccType::NORMAL); - return MemoryInstructionContinues(); + return true; } // STRB , [, #+/-]{!} @@ -648,7 +648,7 @@ bool TranslatorVisitor::arm_STRB_reg(Cond cond, bool P, bool U, bool W, Reg n, R const auto offset = EmitImmShift(ir.GetRegister(m), shift, imm5, ir.GetCFlag()).result; const auto address = GetAddress(ir, P, U, W, n, offset); ir.WriteMemory8(address, ir.LeastSignificantByte(ir.GetRegister(t)), IR::AccType::NORMAL); - return MemoryInstructionContinues(); + return true; } // STRD , [, #+/-]{!} @@ -686,7 +686,7 @@ bool TranslatorVisitor::arm_STRD_imm(Cond cond, bool P, bool U, bool W, Reg n, R // NOTE: If alignment is exactly off by 4, each word is an atomic access. ir.WriteMemory64(address, data, IR::AccType::ATOMIC); - return MemoryInstructionContinues(); + return true; } // STRD , [, #+/-]{!} @@ -723,7 +723,7 @@ bool TranslatorVisitor::arm_STRD_reg(Cond cond, bool P, bool U, bool W, Reg n, R // NOTE: If alignment is exactly off by 4, each word is an atomic access. ir.WriteMemory64(address, data, IR::AccType::ATOMIC); - return MemoryInstructionContinues(); + return true; } // STRH , [, #+/-]{!} @@ -746,7 +746,7 @@ bool TranslatorVisitor::arm_STRH_imm(Cond cond, bool P, bool U, bool W, Reg n, R const auto address = GetAddress(ir, P, U, W, n, offset); ir.WriteMemory16(address, ir.LeastSignificantHalf(ir.GetRegister(t)), IR::AccType::NORMAL); - return MemoryInstructionContinues(); + return true; } // STRH , [, #+/-]{!} @@ -768,31 +768,29 @@ bool TranslatorVisitor::arm_STRH_reg(Cond cond, bool P, bool U, bool W, Reg n, R const auto address = GetAddress(ir, P, U, W, n, offset); ir.WriteMemory16(address, ir.LeastSignificantHalf(ir.GetRegister(t)), IR::AccType::NORMAL); - return MemoryInstructionContinues(); + return true; } -static bool LDMHelper(TranslatorVisitor& v, bool W, Reg n, RegList list, IR::U32 start_address, IR::U32 writeback_address) { +static bool LDMHelper(A32::IREmitter& ir, bool W, Reg n, RegList list, IR::U32 start_address, IR::U32 writeback_address) { auto address = start_address; for (size_t i = 0; i <= 14; i++) { if (mcl::bit::get_bit(i, list)) { - v.ir.SetRegister(static_cast(i), v.ir.ReadMemory32(address, IR::AccType::ATOMIC)); - address = v.ir.Add(address, v.ir.Imm32(4)); + ir.SetRegister(static_cast(i), ir.ReadMemory32(address, IR::AccType::ATOMIC)); + address = ir.Add(address, ir.Imm32(4)); } } if (W && !mcl::bit::get_bit(RegNumber(n), list)) { - v.ir.SetRegister(n, writeback_address); + ir.SetRegister(n, writeback_address); } if (mcl::bit::get_bit<15>(list)) { - v.ir.LoadWritePC(v.ir.ReadMemory32(address, IR::AccType::ATOMIC)); - if (v.options.check_halt_on_memory_access) - v.ir.SetTerm(IR::Term::CheckHalt{IR::Term::ReturnToDispatch{}}); - else if (n == Reg::R13) - v.ir.SetTerm(IR::Term::PopRSBHint{}); + ir.LoadWritePC(ir.ReadMemory32(address, IR::AccType::ATOMIC)); + if (n == Reg::R13) + ir.SetTerm(IR::Term::PopRSBHint{}); else - v.ir.SetTerm(IR::Term::FastDispatchHint{}); + ir.SetTerm(IR::Term::FastDispatchHint{}); return false; } - return v.MemoryInstructionContinues(); + return true; } // LDM {!}, @@ -810,7 +808,7 @@ bool TranslatorVisitor::arm_LDM(Cond cond, bool W, Reg n, RegList list) { const auto start_address = ir.GetRegister(n); const auto writeback_address = ir.Add(start_address, ir.Imm32(u32(mcl::bit::count_ones(list) * 4))); - return LDMHelper(*this, W, n, list, start_address, writeback_address); + return LDMHelper(ir, W, n, list, start_address, writeback_address); } // LDMDA {!}, @@ -828,7 +826,7 @@ bool TranslatorVisitor::arm_LDMDA(Cond cond, bool W, Reg n, RegList list) { const auto start_address = ir.Sub(ir.GetRegister(n), ir.Imm32(u32(4 * mcl::bit::count_ones(list) - 4))); const auto writeback_address = ir.Sub(start_address, ir.Imm32(4)); - return LDMHelper(*this, W, n, list, start_address, writeback_address); + return LDMHelper(ir, W, n, list, start_address, writeback_address); } // LDMDB {!}, @@ -846,7 +844,7 @@ bool TranslatorVisitor::arm_LDMDB(Cond cond, bool W, Reg n, RegList list) { const auto start_address = ir.Sub(ir.GetRegister(n), ir.Imm32(u32(4 * mcl::bit::count_ones(list)))); const auto writeback_address = start_address; - return LDMHelper(*this, W, n, list, start_address, writeback_address); + return LDMHelper(ir, W, n, list, start_address, writeback_address); } // LDMIB {!}, @@ -864,7 +862,7 @@ bool TranslatorVisitor::arm_LDMIB(Cond cond, bool W, Reg n, RegList list) { const auto start_address = ir.Add(ir.GetRegister(n), ir.Imm32(4)); const auto writeback_address = ir.Add(ir.GetRegister(n), ir.Imm32(u32(4 * mcl::bit::count_ones(list)))); - return LDMHelper(*this, W, n, list, start_address, writeback_address); + return LDMHelper(ir, W, n, list, start_address, writeback_address); } bool TranslatorVisitor::arm_LDM_usr() { @@ -875,21 +873,21 @@ bool TranslatorVisitor::arm_LDM_eret() { return InterpretThisInstruction(); } -static bool STMHelper(TranslatorVisitor& v, bool W, Reg n, RegList list, IR::U32 start_address, IR::U32 writeback_address) { +static bool STMHelper(A32::IREmitter& ir, bool W, Reg n, RegList list, IR::U32 start_address, IR::U32 writeback_address) { auto address = start_address; for (size_t i = 0; i <= 14; i++) { if (mcl::bit::get_bit(i, list)) { - v.ir.WriteMemory32(address, v.ir.GetRegister(static_cast(i)), IR::AccType::ATOMIC); - address = v.ir.Add(address, v.ir.Imm32(4)); + ir.WriteMemory32(address, ir.GetRegister(static_cast(i)), IR::AccType::ATOMIC); + address = ir.Add(address, ir.Imm32(4)); } } if (W) { - v.ir.SetRegister(n, writeback_address); + ir.SetRegister(n, writeback_address); } if (mcl::bit::get_bit<15>(list)) { - v.ir.WriteMemory32(address, v.ir.Imm32(v.ir.PC()), IR::AccType::ATOMIC); + ir.WriteMemory32(address, ir.Imm32(ir.PC()), IR::AccType::ATOMIC); } - return v.MemoryInstructionContinues(); + return true; } // STM {!}, @@ -904,7 +902,7 @@ bool TranslatorVisitor::arm_STM(Cond cond, bool W, Reg n, RegList list) { const auto start_address = ir.GetRegister(n); const auto writeback_address = ir.Add(start_address, ir.Imm32(u32(mcl::bit::count_ones(list) * 4))); - return STMHelper(*this, W, n, list, start_address, writeback_address); + return STMHelper(ir, W, n, list, start_address, writeback_address); } // STMDA {!}, @@ -919,7 +917,7 @@ bool TranslatorVisitor::arm_STMDA(Cond cond, bool W, Reg n, RegList list) { const auto start_address = ir.Sub(ir.GetRegister(n), ir.Imm32(u32(4 * mcl::bit::count_ones(list) - 4))); const auto writeback_address = ir.Sub(start_address, ir.Imm32(4)); - return STMHelper(*this, W, n, list, start_address, writeback_address); + return STMHelper(ir, W, n, list, start_address, writeback_address); } // STMDB {!}, @@ -934,7 +932,7 @@ bool TranslatorVisitor::arm_STMDB(Cond cond, bool W, Reg n, RegList list) { const auto start_address = ir.Sub(ir.GetRegister(n), ir.Imm32(u32(4 * mcl::bit::count_ones(list)))); const auto writeback_address = start_address; - return STMHelper(*this, W, n, list, start_address, writeback_address); + return STMHelper(ir, W, n, list, start_address, writeback_address); } // STMIB {!}, @@ -949,7 +947,7 @@ bool TranslatorVisitor::arm_STMIB(Cond cond, bool W, Reg n, RegList list) { const auto start_address = ir.Add(ir.GetRegister(n), ir.Imm32(4)); const auto writeback_address = ir.Add(ir.GetRegister(n), ir.Imm32(u32(4 * mcl::bit::count_ones(list)))); - return STMHelper(*this, W, n, list, start_address, writeback_address); + return STMHelper(ir, W, n, list, start_address, writeback_address); } bool TranslatorVisitor::arm_STM_usr() { diff --git a/src/dynarmic/frontend/A32/translate/impl/synchronization.cpp b/src/dynarmic/frontend/A32/translate/impl/synchronization.cpp index 5d86f278..e9f04b70 100644 --- a/src/dynarmic/frontend/A32/translate/impl/synchronization.cpp +++ b/src/dynarmic/frontend/A32/translate/impl/synchronization.cpp @@ -29,7 +29,7 @@ bool TranslatorVisitor::arm_SWP(Cond cond, Reg n, Reg t, Reg t2) { ir.WriteMemory32(ir.GetRegister(n), ir.GetRegister(t2), IR::AccType::SWAP); // TODO: Alignment check ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // SWPB , , [] @@ -48,7 +48,7 @@ bool TranslatorVisitor::arm_SWPB(Cond cond, Reg n, Reg t, Reg t2) { ir.WriteMemory8(ir.GetRegister(n), ir.LeastSignificantByte(ir.GetRegister(t2)), IR::AccType::SWAP); // TODO: Alignment check ir.SetRegister(t, ir.ZeroExtendByteToWord(data)); - return MemoryInstructionContinues(); + return true; } // LDA , [] @@ -63,7 +63,7 @@ bool TranslatorVisitor::arm_LDA(Cond cond, Reg n, Reg t) { const auto address = ir.GetRegister(n); ir.SetRegister(t, ir.ReadMemory32(address, IR::AccType::ORDERED)); - return MemoryInstructionContinues(); + return true; } // LDAB , [] bool TranslatorVisitor::arm_LDAB(Cond cond, Reg n, Reg t) { @@ -77,7 +77,7 @@ bool TranslatorVisitor::arm_LDAB(Cond cond, Reg n, Reg t) { const auto address = ir.GetRegister(n); ir.SetRegister(t, ir.ZeroExtendToWord(ir.ReadMemory8(address, IR::AccType::ORDERED))); - return MemoryInstructionContinues(); + return true; } // LDAH , [] bool TranslatorVisitor::arm_LDAH(Cond cond, Reg n, Reg t) { @@ -91,7 +91,7 @@ bool TranslatorVisitor::arm_LDAH(Cond cond, Reg n, Reg t) { const auto address = ir.GetRegister(n); ir.SetRegister(t, ir.ZeroExtendToWord(ir.ReadMemory16(address, IR::AccType::ORDERED))); - return MemoryInstructionContinues(); + return true; } // LDAEX , [] @@ -106,7 +106,7 @@ bool TranslatorVisitor::arm_LDAEX(Cond cond, Reg n, Reg t) { const auto address = ir.GetRegister(n); ir.SetRegister(t, ir.ExclusiveReadMemory32(address, IR::AccType::ORDERED)); - return MemoryInstructionContinues(); + return true; } // LDAEXB , [] @@ -121,7 +121,7 @@ bool TranslatorVisitor::arm_LDAEXB(Cond cond, Reg n, Reg t) { const auto address = ir.GetRegister(n); ir.SetRegister(t, ir.ZeroExtendByteToWord(ir.ExclusiveReadMemory8(address, IR::AccType::ORDERED))); - return MemoryInstructionContinues(); + return true; } // LDAEXD , , [] @@ -139,7 +139,7 @@ bool TranslatorVisitor::arm_LDAEXD(Cond cond, Reg n, Reg t) { // DO NOT SWAP hi AND lo IN BIG ENDIAN MODE, THIS IS CORRECT BEHAVIOUR ir.SetRegister(t, lo); ir.SetRegister(t + 1, hi); - return MemoryInstructionContinues(); + return true; } // LDAEXH , [] @@ -154,7 +154,7 @@ bool TranslatorVisitor::arm_LDAEXH(Cond cond, Reg n, Reg t) { const auto address = ir.GetRegister(n); ir.SetRegister(t, ir.ZeroExtendHalfToWord(ir.ExclusiveReadMemory16(address, IR::AccType::ORDERED))); - return MemoryInstructionContinues(); + return true; } // STL , [] @@ -169,7 +169,7 @@ bool TranslatorVisitor::arm_STL(Cond cond, Reg n, Reg t) { const auto address = ir.GetRegister(n); ir.WriteMemory32(address, ir.GetRegister(t), IR::AccType::ORDERED); - return MemoryInstructionContinues(); + return true; } // STLB , [] @@ -184,7 +184,7 @@ bool TranslatorVisitor::arm_STLB(Cond cond, Reg n, Reg t) { const auto address = ir.GetRegister(n); ir.WriteMemory8(address, ir.LeastSignificantByte(ir.GetRegister(t)), IR::AccType::ORDERED); - return MemoryInstructionContinues(); + return true; } // STLH , , [] @@ -199,7 +199,7 @@ bool TranslatorVisitor::arm_STLH(Cond cond, Reg n, Reg t) { const auto address = ir.GetRegister(n); ir.WriteMemory16(address, ir.LeastSignificantHalf(ir.GetRegister(t)), IR::AccType::ORDERED); - return MemoryInstructionContinues(); + return true; } // STLEXB , , [] @@ -220,7 +220,7 @@ bool TranslatorVisitor::arm_STLEXB(Cond cond, Reg n, Reg d, Reg t) { const auto value = ir.LeastSignificantByte(ir.GetRegister(t)); const auto passed = ir.ExclusiveWriteMemory8(address, value, IR::AccType::ORDERED); ir.SetRegister(d, passed); - return MemoryInstructionContinues(); + return true; } // STLEXD , , , [] bool TranslatorVisitor::arm_STLEXD(Cond cond, Reg n, Reg d, Reg t) { @@ -242,7 +242,7 @@ bool TranslatorVisitor::arm_STLEXD(Cond cond, Reg n, Reg d, Reg t) { const auto value_hi = ir.GetRegister(t2); const auto passed = ir.ExclusiveWriteMemory64(address, value_lo, value_hi, IR::AccType::ORDERED); ir.SetRegister(d, passed); - return MemoryInstructionContinues(); + return true; } // STLEXH , , [] @@ -263,7 +263,7 @@ bool TranslatorVisitor::arm_STLEXH(Cond cond, Reg n, Reg d, Reg t) { const auto value = ir.LeastSignificantHalf(ir.GetRegister(t)); const auto passed = ir.ExclusiveWriteMemory16(address, value, IR::AccType::ORDERED); ir.SetRegister(d, passed); - return MemoryInstructionContinues(); + return true; } // STLEX , , [] @@ -284,7 +284,7 @@ bool TranslatorVisitor::arm_STLEX(Cond cond, Reg n, Reg d, Reg t) { const auto value = ir.GetRegister(t); const auto passed = ir.ExclusiveWriteMemory32(address, value, IR::AccType::ORDERED); ir.SetRegister(d, passed); - return MemoryInstructionContinues(); + return true; } // LDREX , [] @@ -299,7 +299,7 @@ bool TranslatorVisitor::arm_LDREX(Cond cond, Reg n, Reg t) { const auto address = ir.GetRegister(n); ir.SetRegister(t, ir.ExclusiveReadMemory32(address, IR::AccType::ATOMIC)); - return MemoryInstructionContinues(); + return true; } // LDREXB , [] @@ -314,7 +314,7 @@ bool TranslatorVisitor::arm_LDREXB(Cond cond, Reg n, Reg t) { const auto address = ir.GetRegister(n); ir.SetRegister(t, ir.ZeroExtendByteToWord(ir.ExclusiveReadMemory8(address, IR::AccType::ATOMIC))); - return MemoryInstructionContinues(); + return true; } // LDREXD , , [] @@ -332,7 +332,7 @@ bool TranslatorVisitor::arm_LDREXD(Cond cond, Reg n, Reg t) { // DO NOT SWAP hi AND lo IN BIG ENDIAN MODE, THIS IS CORRECT BEHAVIOUR ir.SetRegister(t, lo); ir.SetRegister(t + 1, hi); - return MemoryInstructionContinues(); + return true; } // LDREXH , [] @@ -347,7 +347,7 @@ bool TranslatorVisitor::arm_LDREXH(Cond cond, Reg n, Reg t) { const auto address = ir.GetRegister(n); ir.SetRegister(t, ir.ZeroExtendHalfToWord(ir.ExclusiveReadMemory16(address, IR::AccType::ATOMIC))); - return MemoryInstructionContinues(); + return true; } // STREX , , [] @@ -368,7 +368,7 @@ bool TranslatorVisitor::arm_STREX(Cond cond, Reg n, Reg d, Reg t) { const auto value = ir.GetRegister(t); const auto passed = ir.ExclusiveWriteMemory32(address, value, IR::AccType::ATOMIC); ir.SetRegister(d, passed); - return MemoryInstructionContinues(); + return true; } // STREXB , , [] @@ -389,7 +389,7 @@ bool TranslatorVisitor::arm_STREXB(Cond cond, Reg n, Reg d, Reg t) { const auto value = ir.LeastSignificantByte(ir.GetRegister(t)); const auto passed = ir.ExclusiveWriteMemory8(address, value, IR::AccType::ATOMIC); ir.SetRegister(d, passed); - return MemoryInstructionContinues(); + return true; } // STREXD , , , [] @@ -412,7 +412,7 @@ bool TranslatorVisitor::arm_STREXD(Cond cond, Reg n, Reg d, Reg t) { const auto value_hi = ir.GetRegister(t2); const auto passed = ir.ExclusiveWriteMemory64(address, value_lo, value_hi, IR::AccType::ATOMIC); ir.SetRegister(d, passed); - return MemoryInstructionContinues(); + return true; } // STREXH , , [] @@ -433,7 +433,7 @@ bool TranslatorVisitor::arm_STREXH(Cond cond, Reg n, Reg d, Reg t) { const auto value = ir.LeastSignificantHalf(ir.GetRegister(t)); const auto passed = ir.ExclusiveWriteMemory16(address, value, IR::AccType::ATOMIC); ir.SetRegister(d, passed); - return MemoryInstructionContinues(); + return true; } } // namespace Dynarmic::A32 diff --git a/src/dynarmic/frontend/A32/translate/impl/thumb16.cpp b/src/dynarmic/frontend/A32/translate/impl/thumb16.cpp index 957cc4e1..0c531e9f 100644 --- a/src/dynarmic/frontend/A32/translate/impl/thumb16.cpp +++ b/src/dynarmic/frontend/A32/translate/impl/thumb16.cpp @@ -449,7 +449,7 @@ bool TranslatorVisitor::thumb16_LDR_literal(Reg t, Imm<8> imm8) { const auto data = ir.ReadMemory32(ir.Imm32(address), IR::AccType::NORMAL); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // STR , [, ] @@ -459,7 +459,7 @@ bool TranslatorVisitor::thumb16_STR_reg(Reg m, Reg n, Reg t) { const auto data = ir.GetRegister(t); ir.WriteMemory32(address, data, IR::AccType::NORMAL); - return MemoryInstructionContinues(); + return true; } // STRH , [, ] @@ -469,7 +469,7 @@ bool TranslatorVisitor::thumb16_STRH_reg(Reg m, Reg n, Reg t) { const auto data = ir.LeastSignificantHalf(ir.GetRegister(t)); ir.WriteMemory16(address, data, IR::AccType::NORMAL); - return MemoryInstructionContinues(); + return true; } // STRB , [, ] @@ -479,7 +479,7 @@ bool TranslatorVisitor::thumb16_STRB_reg(Reg m, Reg n, Reg t) { const auto data = ir.LeastSignificantByte(ir.GetRegister(t)); ir.WriteMemory8(address, data, IR::AccType::NORMAL); - return MemoryInstructionContinues(); + return true; } // LDRSB , [, ] @@ -489,7 +489,7 @@ bool TranslatorVisitor::thumb16_LDRSB_reg(Reg m, Reg n, Reg t) { const auto data = ir.SignExtendByteToWord(ir.ReadMemory8(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDR , [, ] @@ -499,7 +499,7 @@ bool TranslatorVisitor::thumb16_LDR_reg(Reg m, Reg n, Reg t) { const auto data = ir.ReadMemory32(address, IR::AccType::NORMAL); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRH , [, ] @@ -509,7 +509,7 @@ bool TranslatorVisitor::thumb16_LDRH_reg(Reg m, Reg n, Reg t) { const auto data = ir.ZeroExtendHalfToWord(ir.ReadMemory16(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRB , [, ] @@ -519,7 +519,7 @@ bool TranslatorVisitor::thumb16_LDRB_reg(Reg m, Reg n, Reg t) { const auto data = ir.ZeroExtendByteToWord(ir.ReadMemory8(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // LDRH , [, ] @@ -529,7 +529,7 @@ bool TranslatorVisitor::thumb16_LDRSH_reg(Reg m, Reg n, Reg t) { const auto data = ir.SignExtendHalfToWord(ir.ReadMemory16(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // STR , [, #] @@ -540,7 +540,7 @@ bool TranslatorVisitor::thumb16_STR_imm_t1(Imm<5> imm5, Reg n, Reg t) { const auto data = ir.GetRegister(t); ir.WriteMemory32(address, data, IR::AccType::NORMAL); - return MemoryInstructionContinues(); + return true; } // LDR , [, #] @@ -551,7 +551,7 @@ bool TranslatorVisitor::thumb16_LDR_imm_t1(Imm<5> imm5, Reg n, Reg t) { const auto data = ir.ReadMemory32(address, IR::AccType::NORMAL); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // STRB , [, #] @@ -573,7 +573,7 @@ bool TranslatorVisitor::thumb16_LDRB_imm(Imm<5> imm5, Reg n, Reg t) { const auto data = ir.ZeroExtendByteToWord(ir.ReadMemory8(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // STRH , [, #] @@ -583,7 +583,7 @@ bool TranslatorVisitor::thumb16_STRH_imm(Imm<5> imm5, Reg n, Reg t) { const auto data = ir.LeastSignificantHalf(ir.GetRegister(t)); ir.WriteMemory16(address, data, IR::AccType::NORMAL); - return MemoryInstructionContinues(); + return true; } // LDRH , [, #] @@ -593,7 +593,7 @@ bool TranslatorVisitor::thumb16_LDRH_imm(Imm<5> imm5, Reg n, Reg t) { const auto data = ir.ZeroExtendHalfToWord(ir.ReadMemory16(address, IR::AccType::NORMAL)); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // STR , [, #] @@ -605,7 +605,7 @@ bool TranslatorVisitor::thumb16_STR_imm_t2(Reg t, Imm<8> imm8) { const auto data = ir.GetRegister(t); ir.WriteMemory32(address, data, IR::AccType::NORMAL); - return MemoryInstructionContinues(); + return true; } // LDR , [, #] @@ -617,7 +617,7 @@ bool TranslatorVisitor::thumb16_LDR_imm_t2(Reg t, Imm<8> imm8) { const auto data = ir.ReadMemory32(address, IR::AccType::NORMAL); ir.SetRegister(t, data); - return MemoryInstructionContinues(); + return true; } // ADR ,