zetah11 / zippy

a smol functional/imperative programming language
MIT License
2 stars 0 forks source link

use register args pervasively in the lir #6

Closed zetah11 closed 2 years ago

zetah11 commented 2 years ago

Everything from code generation to register allocation has turned out to be much, much easier if we only allow lir::Registers in the arguments to calls and returns. The major benefit of doing it this way is that we don't have to worry about which registers we can and cannot clobber in the code generator; instead it is free to just ignore the arguments or parameters all together since any necessary moves or shuffles are inserted beforehand.

The backend should therefore use this technique for all kinds of arguments, including un/conditional jumps.

zetah11 commented 2 years ago

Also worth noting that the lir::Branch::JumpIf lets the then and elze branch take different numbers of registers. This makes the above registirification impractical, so that should be fixed too.