I've now (locally here) extended Bill Coffman's register allocator by one subroutine that actually decides to use non-volatiles or volatiles according to pdd03. All variables that are live around a subroutine call are e.g. allocated from R16..R31.

Variables not alive around a call (temps) are allocated preferred in the lower range first.

Seems to work fine and is not really specific to this register allocator, nor to a specific ABI. Its just exploiting the fact that a bunch of registers are preserved around a call.


Works fine *except* for the .flatten_arg directive. This directive takes an argument array and expands the array contents to function arguments in consecutive parrot registers. E.g.


  .arg a                => P5
  .flatten_arg array    => P6, P7, ...

The code emitted to achieve that runs in a loop and is using the Parrot opcode C<setp_ind Ix, Py> which sets the xth Parrot register from Py.

Now this array is typically a temporary and not not used around the call, so it gets allocated in the volatile register range, which then collides with the generated code for function argument passing.

The register allocator doesn't know, that e.g. P6, P7 is effected by this opcode.

see imcc/t/syn/pcc_20 - _25 for examples and ops/set.ops for usage information of this opcode.

leo



Reply via email to