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>
impl<'a, C: PcodeLoweringContext + ?Sized, W: Width> SizeInference<'a, C, W>
Sourcepub fn run<S>(context: &'a C, statements: &[Ast<S>]) -> HashMap<LocalVarId, W>
pub fn run<S>(context: &'a C, statements: &[Ast<S>]) -> HashMap<LocalVarId, W>
Infers the widths of statements to a fixed point.
Sourcepub fn statement<E: ExprNode>(&mut self, statement: StmtKind<'_, E>)
pub fn statement<E: ExprNode>(&mut self, statement: StmtKind<'_, E>)
Constrains the locals of the next statement by their uses in it.
Sourcepub fn progressed(&mut self) -> bool
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.
Sourcepub fn finish(self) -> HashMap<LocalVarId, W>
pub fn finish(self) -> HashMap<LocalVarId, W>
The widths found so far.