Issue 21: Fix register allocation
Status:  WontFix
Owner:
Closed:  Aug 23
Project Member Reported by ejrh00@gmail.com, Nov 17, 2011
The current plan for this was to define variables that correspond to actual physical registers.  These would be named $rax, etc.  They would be precoloured too.

Then a statement like "x = p / q", which compiled to the DIV instruction having special register requirements, would have an intermediate form (generated in the i386ification phase) of "$rax = p; $rbx = q; $rax = $rax/$rgx; $rdx = $clobber".

Similarly, a statement like "return y" becomes "$rax = y; return $rax".  (N.B. returning tuples remains totally unimplemented!)

The idea is that this is a way of telling the register allocator to try to arrange things so that the values happen to be in the right registers by the time those instructions are called.  The register allocation cycle will coalesce $rax and p if possible, etc.  It also marks $rdx as occupied by something else: junk data, unless you want the result of p % q too.  (N.B. There are no plans for getting both p / q and p % q from the same DIV instruction, at this time.)  The register allocation cycle will also try to coalesce $rax and y.

Another thing that could help is live range splitting.  Somehow.

Unfortunately things currently are a bit of a mess, and I haven't done any real work on the compiler for ages.  Getting it back on its feet will take a bit of work.  But given I started it circa 2003, had a 5 year holiday, then began to make real progress... it could still happen!

Aug 23, 2015
Project Member #1 ejrh00@gmail.com
(No comment was entered for this change.)
Status: WontFix