pub struct LinearScanAllocator;Expand description
Classic linear scan register allocator (Poletto & Sarkar, 1999).
Usage:
ⓘ
let intervals = LinearScanAllocator::compute_intervals(&function);
let free_regs = vec!["r12", "r13", "r14", "r15", "rbx"];
let alloc_map = LinearScanAllocator::allocate(&intervals, &free_regs);Implementations§
Source§impl LinearScanAllocator
impl LinearScanAllocator
Sourcepub fn compute_intervals(function: &Function) -> Vec<LiveInterval>
pub fn compute_intervals(function: &Function) -> Vec<LiveInterval>
Compute interval hulls from instruction operands and control-flow liveness.
Sourcepub fn allocate<R: Copy + Eq>(
intervals: &[LiveInterval],
available_regs: &[R],
) -> HashMap<VirtualReg, Allocation<R>>
pub fn allocate<R: Copy + Eq>( intervals: &[LiveInterval], available_regs: &[R], ) -> HashMap<VirtualReg, Allocation<R>>
Run the linear scan allocation algorithm.
intervals must be sorted by start (as returned by compute_intervals).
available_regs is the pool of physical registers to draw from (any Copy + Eq
type works — for x86_64 pass &["r12", "r13", ...]).
Returns a map from each VirtualReg to either a physical register or a
spill slot (negative byte offset from frame base).
Sourcepub fn allocate_with_constraints<R: Copy + Eq>(
intervals: &[LiveInterval],
available_regs: &[R],
allowed: impl Fn(&LiveInterval, R) -> bool,
) -> HashMap<VirtualReg, Allocation<R>>
pub fn allocate_with_constraints<R: Copy + Eq>( intervals: &[LiveInterval], available_regs: &[R], allowed: impl Fn(&LiveInterval, R) -> bool, ) -> HashMap<VirtualReg, Allocation<R>>
Allocate registers permitted by each interval’s target constraints.
Auto Trait Implementations§
impl Freeze for LinearScanAllocator
impl RefUnwindSafe for LinearScanAllocator
impl Send for LinearScanAllocator
impl Sync for LinearScanAllocator
impl Unpin for LinearScanAllocator
impl UnsafeUnpin for LinearScanAllocator
impl UnwindSafe for LinearScanAllocator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more