The zero register is a consistent thorn in our side in the recompiler, mostly because on amd64 we simply do not have any registers to spare to just permanently park a zero in it, so we have to work around this by special casing almost every instruction for when it uses the zero register.
This bloats and slows down the recompiler.
It increases complexity significantly.
It needs a lot of special casing.
A lot of these special cases are essentially never triggered (because the compiler never emits such code), which means that the code for them is mostly untested, which means it can have catastrophic bugs.
It'd be better to just disallow the use of the zero register altogether, and handle this in the linker, translating every instruction which uses the zero register into a corresponding instruction which doesn't (e.g. by replacing it with an immediate).
For example, add a0, a1, zero and add a0, zero, a1 can just be turned into addi a0, a1, 0.
The
zero
register is a consistent thorn in our side in the recompiler, mostly because on amd64 we simply do not have any registers to spare to just permanently park a zero in it, so we have to work around this by special casing almost every instruction for when it uses thezero
register.It'd be better to just disallow the use of the
zero
register altogether, and handle this in the linker, translating every instruction which uses thezero
register into a corresponding instruction which doesn't (e.g. by replacing it with an immediate).For example,
add a0, a1, zero
andadd a0, zero, a1
can just be turned intoaddi a0, a1, 0
.