pub struct X64RegAlloc { /* private fields */ }Expand description
x86_64 register allocator supporting System V AMD64 and Microsoft x64 ABIs.
Uses platform-appropriate GPR pools for stable virtual-to-physical register mappings and separate scratch pools for short-lived temporaries.
Implementations§
Source§impl X64RegAlloc
impl X64RegAlloc
Sourcepub fn new(target_os: TargetOperatingSystem) -> Self
pub fn new(target_os: TargetOperatingSystem) -> Self
Creates a new register allocator for the specified target OS.
Sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Creates a new register allocator with default target OS (Linux).
Sourcepub fn set_conservative_mode(&mut self)
pub fn set_conservative_mode(&mut self)
Sets conservative mode for complex functions, using fewer registers to reduce pressure.
pub fn alloc_scratch(&mut self) -> Option<&'static str>
pub fn free_scratch(&mut self, phys: &'static str)
pub fn is_occupied(&self, phys: &'static str) -> bool
pub fn occupy(&mut self, phys: &'static str)
pub fn release(&mut self, phys: &'static str)
pub fn get_mapping_for(&self, v: &VirtualReg) -> Option<&'static str>
pub fn ensure_mapping(&mut self, v: VirtualReg) -> Option<&'static str>
pub fn ensure_mapping_for_gpr(&mut self, v: VirtualReg) -> Option<&'static str>
pub fn mapped_for_register(&self, r: &Register) -> Option<&'static str>
Trait Implementations§
Source§impl Default for X64RegAlloc
impl Default for X64RegAlloc
Source§impl RegisterAllocator for X64RegAlloc
impl RegisterAllocator for X64RegAlloc
Source§fn alloc_scratch(&mut self) -> Option<Self::PhysReg>
fn alloc_scratch(&mut self) -> Option<Self::PhysReg>
Acquire a short-lived scratch register. Returns
None when the dedicated
pool is exhausted so the caller may spill or choose an alternate path.Source§fn free_scratch(&mut self, phys: Self::PhysReg)
fn free_scratch(&mut self, phys: Self::PhysReg)
Release a scratch register obtained through
RegisterAllocator::alloc_scratch.Source§fn get_mapping(&self, vreg: &VirtualReg) -> Option<Self::PhysReg>
fn get_mapping(&self, vreg: &VirtualReg) -> Option<Self::PhysReg>
Look up the physical register currently assigned to the virtual
register, when available.
Source§fn ensure_mapping(&mut self, vreg: VirtualReg) -> Option<Self::PhysReg>
fn ensure_mapping(&mut self, vreg: VirtualReg) -> Option<Self::PhysReg>
Ensure that the virtual register has a permanent mapping. Implementers
can reject unsupported register classes by returning
None, signalling
that the caller should spill.Source§fn mapped_for_register(&self, reg: &Register) -> Option<Self::PhysReg>
fn mapped_for_register(&self, reg: &Register) -> Option<Self::PhysReg>
Resolve the backing physical register for an arbitrary MIR register
(virtual or physical).
Source§fn occupy(&mut self, phys: Self::PhysReg)
fn occupy(&mut self, phys: Self::PhysReg)
Mark a physical register as occupied, removing it from the allocator’s
free pool if necessary.
Source§fn release(&mut self, phys: Self::PhysReg)
fn release(&mut self, phys: Self::PhysReg)
Release a previously occupied physical register back to the pool.
Source§fn is_occupied(&self, phys: Self::PhysReg) -> bool
fn is_occupied(&self, phys: Self::PhysReg) -> bool
Test whether the allocator currently treats the physical register as
occupied.
Auto Trait Implementations§
impl Freeze for X64RegAlloc
impl RefUnwindSafe for X64RegAlloc
impl Send for X64RegAlloc
impl Sync for X64RegAlloc
impl Unpin for X64RegAlloc
impl UnsafeUnpin for X64RegAlloc
impl UnwindSafe for X64RegAlloc
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