Struct falcon::il::ControlFlowGraph [−][src]
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 ControlFlowGraph
s easier.
Methods
impl ControlFlowGraph
[src]
impl ControlFlowGraph
pub fn new() -> ControlFlowGraph
[src]
pub fn new() -> ControlFlowGraph
pub fn graph(&self) -> &Graph<Block, Edge>
[src]
pub fn graph(&self) -> &Graph<Block, Edge>
Returns the underlying graph
pub fn set_entry(&mut self, entry: usize) -> Result<()>
[src]
pub fn set_entry(&mut self, entry: usize) -> Result<()>
Sets the entry point for this ControlFlowGraph
to the given Block
index.
pub fn set_exit(&mut self, exit: usize) -> Result<()>
[src]
pub fn set_exit(&mut self, exit: usize) -> Result<()>
Sets the exit point for this ControlFlowGraph
to the given Block
index.
pub fn entry(&self) -> Option<usize>
[src]
pub fn entry(&self) -> Option<usize>
Get the entry Block
index for this ControlFlowGraph
.
pub fn exit(&self) -> Option<usize>
[src]
pub fn exit(&self) -> Option<usize>
Get the exit Block
index for this ControlFlowGraph
.
pub fn block(&self, index: usize) -> Result<&Block>
[src]
pub fn block(&self, index: usize) -> Result<&Block>
Get a Block
by index.
pub fn block_mut(&mut self, index: usize) -> Result<&mut Block>
[src]
pub fn block_mut(&mut self, index: usize) -> Result<&mut Block>
Get a mutable reference to a Block
by index.
pub fn blocks(&self) -> Vec<&Block>
[src]
pub fn blocks(&self) -> Vec<&Block>
Get every Block
in this ControlFlowGraph
.
pub fn blocks_mut(&mut self) -> Vec<&mut Block>
[src]
pub fn blocks_mut(&mut self) -> Vec<&mut Block>
Get a mutable reference to every Block
in this ControlFlowGraph
.
pub fn edge(&self, head: usize, tail: usize) -> Result<&Edge>
[src]
pub fn edge(&self, head: usize, tail: usize) -> Result<&Edge>
Get an Edge
by its head and tail Block
indices.
pub fn edge_mut(&mut self, head: usize, tail: usize) -> Result<&mut Edge>
[src]
pub fn edge_mut(&mut self, head: usize, tail: usize) -> Result<&mut Edge>
Get a mutable reference to an Edge
by its head and tail Block
indices.
pub fn edges(&self) -> Vec<&Edge>
[src]
pub fn edges(&self) -> Vec<&Edge>
Get every Edge
in thie ControlFlowGraph
.
pub fn edges_mut(&mut self) -> Vec<&mut Edge>
[src]
pub fn edges_mut(&mut self) -> Vec<&mut Edge>
Get a mutable reference to every Edge
in this ControlFlowGraph
.
pub fn edges_in(&self, index: usize) -> Result<&Vec<Edge>>
[src]
pub fn edges_in(&self, index: usize) -> Result<&Vec<Edge>>
Get every incoming edge to a block
pub fn edges_out(&self, index: usize) -> Result<&Vec<Edge>>
[src]
pub fn edges_out(&self, index: usize) -> Result<&Vec<Edge>>
Get every outgoing edge from a block
pub fn set_address(&mut self, address: Option<u64>)
[src]
pub fn set_address(&mut self, address: Option<u64>)
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]
pub fn entry_block(&self) -> Option<Result<&Block>>
Returns the entry block for this ControlFlowGraph
pub fn temp(&mut self, bits: usize) -> Scalar
[src]
pub fn temp(&mut self, bits: usize) -> Scalar
Generates a temporary scalar unique to this control flow graph.
pub fn new_block(&mut self) -> Result<&mut Block>
[src]
pub fn new_block(&mut self) -> Result<&mut Block>
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]
pub fn unconditional_edge(&mut self, head: usize, tail: usize) -> Result<()>
Creates an unconditional edge from one block to another block
pub fn conditional_edge(
&mut self,
head: usize,
tail: usize,
condition: Expression
) -> Result<()>
[src]
pub fn conditional_edge(
&mut self,
head: usize,
tail: usize,
condition: Expression
) -> Result<()>
Creates a conditional edge from one block to another block
pub fn merge(&mut self) -> Result<()>
[src]
pub fn merge(&mut self) -> Result<()>
Merge Block
s.
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]
pub fn append(&mut self, other: &ControlFlowGraph) -> Result<()>
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]
pub fn insert(&mut self, other: &ControlFlowGraph) -> Result<(usize, usize)>
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 ControlFlowGraph
s into
one before adding all Edge
s in a subsequent pass.
Warnings
This invalidates the entry and exit of the control flow graph.
Trait Implementations
impl Clone for ControlFlowGraph
[src]
impl Clone for ControlFlowGraph
fn clone(&self) -> ControlFlowGraph
[src]
fn clone(&self) -> ControlFlowGraph
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for ControlFlowGraph
[src]
impl Debug for ControlFlowGraph
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Hash for ControlFlowGraph
[src]
impl Hash for ControlFlowGraph
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Eq for ControlFlowGraph
[src]
impl Eq for ControlFlowGraph
impl PartialEq for ControlFlowGraph
[src]
impl PartialEq for ControlFlowGraph
fn eq(&self, other: &ControlFlowGraph) -> bool
[src]
fn eq(&self, other: &ControlFlowGraph) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &ControlFlowGraph) -> bool
[src]
fn ne(&self, other: &ControlFlowGraph) -> bool
This method tests for !=
.
impl Display for ControlFlowGraph
[src]
impl Display for ControlFlowGraph
Auto Trait Implementations
impl Send for ControlFlowGraph
impl Send for ControlFlowGraph
impl Sync for ControlFlowGraph
impl Sync for ControlFlowGraph