Skip to main content

MoveEnv

Struct MoveEnv 

Source
pub struct MoveEnv {
    pub free: RegSet,
    pub scratch_slot: Option<StackSlot>,
    pub victim_slot: Option<StackSlot>,
    pub swap: bool,
}
Expand description

What the resolver may use besides the moves’ own locations.

§Examples

use backend_lang::RegSet;
use backend_lang::mir::StackSlot;
use backend_lang::moves::MoveEnv;
use backend_lang::x86_64::R11;

let env = MoveEnv::new()
    .with_free(RegSet::of(&[R11]))
    .with_scratch_slot(StackSlot::new(4))
    .with_victim_slot(StackSlot::new(5));
assert!(env.free.contains(R11));

Fields§

§free: RegSet

Registers the caller guarantees are dead here and may be overwritten. Registers that are a source or destination of a move are ignored.

§scratch_slot: Option<StackSlot>

A stack slot (of the largest class’s spill size) for a cycle’s saved value when no free register of its class exists.

§victim_slot: Option<StackSlot>

A stack slot to save a borrowed register in, for a memory-to-memory move when no free register exists.

§swap: bool

Whether register cycles may be resolved with swaps (honoured only on targets that have them). On by default.

Implementations§

Source§

impl MoveEnv

Source

pub const fn new() -> MoveEnv

No free registers, no slots, swaps allowed.

§Examples
use backend_lang::moves::MoveEnv;

assert!(MoveEnv::new().free.is_empty());
assert!(MoveEnv::new().swap);
Source

pub const fn with_free(self, free: RegSet) -> MoveEnv

With free as the free registers.

§Examples
use backend_lang::RegSet;
use backend_lang::moves::MoveEnv;
use backend_lang::x86_64::R10;

assert!(MoveEnv::new().with_free(RegSet::of(&[R10])).free.contains(R10));
Source

pub const fn with_scratch_slot(self, slot: StackSlot) -> MoveEnv

With slot as the scratch slot.

§Examples
use backend_lang::mir::StackSlot;
use backend_lang::moves::MoveEnv;

let env = MoveEnv::new().with_scratch_slot(StackSlot::new(0));
assert_eq!(env.scratch_slot, Some(StackSlot::new(0)));
Source

pub const fn with_victim_slot(self, slot: StackSlot) -> MoveEnv

With slot as the victim slot.

§Examples
use backend_lang::mir::StackSlot;
use backend_lang::moves::MoveEnv;

let env = MoveEnv::new().with_victim_slot(StackSlot::new(1));
assert_eq!(env.victim_slot, Some(StackSlot::new(1)));
Source

pub const fn with_swap(self, swap: bool) -> MoveEnv

With swaps allowed or not.

§Examples
use backend_lang::moves::MoveEnv;

assert!(!MoveEnv::new().with_swap(false).swap);

Trait Implementations§

Source§

impl Clone for MoveEnv

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for MoveEnv

Source§

impl Debug for MoveEnv

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MoveEnv

Source§

fn default() -> MoveEnv

Returns the “default value” for a type. Read more
Source§

impl Eq for MoveEnv

Source§

impl PartialEq for MoveEnv

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MoveEnv

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.