retdec
|
A representation of a control-flow graph node. More...
#include <cfg_node.h>
Classes | |
class | CFGEdge |
A representation of a control-flow graph edge. More... | |
Public Types | |
using | CFGEdgeVector = std::vector< ShPtr< CFGEdge > > |
using | CFGNodeSet = std::unordered_set< ShPtr< CFGNode > > |
using | CFGNodeVector = std::vector< ShPtr< CFGNode > > |
Public Member Functions | |
CFGNode (llvm::BasicBlock *bb, ShPtr< Statement > body) | |
Constructs a new control-flow graph node. More... | |
Operations with stored basic blocks | |
llvm::BasicBlock * | getFirstBB () const |
Returns the first LLVM basic block in sequence which is represented by this node. More... | |
llvm::BasicBlock * | getLastBB () const |
Returns the last LLVM basic block in sequence which is represented by this node. More... | |
void | setLastBB (llvm::BasicBlock *bb) |
Sets bb as the last LLVM basic block in sequence which is represented by this node. More... | |
Operations with terminator instruction of the last basic block | |
llvm::Instruction * | getTerm () const |
Returns the terminator instruction of stored basic block in this node. More... | |
llvm::Value * | getCond () const |
Returns a condition of this node if this is conditional branch. Otherwise, returns nullptr . More... | |
Operations with node's body | |
ShPtr< Statement > | getBody () const |
Returns the body in BIR of this node. More... | |
void | setBody (ShPtr< Statement > body) |
Sets a new body body to this node. More... | |
void | appendToBody (ShPtr< Statement > statement) |
Appends the given statement statement to this node's body. More... | |
Addition and deletion of the node's successors | |
void | addSuccessor (ShPtr< CFGNode > succ) |
Adds a new successor succ to this node. More... | |
void | moveSuccessorsFrom (const ShPtr< CFGNode > &node) |
Moves all successors from the given node node to this node. More... | |
void | removeSucc (std::size_t i) |
Removes a successor of this node on the index i. More... | |
void | deleteSucc (std::size_t i) |
Deletes a successor of this node on the index i. More... | |
void | deleteSuccessors () |
Deletes all successors of this node. More... | |
Getters for number of predecessors and successors | |
std::size_t | getPredsNum () const |
Returns a number of this node successors. More... | |
std::size_t | getSuccNum () const |
Returns a number of this node successors. More... | |
Node's successors getters and querying | |
CFGNodeSet | getPredecessors () |
Returns a set of predecessors of this node. More... | |
CFGNodeVector | getSuccessors () |
Returns a vector of successors of this node. More... | |
ShPtr< CFGNode > | getSucc (std::size_t i) const |
Returns a successor of this node on the index i. More... | |
ShPtr< CFGNode > | getSuccOrNull (std::size_t i) const |
Returns a successor of this node on the index i. If this node does not have a successor on the index i, it returns nullptr . More... | |
bool | hasSuccessor (const ShPtr< CFGNode > &node) const |
Determines whether the given node node is this node's successor. More... | |
Operations with back-edges | |
void | markAsBackEdge (const ShPtr< CFGNode > &node) |
Sets flag that this node's succ node is a back-edge. More... | |
bool | isBackEdge (const ShPtr< CFGNode > &node) const |
Returns true if this node's succ node is a back-edge. More... | |
Operations with statement successor | |
bool | hasStatementSuccessor () const |
Determines whether this node has a statement successor. More... | |
ShPtr< CFGNode > | getStatementSuccessor () const |
Returns the statement successor. More... | |
void | setStatementSuccessor (ShPtr< CFGNode > succ) |
Sets succ as a new statement successor. More... | |
void | removeStatementSuccessor () |
Removes statement successor if exists. More... | |
Debugging methods | |
std::string | getName () const |
Returns the label of first basic block in this node. More... | |
void | debugPrint () const |
Emits this node's name and its successors and predecessors to the standard error output. More... | |
Private Attributes | |
llvm::BasicBlock * | firstBasicBlock |
A first LLVM basic block in sequence which is represented by this node. More... | |
llvm::BasicBlock * | lastBasicBlock |
A last LLVM basic block in sequence which is represented by this node. More... | |
ShPtr< Statement > | body |
A body of this tree node. More... | |
CFGNodeSet | predecessors |
A set of node predecessors. More... | |
CFGEdgeVector | successors |
An ordered vector of node successors. More... | |
ShPtr< CFGNode > | statementSuccessor |
A successor of the high-level statement represented by this node. More... | |
Additional Inherited Members | |
![]() | |
NonCopyable (const NonCopyable &)=delete | |
NonCopyable & | operator= (const NonCopyable &)=delete |
NonCopyable ()=default | |
~NonCopyable ()=default | |
A representation of a control-flow graph node.
using retdec::llvmir2hll::CFGNode::CFGEdgeVector = std::vector<ShPtr<CFGEdge> > |
using retdec::llvmir2hll::CFGNode::CFGNodeSet = std::unordered_set<ShPtr<CFGNode> > |
using retdec::llvmir2hll::CFGNode::CFGNodeVector = std::vector<ShPtr<CFGNode> > |
Constructs a new control-flow graph node.
[in] | bb | An LLVM basic block to store to this tree node. |
[in] | body | A converted body of this tree node. |
Adds a new successor succ to this node.
This method also adds self as predecessor to currently added successor.
Appends the given statement statement to this node's body.
Appended statement statement could be also nullptr
.
void retdec::llvmir2hll::CFGNode::debugPrint | ( | ) | const |
Emits this node's name and its successors and predecessors to the standard error output.
Only for debugging purposes.
void retdec::llvmir2hll::CFGNode::deleteSucc | ( | std::size_t | i | ) |
Deletes a successor of this node on the index i.
Delete means that deleted node will be removed from the tree and all edges to this node will be removed.
i < NUM_NODE_SUCC
, where NUM_NODE_SUCC
is the number of node's successors void retdec::llvmir2hll::CFGNode::deleteSuccessors | ( | ) |
Deletes all successors of this node.
Returns the body in BIR of this node.
llvm::Value * retdec::llvmir2hll::CFGNode::getCond | ( | ) | const |
Returns a condition of this node if this is conditional branch. Otherwise, returns nullptr
.
llvm::BasicBlock * retdec::llvmir2hll::CFGNode::getFirstBB | ( | ) | const |
Returns the first LLVM basic block in sequence which is represented by this node.
llvm::BasicBlock * retdec::llvmir2hll::CFGNode::getLastBB | ( | ) | const |
Returns the last LLVM basic block in sequence which is represented by this node.
std::string retdec::llvmir2hll::CFGNode::getName | ( | ) | const |
Returns the label of first basic block in this node.
CFGNode::CFGNodeSet retdec::llvmir2hll::CFGNode::getPredecessors | ( | ) |
Returns a set of predecessors of this node.
std::size_t retdec::llvmir2hll::CFGNode::getPredsNum | ( | ) | const |
Returns a number of this node successors.
Returns the statement successor.
Returns a successor of this node on the index i.
i < NUM_NODE_SUCC
, where NUM_NODE_SUCC
is the number of node's successors CFGNode::CFGNodeVector retdec::llvmir2hll::CFGNode::getSuccessors | ( | ) |
Returns a vector of successors of this node.
std::size_t retdec::llvmir2hll::CFGNode::getSuccNum | ( | ) | const |
Returns a number of this node successors.
Returns a successor of this node on the index i. If this node does not have a successor on the index i, it returns nullptr
.
llvm::Instruction * retdec::llvmir2hll::CFGNode::getTerm | ( | ) | const |
Returns the terminator instruction of stored basic block in this node.
bool retdec::llvmir2hll::CFGNode::hasStatementSuccessor | ( | ) | const |
Determines whether this node has a statement successor.
Determines whether the given node node is this node's successor.
Returns true
if this node's succ node is a back-edge.
Sets flag that this node's succ node is a back-edge.
Moves all successors from the given node node to this node.
void retdec::llvmir2hll::CFGNode::removeStatementSuccessor | ( | ) |
Removes statement successor if exists.
void retdec::llvmir2hll::CFGNode::removeSucc | ( | std::size_t | i | ) |
Removes a successor of this node on the index i.
Remove means that node will be removed from successors and also back edge from successor to current node will be removed.
i < NUM_NODE_SUCC
, where NUM_NODE_SUCC
is the number of node's successors Sets a new body body to this node.
void retdec::llvmir2hll::CFGNode::setLastBB | ( | llvm::BasicBlock * | bb | ) |
Sets bb as the last LLVM basic block in sequence which is represented by this node.
Sets succ as a new statement successor.
|
private |
A first LLVM basic block in sequence which is represented by this node.
|
private |
A last LLVM basic block in sequence which is represented by this node.
|
private |
A set of node predecessors.
A successor of the high-level statement represented by this node.
|
private |
An ordered vector of node successors.