pub struct RiscVRegAlloc { /* private fields */ }Expand description
RISC-V register allocator with platform-aware register selection.
RISC-V has 32 general-purpose registers (x0-x31):
- x0: zero (hardwired zero)
- x1: ra (return address)
- x2: sp (stack pointer)
- x3: gp (global pointer)
- x4: tp (thread pointer)
- x5-x7, x28-x31: temporaries
- x8: fp/s0 (frame pointer/saved register)
- x9-x15: s1-s7 (saved registers)
- x16-x27: a0-a7 (argument registers), t0-t6 (temporaries)
The allocator uses a conservative subset until prologue/epilogue support covers every saved register.
Implementations§
Source§impl RiscVRegAlloc
impl RiscVRegAlloc
pub fn new(target_os: TargetOperatingSystem) -> Self
Sourcepub fn set_conservative_mode(&mut self)
pub fn set_conservative_mode(&mut self)
Set conservative mode (limit to fewer registers)
Sourcepub fn get_stack_slot(&self, vreg: &VirtualReg) -> Option<i32>
pub fn get_stack_slot(&self, vreg: &VirtualReg) -> Option<i32>
Get stack slot for a virtual register
Trait Implementations§
Source§impl Default for RiscVRegAlloc
impl Default for RiscVRegAlloc
Source§impl RegisterAllocator for RiscVRegAlloc
impl RegisterAllocator for RiscVRegAlloc
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 RiscVRegAlloc
impl RefUnwindSafe for RiscVRegAlloc
impl Send for RiscVRegAlloc
impl Sync for RiscVRegAlloc
impl Unpin for RiscVRegAlloc
impl UnsafeUnpin for RiscVRegAlloc
impl UnwindSafe for RiscVRegAlloc
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