Skip to main content

Stack

Struct Stack 

Source
pub struct Stack {
    pub calls: Option<u32>,
    pub locals: Vec<Local>,
    pub addresses: Vec<(Inst, usize)>,
    pub arguments: Vec<(Inst, u32)>,
}
Expand description

What a function’s stack has to hold, as far as selection is able to say.

All of it is answered here because selection is where a call is built and where an alloca is read, and nothing after it could tell what either of them needed.

Fields§

§calls: Option<u32>

How many bytes the widest call in the function needs below the stack pointer for the arguments it passes there, or None for a function that makes no call at all.

None is a leaf, which is the function that may use the red zone and the one whose stack pointer does not have to be left aligned for anybody.

§locals: Vec<Local>

The memory the function asked for itself, one entry for every alloca in it, in the order the walk reached them.

§addresses: Vec<(Inst, usize)>

Which instruction computes the address of which of those locals.

An address in the frame is a distance from the stack pointer, and there is no frame until after allocation, so the instruction is written here with nothing in its displacement and crate::finish writes the number in once crate::frame::Frame knows it.

§arguments: Vec<(Inst, u32)>

Which instruction reads which of the arguments the caller passed on the stack, as how far up the caller’s argument area it reads.

Waiting on crate::finish for the same reason the addresses above are, and on one thing more: where the caller’s argument area is from inside this function depends on whether the prologue had to force the stack pointer’s alignment, so which register the load reads through is not settled here either.

Implementations§

Source§

impl Stack

Source

pub fn layout<'a>(&'a self, base: Layout<'a>) -> Layout<'a>

The layout given, with the three fields only the lowering knows the answer to filled in.

Everything else in a layout comes from the flags the function is compiled under or from the allocation, so this takes one and returns it rather than building one.

Trait Implementations§

Source§

impl Debug for Stack

Source§

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

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

impl Default for Stack

Source§

fn default() -> Stack

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

Auto Trait Implementations§

§

impl Freeze for Stack

§

impl RefUnwindSafe for Stack

§

impl Send for Stack

§

impl Sync for Stack

§

impl Unpin for Stack

§

impl UnsafeUnpin for Stack

§

impl UnwindSafe for Stack

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> 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, 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.