Skip to main content

SizeInference

Struct SizeInference 

Source
pub struct SizeInference<'a, C: PcodeLoweringContext + ?Sized, W: Width> { /* private fields */ }
Expand description

The width-inference pass, shared by specification-compile time and by per-instruction planning.

It is generic over the statement representation so a producer can run it over its own source bodies, and over the width domain so those bodies can be resolved before the values a decode substitutes into them are known.

Inference is a fixed point: a forward-only pass cannot size, for example, v = 255 & 31 until a later word << v reveals that v is a word-wide shift count. run iterates it over a slice; a producer that streams its statements feeds them through statement and repeats the whole sequence while progressed says a pass found something new, at most once more than there are statements.

Implementations§

Source§

impl<'a, C: PcodeLoweringContext + ?Sized, W: Width> SizeInference<'a, C, W>

Source

pub fn new(context: &'a C) -> Self

Starts an inference with no widths known.

Source

pub fn run<S>(context: &'a C, statements: &[Ast<S>]) -> HashMap<LocalVarId, W>

Infers the widths of statements to a fixed point.

Source

pub fn statement<E: ExprNode>(&mut self, statement: StmtKind<'_, E>)

Constrains the locals of the next statement by their uses in it.

Source

pub fn progressed(&mut self) -> bool

Whether a width was found since this was last asked, so the caller knows to feed the statements again.

Source

pub fn finish(self) -> HashMap<LocalVarId, W>

The widths found so far.

Auto Trait Implementations§

§

impl<'a, C, W> Freeze for SizeInference<'a, C, W>

§

impl<'a, C, W> RefUnwindSafe for SizeInference<'a, C, W>

§

impl<'a, C, W> Send for SizeInference<'a, C, W>
where &'a C: Send, HashMap<LocalVarId, W>: Send, C: ?Sized,

§

impl<'a, C, W> Sync for SizeInference<'a, C, W>
where &'a C: Sync, HashMap<LocalVarId, W>: Sync, C: ?Sized,

§

impl<'a, C, W> Unpin for SizeInference<'a, C, W>

§

impl<'a, C, W> UnsafeUnpin for SizeInference<'a, C, W>

§

impl<'a, C, W> UnwindSafe for SizeInference<'a, C, W>

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.