parrotcode: Untitled | |
Contents | Compilers |
This file contains functions implementing a somewhat modified version of the linear scan register allocation algorithm. This algorithm assumes there's a fixed number of registers, which is not the case for Parrot. Therefore, the algorithm is modified in some places.
lsr_allocator *new_linear_scan_register_allocator(void)
void destroy_linear_scan_regiser_allocator(lsr_allocator *lsr)
live_interval *new_live_interval(lsr_allocator *const lsr, unsigned firstuse_location, pir_type type)
firstuse_location
.
Note that an interval has a type; the register allocator keeps a list of interval for each type,
because obviously you can't mix different types of registers.void add_live_interval(lsr_allocator *const lsr, live_interval *const i, pir_type type)
i
to the list; this list is sorted on increasing start point.static void add_interval_to_active(lsr_allocator *lsr, live_interval *i, pir_type type)
i
to the list of active intervals; the list is sorted on increasing endpoint.static unsigned get_free_reg(lsr_allocator *const lsr, pir_type type)
static void add_free_reg(lsr_allocator *const lsr, unsigned regno, pir_type type)
regno
to the list of free regs that can be reuse.static void remove_from_active(live_interval *i)
i
from the list of active intervals.static void expire_old_intervals(lsr_allocator *const lsr, live_interval *i, pir_type type)
i
's start point,
the action is aborted.
This is why the active
list must be sorted on increasing endpoint.
Otherwise j
is 'removed' from active,
as it has expired.
(the variable is no longer needed).void linear_scan_register_allocation(lsr_allocator *const lsr)
|