Description
The rv32emu employs block chaining, macro-operation fusion during the decoding stage would be generally more advantageous. This is because the primary benefit of block chaining is to streamline the transition between basic blocks during execution. By fusing operations during decoding, we reduce the overall number of operations and potentially the number of basic blocks, making the block chaining more efficient. Additionally, doing this work upfront during decoding means that the execution phase can remain fast and efficient, which is critical for both interpreters and JIT compilers.
However, the best approach can vary based on specific emulator design goals, the nature of the instruction set being emulated, and the typical workload expected for the emulator. In practice, a hybrid approach might also be feasible, where some fusion decisions are made during decoding and others are deferred until execution, depending on the context and potential optimization gains.
Once macro-operation fusion is implemented through the hybrid instruction decoding and execution stages, more complex scenarios, such as dynamic superinstructions (#282), can be applied in a similar and more concrete manner. Similarly, C routine substitution can be implemented more efficiently in the instruction decoding stage, because optimized routines such as memcmp
can always be used to recognize the target instruction sequences.
Additional materals: