Struct cranelift_codegen::loop_analysis::LoopAnalysis

source ·
pub struct LoopAnalysis { /* private fields */ }
Expand description

Loop tree information for a single function.

Loops are referenced by the Loop object, and for each loop you can access its header block, its eventual parent in the loop tree and all the block belonging to the loop.

Implementations§

source§

impl LoopAnalysis

Methods for querying the loop analysis.

source

pub fn new() -> Self

Allocate a new blank loop analysis struct. Use compute to compute the loop analysis for a function.

source

pub fn loops(&self) -> Keys<Loop>

Returns all the loops contained in a function.

source

pub fn loop_header(&self, lp: Loop) -> Block

Returns the header block of a particular loop.

The characteristic property of a loop header block is that it dominates some of its predecessors.

source

pub fn loop_parent(&self, lp: Loop) -> Option<Loop>

Return the eventual parent of a loop in the loop tree.

source

pub fn innermost_loop(&self, block: Block) -> Option<Loop>

Return the innermost loop for a given block.

source

pub fn is_loop_header(&self, block: Block) -> Option<Loop>

Determine if a Block is a loop header. If so, return the loop.

source

pub fn is_in_loop(&self, block: Block, lp: Loop) -> bool

Determine if a Block belongs to a loop by running a finger along the loop tree.

Returns true if block is in loop lp.

source

pub fn is_child_loop(&self, child: Loop, parent: Loop) -> bool

Determines if a loop is contained in another loop.

is_child_loop(child,parent) returns true if and only if child is a child loop of parent (or child == parent).

source

pub fn loop_level(&self, block: Block) -> LoopLevel

Returns the loop-nest level of a given block.

source§

impl LoopAnalysis

source

pub fn compute( &mut self, func: &Function, cfg: &ControlFlowGraph, domtree: &DominatorTree, )

Detects the loops in a function. Needs the control flow graph and the dominator tree.

source

pub fn is_valid(&self) -> bool

Check if the loop analysis is in a valid state.

Note that this doesn’t perform any kind of validity checks. It simply checks if the compute() method has been called since the last clear(). It does not check that the loop analysis is consistent with the CFG.

source

pub fn clear(&mut self)

Clear all the data structures contained in the loop analysis. This will leave the analysis in a similar state to a context returned by new() except that allocated memory be retained.

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.