zorbid
New member
The x86 emulator QEMU team is writing a more or less CPU indenpendant Dynamic Recompiler. I thought you might find it interresting for Mupen (if this can be applied to the R4300i). The main coder is french too...
From http://fabrice.bellard.free.fr/qemu/qemu-doc.html
3.2 Portable dynamic translation
QEMU is a dynamic translator. When it first encounters a piece of code, it converts it to the host instruction set. Usually dynamic translators are very complicated and highly CPU dependant. QEMU uses some tricks which make it relatively easily portable and simple while achieving good performances.
The basic idea is to split every x86 instruction into fewer simpler instructions. Each simple instruction is implemented by a piece of C code (see `op-i386.c'). Then a compile time tool (`dyngen') takes the corresponding object file (`op-i386.o') to generate a dynamic code generator which concatenates the simple instructions to build a function (see `op-i386.h:dyngen_code()').
In essence, the process is similar to [1], but more work is done at compile time.
A key idea to get optimal performances is that constant parameters can be passed to the simple operations. For that purpose, dummy ELF relocations are generated with gcc for each constant parameter. Then, the tool (`dyngen') can locate the relocations and generate the appriopriate C code to resolve them when building the dynamic code.
That way, QEMU is no more difficult to port than a dynamic linker.
To go even faster, GCC static register variables are used to keep the state of the virtual CPU.
Last edited: