pub struct Allocation { /* private fields */ }Expand description
What the allocator did.
§Examples
use backend_lang::mir::{Effects, Function, Operand};
use backend_lang::regalloc;
use backend_lang::x86_64::{op, GPR, SYSV, RAX};
let mut f = Function::new("f", &SYSV);
let b = f.block()?;
let v = f.vreg(GPR)?;
f.push(b, op::MOV64RI, &[v.into(), Operand::Imm(7)])?;
f.push(b, op::COPY, &[RAX.into(), v.into()])?;
f.push_with(b, op::RET, &[], Effects::new().uses(&[RAX]))?;
let a = regalloc::allocate(&mut f)?;
assert_eq!(a.spilled(), 0);
// The value was given rax, the register it is copied to: no move left.
assert_eq!(backend_lang::emit(&f)?, [0x55, 0x48, 0x89, 0xE5, 0xB8, 7, 0, 0, 0, 0x5D, 0xC3]);Implementations§
Source§impl Allocation
impl Allocation
Sourcepub fn rematerialized(&self) -> u32
pub fn rematerialized(&self) -> u32
Sourcepub fn max_pressure(&self) -> u32
pub fn max_pressure(&self) -> u32
The most values of one class live at once, before any spilling: the register pressure the function itself demands.
§Examples
See Allocation.
Sourcepub fn assignment(&self) -> Option<(&Function, &[Location])>
pub fn assignment(&self) -> Option<(&Function, &[Location])>
With Options::keep_assignment: the virtual function the final
round colored (after spill code was inserted), and each of its virtual
registers’ locations, indexed by VReg::index.
§Examples
use backend_lang::mir::{Function, Operand};
use backend_lang::regalloc::{self, Location, Options};
use backend_lang::x86_64::{op, GPR, SYSV};
let mut f = Function::new("f", &SYSV);
let b = f.block()?;
let v = f.vreg(GPR)?;
f.push(b, op::MOV64RI, &[v.into(), Operand::Imm(7)])?;
f.push(b, op::CMP64, &[v.into(), Operand::Imm(1)])?;
f.push(b, op::RET, &[])?;
let a = regalloc::allocate_with(&mut f, &Options::new().keep_assignment(true))?;
let (virt, locs) = a.assignment().unwrap();
assert_eq!(virt.vreg_count(), locs.len());
assert!(matches!(locs[0], Location::Reg(_)));Trait Implementations§
Source§impl Clone for Allocation
impl Clone for Allocation
Auto Trait Implementations§
impl Freeze for Allocation
impl RefUnwindSafe for Allocation
impl Send for Allocation
impl Sync for Allocation
impl Unpin for Allocation
impl UnsafeUnpin for Allocation
impl UnwindSafe for Allocation
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