Angel Faus wrote:


(1) First, do a register allocation for machine registers, assuming that there are N machine registers and infinite parrot registers.


This uses equally the top N used registers for processor regs. The "spilling" for (1) is loading/moving them to parrot registers/temp registers. Only the load/store would be that what spilling code makes out of those. Then you still have 32 parrot registers per kind to allocate.

But it is not as easy as it reads: We have non preserved registers too, which can be mapped, but are not preserved over function calls, so they must, when mapped and used, be stored to parrots regs and reloaded after extern function calls, if used again in that block or after. Albeit load/stores of this kind can be optimized, depending on register usage.


For example, code generated by (1) would look like:

set m3, 1 # m3 is the machine 3d register add m3, m3, 1
print m3


set $I1, m3 # $I1 is a parrot virtual register


Not exactly: print is an external function.
Assuming ri0 - ri3 are mapped, ri3 is not callee saved:

  set ri0, 1
  add ri0, 1
  set $I0, ri0  # save for print $I0
  set $I1, ri3  # save/preserve the register, when used
  print $I0     # external function
  set ri3, $I1  # load
  add ri3, ri1, ri2     # do something


(For debugging mapped registers are printed ri0..x or rn0..y by imcc)



Hope that it know make more sense,


More, yes. This would give us 32 + N - (0..x) registers, where x is the amount of non callee saved registers in the worst case, or 0 most of the time. The $1 above can be always a new temp, which would then have a very limited life range inside one basic block.


-angel


leo





Reply via email to