[][src]Struct falcon::il::ControlFlowGraph

pub struct ControlFlowGraph { /* fields omitted */ }

A directed graph of types Block and Edge.

Entry and Exit

A ControlFlowGraph has an optional, "Entry," and an optional, "Exit." When these are provided, certain convenience functions become available.

For example, when translating a native instruction to Falcon IL, it can be useful to consider an instruction as its own ControlFlowGraph. rep scasb is a great example of when this pattern is helpful. Instructions in a Block will have one entry, and one exit. Explicitly declaring these makes merging ControlFlowGraphs easier.

Methods

impl ControlFlowGraph[src]

pub fn new() -> ControlFlowGraph[src]

pub fn graph(&self) -> &Graph<Block, Edge>[src]

Returns the underlying graph

pub fn set_entry(&mut self, entry: usize) -> Result<()>[src]

Sets the entry point for this ControlFlowGraph to the given Block index.

pub fn set_exit(&mut self, exit: usize) -> Result<()>[src]

Sets the exit point for this ControlFlowGraph to the given Block index.

pub fn entry(&self) -> Option<usize>[src]

Get the entry Block index for this ControlFlowGraph.

pub fn exit(&self) -> Option<usize>[src]

Get the exit Block index for this ControlFlowGraph.

pub fn block(&self, index: usize) -> Result<&Block>[src]

Get a Block by index.

pub fn block_mut(&mut self, index: usize) -> Result<&mut Block>[src]

Get a mutable reference to a Block by index.

pub fn blocks(&self) -> Vec<&Block>[src]

Get every Block in this ControlFlowGraph.

pub fn blocks_mut(&mut self) -> Vec<&mut Block>[src]

Get a mutable reference to every Block in this ControlFlowGraph.

pub fn edge(&self, head: usize, tail: usize) -> Result<&Edge>[src]

Get an Edge by its head and tail Block indices.

pub fn edge_mut(&mut self, head: usize, tail: usize) -> Result<&mut Edge>[src]

Get a mutable reference to an Edge by its head and tail Block indices.

pub fn edges(&self) -> Vec<&Edge>[src]

Get every Edge in thie ControlFlowGraph.

pub fn edges_mut(&mut self) -> Vec<&mut Edge>[src]

Get a mutable reference to every Edge in this ControlFlowGraph.

pub fn edges_in(&self, index: usize) -> Result<Vec<&Edge>>[src]

Get every incoming edge to a block

pub fn edges_out(&self, index: usize) -> Result<Vec<&Edge>>[src]

Get every outgoing edge from a block

pub fn predecessor_indices(&self, index: usize) -> Result<Vec<usize>>[src]

Get the indices of every predecessor of a Block in this ControlFlowGraph.

pub fn successor_indices(&self, index: usize) -> Result<Vec<usize>>[src]

Get the indices of every successor of a Block in this ControlFlowGraph.

pub fn set_address(&mut self, address: Option<u64>)[src]

Sets the address for all instructions in this ControlFlowGraph.

Useful for translators to set address information.

pub fn entry_block(&self) -> Option<Result<&Block>>[src]

Returns the entry block for this ControlFlowGraph

pub fn temp(&mut self, bits: usize) -> Scalar[src]

Generates a temporary scalar unique to this control flow graph.

pub fn new_block(&mut self) -> Result<&mut Block>[src]

Creates a new basic block, adds it to the graph, and returns it

pub fn unconditional_edge(&mut self, head: usize, tail: usize) -> Result<()>[src]

Creates an unconditional edge from one block to another block

pub fn conditional_edge(
    &mut self,
    head: usize,
    tail: usize,
    condition: Expression
) -> Result<()>
[src]

Creates a conditional edge from one block to another block

pub fn merge(&mut self) -> Result<()>[src]

Merge Blocks.

When a Block as only one successor, and that successor has only one predecessor, we merge both into one Block.

pub fn append(&mut self, other: &ControlFlowGraph) -> Result<()>[src]

Appends a control flow graph to this control flow graph.

In order for this to work, the entry and exit of boths graphs must be set, which should be the case for all conformant translators. You can also append to an empty ControlFlowGraph.

pub fn insert(&mut self, other: &ControlFlowGraph) -> Result<(usize, usize)>[src]

Inserts a control flow graph into this control flow graph, and returns the entry and exit indices for inserted graph.

Requires the graph being inserted to have entry set.

This function causes the ControlFlowGraph to become disconnected.

This function is useful for inserting multiple ControlFlowGraphs into one before adding all Edges in a subsequent pass.

Warnings

This invalidates the entry and exit of the control flow graph.

Trait Implementations

impl Clone for ControlFlowGraph[src]

impl Debug for ControlFlowGraph[src]

impl<'de> Deserialize<'de> for ControlFlowGraph[src]

impl Display for ControlFlowGraph[src]

impl Eq for ControlFlowGraph[src]

impl Hash for ControlFlowGraph[src]

impl PartialEq<ControlFlowGraph> for ControlFlowGraph[src]

impl Serialize for ControlFlowGraph[src]

impl StructuralEq for ControlFlowGraph[src]

impl StructuralPartialEq for ControlFlowGraph[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.