PandA-2024.02
|
Compute the control flow graph for the operations. More...
#include <operations_cfg_computation.hpp>
Public Member Functions | |
operations_cfg_computation (const ParameterConstRef _parameters, const application_managerRef AppM, unsigned int function_id, const DesignFlowManagerConstRef design_flow_manager) | |
Constructor. More... | |
~operations_cfg_computation () override | |
Destructor. More... | |
DesignFlowStep_Status | InternalExec () override |
Computes the operations CFG graph data structure. More... | |
void | Initialize () override |
Initialize the step (i.e., like a constructor, but executed just before exec. More... | |
Public Member Functions inherited from FunctionFrontendFlowStep | |
FunctionFrontendFlowStep (const application_managerRef AppM, const unsigned int function_id, const FrontendFlowStepType frontend_flow_step_type, const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters) | |
Constructor. More... | |
~FunctionFrontendFlowStep () override | |
Destructor. More... | |
void | ComputeRelationships (DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override |
Compute the relationships of a step with other steps. More... | |
std::string | GetSignature () const override |
Return the signature of this step. More... | |
std::string | GetName () const override |
Return the name of this design step. More... | |
DesignFlowStep_Status | Exec () final |
Execute the step. More... | |
bool | HasToBeExecuted () const override |
Check if this step has actually to be executed. More... | |
unsigned int | CGetBBVersion () const |
unsigned int | GetBitValueVersion () const |
void | PrintInitialIR () const override |
Dump the initial intermediate representation. More... | |
void | PrintFinalIR () const override |
Dump the final intermediate representation. More... | |
Public Member Functions inherited from FrontendFlowStep | |
FrontendFlowStep (const application_managerRef AppM, const FrontendFlowStepType frontend_flow_step_type, const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters) | |
Constructor. More... | |
~FrontendFlowStep () override | |
Destructor. More... | |
virtual std::string | GetKindText () const |
Return the name of the type of this frontend flow step. More... | |
DesignFlowStepFactoryConstRef | CGetDesignFlowStepFactory () const override |
Return the factory to create this type of steps. More... | |
void | PrintTreeManager (const bool before) const |
Dump the tree manager. More... | |
Public Member Functions inherited from DesignFlowStep | |
DesignFlowStep (const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters) | |
Constructor. More... | |
virtual | ~DesignFlowStep () |
Destructor. More... | |
DesignFlowStep_Status | GetStatus () const |
Return the status of this design step. More... | |
virtual void | WriteDot (std::ostream &out) const |
Write the label for a dot graph. More... | |
bool | IsComposed () const |
Returns if this step is composed. More... | |
int | CGetDebugLevel () const |
Return the debug level of the step. More... | |
Private Member Functions | |
std::string | get_first_node (const tree_nodeRef &tn, const std::string &f_name) const |
Return the name of the first node given a tree node. More... | |
void | clean_start_nodes () |
Clean the list of start nodes. More... | |
void | insert_start_node (const std::string &start_node) |
Insert a start node to the list of start nodes. More... | |
bool | empty_start_nodes () const |
Return true if start_node is empty. More... | |
void | init_start_nodes (const std::string &start_node) |
Initialize the list of start nodes. More... | |
void | connect_start_nodes (const operations_graph_constructorRef ogc, const std::string &next, bool true_edge=false, bool false_edge=false, unsigned int nodeid=0) |
Connect start_node with the next node. More... | |
void | build_operation_recursive (const tree_managerRef TM, const operations_graph_constructorRef ogc, const tree_nodeRef tn, const std::string &f_name, unsigned int bb_index) |
Builds recursively the operation for a given tree node. More... | |
const CustomUnorderedSet< std::pair< FrontendFlowStepType, FunctionRelationship > > | ComputeFrontendRelationships (const DesignFlowStep::RelationshipType relationship_type) const override |
Return the set of analyses in relationship with this design step. More... | |
Private Attributes | |
std::map< unsigned int, std::string > | label_decl_map |
relation between label declaration and first statement id More... | |
std::map< unsigned int, std::string > | first_statement |
relation between basic block and first statement id More... | |
std::list< std::string > | start_nodes |
store the name of the nodes at which the next node should be attached. More... | |
std::string | actual_name |
store the name of the current vertex More... | |
Additional Inherited Members | |
Public Types inherited from FrontendFlowStep | |
using | FunctionRelationship = enum { ALL_FUNCTIONS, CALLED_FUNCTIONS, CALLING_FUNCTIONS, SAME_FUNCTION, WHOLE_APPLICATION } |
The different relationship type between function analysis. More... | |
Public Types inherited from DesignFlowStep | |
enum | RelationshipType { DEPENDENCE_RELATIONSHIP, INVALIDATION_RELATIONSHIP, PRECEDENCE_RELATIONSHIP } |
The relationship type. More... | |
Static Public Member Functions inherited from FunctionFrontendFlowStep | |
static const std::string | ComputeSignature (const FrontendFlowStepType frontend_flow_step_type, const unsigned int function_id) |
Compute the signature of a function frontend flow step. More... | |
Static Public Member Functions inherited from FrontendFlowStep | |
static void | CreateSteps (const DesignFlowManagerConstRef design_flow_manager, const CustomUnorderedSet< std::pair< FrontendFlowStepType, FunctionRelationship >> &frontend_relationships, const application_managerConstRef application_manager, DesignFlowStepSet &relationships) |
Create the relationship steps of a step with other steps starting from already specified dependencies between frontend flow steps. More... | |
static const std::string | EnumToKindText (const FrontendFlowStepType frontend_flow_step_type) |
Given a frontend flow step type, return the name of the type. More... | |
Protected Member Functions inherited from FunctionFrontendFlowStep | |
void | WriteBBGraphDot (const std::string &filename) const |
Write the current version of statement list in dot format. More... | |
Protected Attributes inherited from FunctionFrontendFlowStep | |
const FunctionBehaviorRef | function_behavior |
The function behavior of the function to be analyzed. More... | |
const unsigned int | function_id |
The index of the function to be analyzed. More... | |
unsigned int | bb_version |
The version of the basic block intermediate representation on which this step has been applied. More... | |
unsigned int | bitvalue_version |
The version of the bitvalue information on which this step has been applied. More... | |
Protected Attributes inherited from FrontendFlowStep | |
const application_managerRef | AppM |
The application manager. More... | |
const FrontendFlowStepType | frontend_flow_step_type |
The type of this step. More... | |
unsigned int | print_counter |
Print counter. More... | |
Protected Attributes inherited from DesignFlowStep | |
bool | composed |
True if this step represents a composition of design flow steps (e.g., a flow); must be set by specialized constructors. More... | |
const Wrefcount< const DesignFlowManager > | design_flow_manager |
The design flow manager. More... | |
const ParameterConstRef | parameters |
Set of input parameters. More... | |
int | debug_level |
The debug level. More... | |
const int | output_level |
The output level. More... | |
Compute the control flow graph for the operations.
Definition at line 65 of file operations_cfg_computation.hpp.
operations_cfg_computation::operations_cfg_computation | ( | const ParameterConstRef | _parameters, |
const application_managerRef | AppM, | ||
unsigned int | function_id, | ||
const DesignFlowManagerConstRef | design_flow_manager | ||
) |
Constructor.
Param | is the set of the parameters |
AppM | is the application manager |
function_id | is the identifier of the function |
Definition at line 67 of file operations_cfg_computation.cpp.
References DesignFlowStep::debug_level, DEBUG_LEVEL_NONE, GET_CLASS, DesignFlowStep::parameters, and ~operations_cfg_computation().
|
overridedefault |
|
private |
Builds recursively the operation for a given tree node.
We assume a one to one mapping between nodeids and vertices
TM | is the tree manager. |
ogc | is the operation graph constructor used to add the vertices. |
tn | is the reference of the tree node we are currently analyzing |
f_name | is the name of the function which the node we are analyzing belongs to |
Definition at line 495 of file operations_cfg_computation.cpp.
References actual_name, ASSIGN, CASE_BINARY_EXPRESSION, CASE_CPP_NODES, CASE_DECL_NODES, CASE_FAKE_NODES, CASE_PRAGMA_NODES, CASE_QUATERNARY_EXPRESSION, CASE_TERNARY_EXPRESSION, CASE_TYPE_NODES, CASE_UNARY_EXPRESSION, tree_helper::CGetType(), connect_start_nodes(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, default_COND, tree_helper::find_obj_type_ref_function(), FIX_TRUNC_EXPR, FLOAT_EXPR, FunctionFrontendFlowStep::function_behavior, GET_CONST_NODE, get_first_node(), GET_INDEX_CONST_NODE, GET_INDEX_NODE, tree_node::get_kind(), GET_NODE, tree_node::GetString(), INDENT_DBG_MEX, tree_helper::is_a_nop_function_decl(), tree_helper::IsArrayEquivType(), tree_helper::IsLoad(), tree_helper::IsPointerType(), tree_helper::IsStore(), tree_helper::IsUnsignedIntegerType(), tree_helper::IsVectorType(), MEMCPY, MEMSET, MULTI_READ_COND, NODE_NOT_YET_SUPPORTED_EC, NOP, tree_helper::NormalizeTypename(), phi, PRINT_DBG_MEX, tree_helper::print_function_name(), READ_COND, tree_helper::Size(), STR, SWITCH_COND, THROW_ASSERT, THROW_ERROR, THROW_ERROR_CODE, THROW_UNREACHABLE, TYPE_ASSIGN, TYPE_ATOMIC, TYPE_EXTERNAL, TYPE_FOR, TYPE_GENERIC, TYPE_GOTO, TYPE_IF, TYPE_INIT, TYPE_LABEL, TYPE_LAST_OP, TYPE_LOAD, TYPE_MEMCPY, TYPE_MULTIIF, TYPE_NOP, TYPE_OPAQUE, TYPE_PHI, TYPE_PREDICATED, TYPE_RET, TYPE_RW, TYPE_STORE, TYPE_SWITCH, TYPE_VPHI, TYPE_WHILE, and VECT_CONCATENATION.
Referenced by InternalExec().
|
private |
Clean the list of start nodes.
Definition at line 450 of file operations_cfg_computation.cpp.
References start_nodes.
Referenced by InternalExec().
|
overrideprivatevirtual |
Return the set of analyses in relationship with this design step.
relationship_type | is the type of relationship to be considered |
Implements FrontendFlowStep.
Definition at line 78 of file operations_cfg_computation.cpp.
References DesignFlowStep::DEPENDENCE_RELATIONSHIP, DesignFlowStep::INVALIDATION_RELATIONSHIP, DesignFlowStep::parameters, DesignFlowStep::PRECEDENCE_RELATIONSHIP, SAME_FUNCTION, and THROW_UNREACHABLE.
|
private |
Connect start_node with the next node.
ogc | is the operation graph constructor used to add the edges. |
next | is the ending node of the edge that must be added to g. |
true_edge | when it is true the control edge is the true branch of an if then else statement. |
false_edge | when it is true the control edge is the false branch of an if then else statement. |
nodeid | is meaningful only in case true_edge and false_edge are both true and the control edge is associated with a switch statement. |
Mark first operation of the application
Definition at line 466 of file operations_cfg_computation.cpp.
References FrontendFlowStep::AppM, CFG_SELECTOR, DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, ENTRY, F_COND, FunctionFrontendFlowStep::function_id, INDENT_DBG_MEX, start_nodes, STR, T_COND, and TYPE_FIRST_OP.
Referenced by build_operation_recursive(), and InternalExec().
|
private |
Return true if start_node is empty.
Definition at line 455 of file operations_cfg_computation.cpp.
References start_nodes.
Referenced by InternalExec().
|
private |
Return the name of the first node given a tree node.
tn | is the tree node. |
f_name | is the name of the function of the node we are analyzing |
Definition at line 387 of file operations_cfg_computation.cpp.
References CASE_BINARY_EXPRESSION, CASE_CPP_NODES, CASE_CST_NODES, CASE_DECL_NODES, CASE_FAKE_NODES, CASE_GIMPLE_NODES, CASE_PRAGMA_NODES, CASE_QUATERNARY_EXPRESSION, CASE_TERNARY_EXPRESSION, CASE_TYPE_NODES, CASE_UNARY_EXPRESSION, GET_INDEX_NODE, tree_node::get_kind(), tree_node::get_kind_text(), GET_NODE, label_decl_map, NODE_NOT_YET_SUPPORTED_EC, STR, THROW_ASSERT, and THROW_ERROR_CODE.
Referenced by build_operation_recursive(), and InternalExec().
|
private |
Initialize the list of start nodes.
start_node | is the starting node |
Definition at line 460 of file operations_cfg_computation.cpp.
References start_nodes.
Referenced by InternalExec().
|
overridevirtual |
Initialize the step (i.e., like a constructor, but executed just before exec.
Reimplemented from DesignFlowStep.
Definition at line 117 of file operations_cfg_computation.cpp.
References FunctionBehavior::BB, FunctionFrontendFlowStep::bb_version, FunctionFrontendFlowStep::function_behavior, and BBGraph::GetBBNodeInfo().
|
private |
Insert a start node to the list of start nodes.
start_node | is the starting node |
Definition at line 445 of file operations_cfg_computation.cpp.
References start_nodes.
|
overridevirtual |
Computes the operations CFG graph data structure.
entry and exit computation
first cycle to compute the label_decl_map and the first_statement maps.
second cycle doing the real job
Implements FunctionFrontendFlowStep.
Definition at line 135 of file operations_cfg_computation.cpp.
References actual_name, FrontendFlowStep::AppM, BB_ENTRY, BB_EXIT, build_operation_recursive(), BUILTIN_SRCP, FunctionBehavior::CFG, BBGraph::CGetBBGraphInfo(), BBGraph::CGetBBNodeInfo(), clean_start_nodes(), connect_start_nodes(), tree_manager::create_tree_node(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, empty_start_nodes(), ENTRY, EXIT, bloc::EXIT_BLOCK_ID, FunctionBehavior::FBB, first_statement, FunctionFrontendFlowStep::function_behavior, FunctionFrontendFlowStep::function_id, get_first_node(), BehavioralHelper::get_function_name(), GET_INDEX_NODE, GET_NODE, tree_manager::get_tree_node_const(), tree_manager::GetTreeNode(), tree_manager::GetTreeReindex(), INDENT_DBG_MEX, init_start_nodes(), label_decl_map, tree_manager::new_tree_node_id(), DesignFlowStep::parameters, phi, start_nodes, STR, SUCCESS, THROW_ASSERT, THROW_UNREACHABLE, TOK, TOK_SCPE, TOK_SRCP, tree_node::ToString(), TYPE_ENTRY, TYPE_EXIT, and TYPE_LAST_OP.
|
private |
store the name of the current vertex
Definition at line 78 of file operations_cfg_computation.hpp.
Referenced by build_operation_recursive(), and InternalExec().
|
private |
relation between basic block and first statement id
Definition at line 72 of file operations_cfg_computation.hpp.
Referenced by InternalExec().
|
private |
relation between label declaration and first statement id
Definition at line 69 of file operations_cfg_computation.hpp.
Referenced by get_first_node(), and InternalExec().
|
private |
store the name of the nodes at which the next node should be attached.
Definition at line 75 of file operations_cfg_computation.hpp.
Referenced by clean_start_nodes(), connect_start_nodes(), empty_start_nodes(), init_start_nodes(), insert_start_node(), and InternalExec().