Skip to main content

Register

Trait Register 

Source
pub trait Register:
    Copy
    + Clone
    + Debug
    + Hash
    + Eq {
    // Required methods
    fn id(&self) -> u32;
    fn abi_class(&self) -> AbiClass;

    // Provided methods
    fn is_caller_saved(&self) -> bool { ... }
    fn is_callee_saved(&self) -> bool { ... }
    fn is_special(&self) -> bool { ... }
}
Expand description

A register identifier for a target architecture

Required Methods§

Source

fn id(&self) -> u32

Get the register number/identifier

Source

fn abi_class(&self) -> AbiClass

Get the ABI classification for this register.

This method should return the appropriate AbiClass based on the target architecture’s calling convention.

§Example
// For RISC-V
match self {
    Register::T0 | Register::T1 => AbiClass::CallerSaved,
    Register::S0 | Register::S1 => AbiClass::CalleeSaved,
    Register::SP | Register::FP => AbiClass::Other,
    // ...
}

Provided Methods§

Source

fn is_caller_saved(&self) -> bool

Check if this register is caller-saved.

Convenience method equivalent to self.abi_class() == AbiClass::CallerSaved.

Source

fn is_callee_saved(&self) -> bool

Check if this register is callee-saved.

Convenience method equivalent to self.abi_class() == AbiClass::CalleeSaved.

Source

fn is_special(&self) -> bool

Check if this register is special-purpose.

Convenience method equivalent to self.abi_class() == AbiClass::Special.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Register for jit_assembler::riscv64::instruction::Register

Source§

impl Register for jit_assembler::aarch64::instruction::Register