cranelift_codegen::flowgraph

Struct ControlFlowGraph

Source
pub struct ControlFlowGraph { /* private fields */ }
Expand description

The Control Flow Graph maintains a mapping of blocks to their predecessors and successors where predecessors are basic blocks and successors are basic blocks.

Implementations§

Source§

impl ControlFlowGraph

Source

pub fn new() -> Self

Allocate a new blank control flow graph.

Source

pub fn clear(&mut self)

Clear all data structures in this control flow graph.

Source

pub fn with_function(func: &Function) -> Self

Allocate and compute the control flow graph for func.

Source

pub fn compute(&mut self, func: &Function)

Compute the control flow graph of func.

This will clear and overwrite any information already stored in this data structure.

Source

pub fn recompute_block(&mut self, func: &Function, block: Block)

Recompute the control flow graph of block.

This is for use after modifying instructions within a specific block. It recomputes all edges from block while leaving edges to block intact. Its functionality a subset of that of the more expensive compute, and should be used when we know we don’t need to recompute the CFG from scratch, but rather that our changes have been restricted to specific blocks.

Source

pub fn pred_iter(&self, block: Block) -> PredIter<'_>

Get an iterator over the CFG predecessors to block.

Source

pub fn succ_iter(&self, block: Block) -> SuccIter<'_>

Get an iterator over the CFG successors to block.

Source

pub fn is_valid(&self) -> bool

Check if the CFG 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 CFG is consistent with the function.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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.