[−][src]Struct falcon::il::ControlFlowGraph
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]
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]
&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]
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]
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 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]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for ControlFlowGraph
[src]
impl<'de> Deserialize<'de> for ControlFlowGraph
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for ControlFlowGraph
[src]
impl Eq for ControlFlowGraph
[src]
impl Hash for ControlFlowGraph
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<ControlFlowGraph> for ControlFlowGraph
[src]
fn eq(&self, other: &ControlFlowGraph) -> bool
[src]
fn ne(&self, other: &ControlFlowGraph) -> bool
[src]
impl Serialize for ControlFlowGraph
[src]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl StructuralEq for ControlFlowGraph
[src]
impl StructuralPartialEq for ControlFlowGraph
[src]
Auto Trait Implementations
impl RefUnwindSafe for ControlFlowGraph
impl Send for ControlFlowGraph
impl Sync for ControlFlowGraph
impl Unpin for ControlFlowGraph
impl UnwindSafe for ControlFlowGraph
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,