pub struct Predictions { /* private fields */ }Expand description
How likely each edge out of each block is.
Indexed the way the graph is: Predictions::edges gives one probability for each block in
Cfg::successors, in that order. They sum to exactly Probability::SCALE for every block
that has any, which is what the frequency computation in section 11.3 needs and what the test
at the bottom of this file checks on every shape it builds.
Implementations§
Source§impl Predictions
impl Predictions
Sourcepub fn of(func: &Func, cfg: &Cfg, loops: &Loops, callees: &Callees) -> Self
pub fn of(func: &Func, cfg: &Cfg, loops: &Loops, callees: &Callees) -> Self
Predicts every branch in the function.
Linear in the blocks and the edges, except for the two return value predictors, which walk
forward from an arm over blocks with one way out and stop after
PREDICT_RETURN_BLOCKS of them.
Sourcepub fn edges(&self, block: Block) -> &[Probability]
pub fn edges(&self, block: Block) -> &[Probability]
The probability of each edge out of this block, in Cfg::successors order.
Sourcepub fn taken(&self, block: Block, index: usize) -> Probability
pub fn taken(&self, block: Block, index: usize) -> Probability
The probability of the edge at that position among this block’s successors.
Zero for an edge that is not there, because the chance of taking an edge that does not exist is not a guess.
Trait Implementations§
Source§impl Clone for Predictions
impl Clone for Predictions
Source§fn clone(&self) -> Predictions
fn clone(&self) -> Predictions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more