pub struct VReg(/* private fields */);Expand description
A virtual register: an index into a function’s virtual-register table.
Virtual registers are created by
Function::vreg, each with a
RegClass, and printed as %N.
§Examples
use backend_lang::mir::Function;
use backend_lang::x86_64::{GPR, SYSV};
let mut f = Function::new("f", &SYSV);
let v = f.vreg(GPR).unwrap();
assert_eq!(v.as_virt().map(|v| v.index()), Some(0));
assert_eq!(f.vreg_class(v.as_virt().unwrap()), Some(GPR));Implementations§
Source§impl VReg
impl VReg
Sourcepub const MAX: usize
pub const MAX: usize
The most virtual registers one function may have: indexes use 31
bits, because Reg keeps the top bit to tell the two kinds apart.
Sourcepub const fn index(self) -> usize
pub const fn index(self) -> usize
The register’s index in its function’s virtual-register table.
§Examples
use backend_lang::mir::Function;
use backend_lang::x86_64::{GPR, SYSV};
let mut f = Function::new("f", &SYSV);
let _ = f.vreg(GPR).unwrap();
let second = f.vreg(GPR).unwrap().as_virt().unwrap();
assert_eq!(second.index(), 1);Trait Implementations§
impl Copy for VReg
impl Eq for VReg
Source§impl Ord for VReg
impl Ord for VReg
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for VReg
impl PartialOrd for VReg
impl StructuralPartialEq for VReg
Auto Trait Implementations§
impl Freeze for VReg
impl RefUnwindSafe for VReg
impl Send for VReg
impl Sync for VReg
impl Unpin for VReg
impl UnsafeUnpin for VReg
impl UnwindSafe for VReg
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