Trait RegisterAllocator

Source
pub trait RegisterAllocator: Default {
    // Required methods
    fn add_use(&mut self, reg: VReg);
    fn add_def(&mut self, reg: VReg);
    fn force_same(&mut self, reg: VReg, constraint: VReg);
    fn next_live_step(&mut self);
    fn allocate_regs<I>(self) -> HashMap<VReg, VReg>
       where I: Instr;
}
Expand description

RegisterAllocator is the trait register allocators implement. Implementations of this trait can be used wherever a register allocator is needed.

Required Methods§

Source

fn add_use(&mut self, reg: VReg)

Appends a usage of the given register. The register passed in must be a VReg::Virtual.

Source

fn add_def(&mut self, reg: VReg)

Appends a definition of the given register. Note that this does not redefine the register, so it can be used multiple times. The register passed in must be a VReg::Virtual.

Source

fn force_same(&mut self, reg: VReg, constraint: VReg)

Forces the given register to be equivalent to the constraint. Note that the register passed in must be a VReg::Virtual whereas the constraint passed in must be a VReg::RealRegister.

Source

fn next_live_step(&mut self)

Tells the register allocator that the current live step has ended and to proceed to the next one.

Source

fn allocate_regs<I>(self) -> HashMap<VReg, VReg>
where I: Instr,

Performs register allocation for the given Instr.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§