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]
fn new() -> ControlFlowGraph
[src]
fn graph(&self) -> &Graph<Block, Edge>
[src]
Returns the underlying graph
fn set_entry(&mut self, entry: u64) -> Result<()>
[src]
Sets the entry point for this ControlFlowGraph
to the given Block
index.
fn set_exit(&mut self, exit: u64) -> Result<()>
[src]
Sets the exit point for this ControlFlowGraph
to the given Block
index.
fn entry(&self) -> Option<u64>
[src]
Get the entry Block
index for this ControlFlowGraph
.
fn exit(&self) -> Option<u64>
[src]
Get the exit Block
index for this ControlFlowGraph
.
fn block(&self, index: u64) -> Option<&Block>
[src]
Get a Block
by index.
fn block_mut(&mut self, index: u64) -> Option<&mut Block>
[src]
Get a mutable reference to a Block
by index.
fn blocks(&self) -> Vec<&Block>
[src]
Get every Block
in this ControlFlowGraph
.
fn blocks_mut(&mut self) -> Vec<&mut Block>
[src]
Get a mutable reference to every Block
in this ControlFlowGraph
.
fn edge(&self, head: u64, tail: u64) -> Option<&Edge>
[src]
Get an Edge
by its head and tail Block
indices.
fn edge_mut(&mut self, head: u64, tail: u64) -> Option<&mut Edge>
[src]
Get a mutable reference to an Edge
by its head and tail Block
indices.
fn edges(&self) -> Vec<&Edge>
[src]
Get every Edge
in thie ControlFlowGraph
.
fn edges_mut(&mut self) -> Vec<&mut Edge>
[src]
Get a mutable reference to every Edge
in this ControlFlowGraph
.
fn edges_in(&self, index: u64) -> Option<&Vec<Edge>>
[src]
Get every incoming edge to a block
fn edges_out(&self, index: u64) -> Option<&Vec<Edge>>
[src]
Get every outgoing edge from a block
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.
fn entry_block(&self) -> Option<&Block>
[src]
Returns the entry block for this ControlFlowGraph
fn temp(&mut self, bits: usize) -> Scalar
[src]
Generates a temporary scalar unique to this control flow graph.
fn new_block(&mut self) -> Result<&mut Block>
[src]
Creates a new basic block, adds it to the graph, and returns it
fn unconditional_edge(&mut self, head: u64, tail: u64) -> Result<()>
[src]
Creates an unconditional edge from one block to another block
fn conditional_edge(
&mut self,
head: u64,
tail: u64,
condition: Expression
) -> Result<()>
[src]
&mut self,
head: u64,
tail: u64,
condition: Expression
) -> Result<()>
Creates a conditional edge from one block to another block
fn merge(&mut self) -> Result<()>
[src]
Merge Block
s.
When a Block
as only one successor, and that successor has only one predecessor, we
merge both into one Block
.
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.
fn insert(&mut self, other: &ControlFlowGraph) -> Result<(u64, u64)>
[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 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]
fn clone(&self) -> ControlFlowGraph
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for ControlFlowGraph
[src]
impl Eq for ControlFlowGraph
[src]
impl Hash for ControlFlowGraph
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
[src]
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]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Ord for ControlFlowGraph
[src]
fn cmp(&self, __arg_0: &ControlFlowGraph) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl PartialEq for ControlFlowGraph
[src]
fn eq(&self, __arg_0: &ControlFlowGraph) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &ControlFlowGraph) -> bool
[src]
This method tests for !=
.
impl PartialOrd for ControlFlowGraph
[src]
fn partial_cmp(&self, __arg_0: &ControlFlowGraph) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &ControlFlowGraph) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &ControlFlowGraph) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &ControlFlowGraph) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &ControlFlowGraph) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more