A32: Introduce PreCodeReadHook (#763)
* A32: Introduce PreCodeReadHook * A32: Invert code read hook return value
This commit is contained in:
parent
0df09e2f6b
commit
9d1bc6ecc2
4 changed files with 23 additions and 1 deletions
|
@ -30,6 +30,11 @@ IR::Block TranslateArm(LocationDescriptor descriptor, TranslateCallbacks* tcb, c
|
|||
const u32 arm_pc = visitor.ir.current_location.PC();
|
||||
u64 ticks_for_instruction = 1;
|
||||
|
||||
if (!tcb->PreCodeReadHook(false, arm_pc, visitor.ir)) {
|
||||
should_continue = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (const auto arm_instruction = tcb->MemoryReadCode(arm_pc)) {
|
||||
visitor.current_instruction_size = 4;
|
||||
|
||||
|
|
|
@ -18,7 +18,13 @@ struct TranslateCallbacks {
|
|||
// Memory must be interpreted as little endian.
|
||||
virtual std::optional<std::uint32_t> MemoryReadCode(VAddr vaddr) = 0;
|
||||
|
||||
// Thus function is called before the instruction at pc is interpreted.
|
||||
// This function is called before the instruction at pc is read.
|
||||
// IR code can be emitted by the callee prior to instruction handling.
|
||||
// By returning false the callee precludes the translation of the instruction;
|
||||
// in such case the callee is responsible for setting the terminal.
|
||||
virtual bool PreCodeReadHook(bool is_thumb, VAddr pc, A32::IREmitter& ir) = 0;
|
||||
|
||||
// This function is called before the instruction at pc is interpreted.
|
||||
// IR code can be emitted by the callee prior to translation of the instruction.
|
||||
virtual void PreCodeTranslationHook(bool is_thumb, VAddr pc, A32::IREmitter& ir) = 0;
|
||||
|
||||
|
|
|
@ -111,6 +111,11 @@ IR::Block TranslateThumb(LocationDescriptor descriptor, TranslateCallbacks* tcb,
|
|||
const u32 arm_pc = visitor.ir.current_location.PC();
|
||||
u64 ticks_for_instruction = 1;
|
||||
|
||||
if (!tcb->PreCodeReadHook(true, arm_pc, visitor.ir)) {
|
||||
should_continue = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (const auto maybe_instruction = ReadThumbInstruction(arm_pc, tcb)) {
|
||||
const auto [thumb_instruction, inst_size] = *maybe_instruction;
|
||||
const bool is_thumb_16 = inst_size == ThumbInstSize::Thumb16;
|
||||
|
|
|
@ -65,6 +65,12 @@ struct UserCallbacks : public TranslateCallbacks {
|
|||
// Memory must be interpreted as little endian.
|
||||
std::optional<std::uint32_t> MemoryReadCode(VAddr vaddr) override { return MemoryRead32(vaddr); }
|
||||
|
||||
// This function is called before the instruction at pc is read.
|
||||
// IR code can be emitted by the callee prior to instruction handling.
|
||||
// By returning true the callee precludes the translation of the instruction;
|
||||
// in such case the callee is responsible for setting the terminal.
|
||||
bool PreCodeReadHook(bool /*is_thumb*/, VAddr /*pc*/, A32::IREmitter& /*ir*/) override { return true; }
|
||||
|
||||
// Thus function is called before the instruction at pc is interpreted.
|
||||
// IR code can be emitted by the callee prior to translation of the instruction.
|
||||
void PreCodeTranslationHook(bool /*is_thumb*/, VAddr /*pc*/, A32::IREmitter& /*ir*/) override {}
|
||||
|
|
Loading…
Reference in a new issue