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 new_leaf(target_os: TargetOperatingSystem) -> Self
pub fn new_leaf(target_os: TargetOperatingSystem) -> Self
Creates a new register allocator for leaf functions (no calls), expanding the available register pool by including r10/r11 as mappable GPRs since they won’t be clobbered.
Sourcepub fn gpr_pool_for_global_allocation(
_target_os: TargetOperatingSystem,
_leaf: bool,
) -> Vec<&'static str>
pub fn gpr_pool_for_global_allocation( _target_os: TargetOperatingSystem, _leaf: bool, ) -> Vec<&'static str>
GPR candidates for global allocation; emitter constraints apply separately.
Sourcepub fn xmm_pool_for_global_allocation(
target_os: TargetOperatingSystem,
) -> Vec<&'static str>
pub fn xmm_pool_for_global_allocation( target_os: TargetOperatingSystem, ) -> Vec<&'static str>
Vector register candidates for global allocation of RegisterClass::Vec values.
Sourcepub fn from_global_plan(
target_os: TargetOperatingSystem,
leaf: bool,
plan: &HashMap<VirtualReg, Allocation<&'static str>>,
) -> Self
pub fn from_global_plan( target_os: TargetOperatingSystem, leaf: bool, plan: &HashMap<VirtualReg, Allocation<&'static str>>, ) -> Self
Rebuild allocator state from a precomputed plan (global linear scan or graph coloring).
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>
Sourcepub fn xmm_for(&self, v: &VirtualReg) -> Option<&'static str>
pub fn xmm_for(&self, v: &VirtualReg) -> Option<&'static str>
The vector register a globally allocated RegisterClass::Vec value lives in.
pub fn mapped_for_register(&self, r: &Register) -> Option<&'static str>
Trait Implementations§
Source§impl Default for X64RegAlloc
impl Default for X64RegAlloc
Source§impl LocalRegisterAllocator for X64RegAlloc
impl LocalRegisterAllocator for X64RegAlloc
Source§fn alloc_scratch(&mut self) -> Option<Self::PhysReg>
fn alloc_scratch(&mut self) -> Option<Self::PhysReg>
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)
LocalRegisterAllocator::alloc_scratch.Source§fn get_mapping(&self, vreg: &VirtualReg) -> Option<Self::PhysReg>
fn get_mapping(&self, vreg: &VirtualReg) -> Option<Self::PhysReg>
Source§fn ensure_mapping(&mut self, vreg: VirtualReg) -> Option<Self::PhysReg>
fn ensure_mapping(&mut self, vreg: VirtualReg) -> Option<Self::PhysReg>
None, signalling
that the caller should spill.