Register allocation with special registers
My register allocator currently deals with special registers in the following way:
- special registers are not
usable, thus it cannot be assigned to a temporary.
- coalescing will not combine special registers with temporaries (even if it is safe and optimal to do so)
We can make this cleaner by manipulating interferences with special registers, and let register allocator make the decision:
- make special registers alive at function exit, so it conflicts with all other temporaries, and register allocator won't assign it to any of the temporaries. But coalescing may combine temporaries with special registers if possible.
- to prevent coalescing in some cases, such as
mov SP -> t add t, 8 -> twe cannot coalesce SP with t. Otherwise changing t will also change the stack pointer. For a general case,
OP t, v -> uif t cannot be coalesced with special register S, the instruction selector can generate code
mov t -> t0 (with def S) OP t0, v -> uthis will add an interference edge between t0 and S, and prevent the coalescing.