pub struct Reg(/* private fields */);Expand description
A register operand: physical or virtual.
Before register allocation, instructions name virtual registers (and the physical registers an ABI or an instruction fixes); after it, only physical ones. Emission requires the latter.
§Examples
use backend_lang::Reg;
use backend_lang::x86_64::RAX;
let r = Reg::from(RAX);
assert_eq!(r.as_phys(), Some(RAX));
assert!(r.as_virt().is_none());Implementations§
Source§impl Reg
impl Reg
Sourcepub const fn as_phys(self) -> Option<PReg>
pub const fn as_phys(self) -> Option<PReg>
The register as a physical register, if it is one.
§Examples
use backend_lang::Reg;
use backend_lang::x86_64::RSI;
assert_eq!(Reg::from(RSI).as_phys(), Some(RSI));Sourcepub const fn as_virt(self) -> Option<VReg>
pub const fn as_virt(self) -> Option<VReg>
The register as a virtual register, if it is one.
§Examples
use backend_lang::mir::Function;
use backend_lang::x86_64::{GPR, SYSV};
let mut f = Function::new("f", &SYSV);
let r = f.vreg(GPR).unwrap();
assert!(r.as_virt().is_some());
assert!(r.as_phys().is_none());Sourcepub const fn is_virtual(self) -> bool
pub const fn is_virtual(self) -> bool
Whether this is a virtual register.
§Examples
use backend_lang::Reg;
use backend_lang::x86_64::RAX;
assert!(!Reg::from(RAX).is_virtual());Trait Implementations§
impl Copy for Reg
impl Eq for Reg
Source§impl Ord for Reg
impl Ord for Reg
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 Reg
impl PartialOrd for Reg
impl StructuralPartialEq for Reg
Auto Trait Implementations§
impl Freeze for Reg
impl RefUnwindSafe for Reg
impl Send for Reg
impl Sync for Reg
impl Unpin for Reg
impl UnsafeUnpin for Reg
impl UnwindSafe for Reg
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