73 #include <boost/iterator/iterator_facade.hpp> 74 #include <boost/tuple/tuple.hpp> 80 const DesignFlowManagerConstRef _design_flow_manager,
82 :
FrontendFlowStep(_AppM, _frontend_flow_step_type, _design_flow_manager, _parameters),
83 function_behavior(_AppM->GetFunctionBehavior(_function_id)),
84 function_id(_function_id),
101 return "Frontend::" +
STR(frontend_flow_step_type) +
"::" + std::to_string(function_id);
110 const std::string version =
"";
111 const std::string bv_version =
"";
114 version + bv_version;
130 for(
const auto& precedence_relationship : precedence_relationships)
134 const auto signature =
136 const auto symbolic_signature =
147 const auto design_flow_step_info = design_flow_graph->CGetDesignFlowStepInfo(symbolic_step);
148 THROW_UNREACHABLE(
"Symbolic step " + design_flow_step_info->design_flow_step->GetName() +
149 " is not unexecuted");
152 frontend_relationships.insert(precedence_relationship);
158 frontend_relationship_end = frontend_relationships.end();
159 for(frontend_relationship = frontend_relationships.begin(); frontend_relationship != frontend_relationship_end;
160 ++frontend_relationship)
162 switch(frontend_relationship->second)
171 const auto call_graph_manager =
AppM->CGetCallGraphManager();
172 const auto acyclic_call_graph = call_graph_manager->CGetAcyclicCallGraph();
173 const auto function_vertex = call_graph_manager->GetVertex(
function_id);
175 for(boost::tie(oe, oe_end) = boost::out_edges(function_vertex, *acyclic_call_graph); oe != oe_end; oe++)
178 const unsigned int called_function = call_graph_manager->get_function(target);
179 if(
AppM->CGetFunctionBehavior(called_function)->CGetBehavioralHelper()->has_implementation() and
185 if(function_frontend_flow_step)
188 design_flow_graph->CGetDesignFlowStepInfo(function_frontend_flow_step)->design_flow_step;
189 relationships.insert(design_flow_step);
193 design_flow_step = frontend_flow_step_factory->CreateFunctionFrontendFlowStep(
194 frontend_relationship->first, called_function);
195 relationships.insert(design_flow_step);
201 case(CALLING_FUNCTIONS):
203 const auto call_graph_manager =
AppM->CGetCallGraphManager();
204 const auto acyclic_call_graph = call_graph_manager->CGetAcyclicCallGraph();
205 const auto function_vertex = call_graph_manager->GetVertex(
function_id);
207 for(boost::tie(ie, ie_end) = boost::in_edges(function_vertex, *acyclic_call_graph); ie != ie_end; ie++)
209 const vertex source = boost::source(*ie, *acyclic_call_graph);
210 const unsigned int calling_function = call_graph_manager->get_function(source);
216 if(function_frontend_flow_step)
219 design_flow_graph->CGetDesignFlowStepInfo(function_frontend_flow_step)->design_flow_step;
220 relationships.insert(design_flow_step);
224 design_flow_step = frontend_flow_step_factory->CreateFunctionFrontendFlowStep(
225 frontend_relationship->first, calling_function);
226 relationships.insert(design_flow_step);
239 design_flow_step = design_flow_graph->CGetDesignFlowStepInfo(prec_step)->design_flow_step;
240 relationships.insert(design_flow_step);
244 design_flow_step = frontend_flow_step_factory->CreateFunctionFrontendFlowStep(
246 relationships.insert(design_flow_step);
283 const auto funcs = CGMan->GetReachedBodyFunctions();
303 const auto fd = GetPointer<const function_decl>(function_tree_node);
306 for(
const auto&
block : sl->list_of_bloc)
308 inverse_vertex_map[
block.first] =
324 for(
const auto&
block : sl->list_of_bloc)
326 for(
const auto pred :
block.second->list_of_pred)
330 GCC_bb_graphs_collection->AddEdge(inverse_vertex_map[pred], inverse_vertex_map[
block.first],
CFG_SELECTOR);
333 for(
const auto succ :
block.second->list_of_succ)
336 "BB" +
STR(
block.first) +
" does not exist");
337 THROW_ASSERT(inverse_vertex_map.find(succ) != inverse_vertex_map.end(),
"BB" +
STR(succ) +
" does not exist");
338 if(
block.second->CGetStmtList().size() and
339 GET_NODE(
block.second->CGetStmtList().back())->get_kind() == gimple_multi_way_if_K)
341 const auto gmwi = GetPointer<const gimple_multi_way_if>(
GET_NODE(
block.second->CGetStmtList().back()));
343 for(
const auto& gmwi_cond : gmwi->list_of_cond)
345 if(gmwi_cond.second == succ)
349 conds.insert(gmwi_cond.first->index);
357 THROW_ASSERT(conds.size(),
"Inconsistency between cfg and output of gimple_multi_way_if " +
358 gmwi->ToString() +
"- condition for BB" +
STR(succ) +
" not found");
360 for(
auto cond : conds)
362 GetPointer<BBEdgeInfo>(edge_info)->add_nodeID(cond,
CFG_SELECTOR);
364 GCC_bb_graphs_collection->InternalAddEdge(inverse_vertex_map[
block.first], inverse_vertex_map[succ],
369 GCC_bb_graphs_collection->AddEdge(inverse_vertex_map[
block.first], inverse_vertex_map[succ],
CFG_SELECTOR);
372 if(
block.second->list_of_succ.empty())
386 for(
const auto&
block : sl->list_of_bloc)
388 for(
const auto&
phi :
block.second->CGetPhiList())
392 "BB" +
STR(
block.second->number) +
" has " +
STR(
block.second->list_of_pred.size()) +
393 " incoming edges but contains " +
STR(
phi));
411 if(!
parameters->IsParameter(
"print-dot-FF") ||
parameters->GetParameter<
unsigned int>(
"print-dot-FF"))
420 if(!
parameters->IsParameter(
"print-dot-FF") ||
parameters->GetParameter<
unsigned int>(
"print-dot-FF"))
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
boost::graph_traits< graph >::out_edge_iterator OutEdgeIterator
out_edge_iterator definition.
virtual const CustomUnorderedSet< std::pair< FrontendFlowStepType, FunctionRelationship > > ComputeFrontendRelationships(const DesignFlowStep::RelationshipType relationship_type) const =0
Return the set of analyses in relationship with this design step.
void PrintInitialIR() const override
Dump the initial intermediate representation.
File containing functions and utilities to support the printing of debug messagges.
Step successfully executed.
Definition of the node_info object for the basic_block graph.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
Information associated with a basic block edge.
Definition of the class representing a generic C application.
std::string GetName() const override
Return the name of this design step.
Step successfully executed but without any IR change.
void WriteDot(const std::string &file_name, const int detail_level=0) const
Writes this graph in dot format.
RelationshipType
The relationship type.
DesignFlowStepFactoryConstRef CGetDesignFlowStepFactory() const override
Return the factory to create this type of steps.
Class specification of the graph structures.
boost::graph_traits< graph >::in_edge_iterator InEdgeIterator
in_edge_iterator definition.
exceptions managed by PandA
static const unsigned int EXIT_BLOCK_ID
constant identifying the exit basic block
virtual std::string GetKindText() const
Return the name of the type of this frontend flow step.
This class contains the base representation for a generic frontend flow step which works on a single ...
const FrontendFlowStepType frontend_flow_step_type
The type of this step.
Data structure describing a basic block at tree level.
virtual DesignFlowStep_Status InternalExec()=0
Execute the step.
unsigned int bb_version
The version of the basic block intermediate representation on which this step has been applied...
redefinition of map to manage ordered/unordered structures
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
bool HasToBeExecuted() const override
Check if this step has actually to be executed.
void ComputeRelationships(DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override
Compute the relationships of a step with other steps.
std::string GetSignature() const override
Return the signature of this step.
Pure virtual base class for all the design flow step factory.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
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.
Class used to describe a particular graph with basic blocks as nodes.
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
static const std::string ComputeSignature(const FrontendFlowStepType frontend_flow_step_type)
Compute the signature of a symbolic application frontend flow step.
This C++ header file contains common macros for the tree structure.
~FunctionFrontendFlowStep() override
Destructor.
refcount< BBNodeInfo > BBNodeInfoRef
refcount definition of the class
void WriteBBGraphDot(const std::string &filename) const
Write the current version of statement list in dot format.
Information associated with the whole basic-block graph.
#define default_COND
constant used to represent label "default" of a switch construct
Classes to describe design flow graph.
Target must be reexecuted.
redefinition of set to manage ordered/unordered structures
void PrintInitialIR() const override
Dump the initial intermediate representation.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
const Wrefcount< const DesignFlowManager > design_flow_manager
The design flow manager.
unsigned int CGetBBVersion() const
#define GET_CONST_NODE(t)
Classes specification of the tree_node data structures.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
This struct specifies the block node.
enum FrontendFlowStepType { CREATE_TREE_MANAGER, FIND_MAX_TRANSFORMATIONS, FUNCTION_ANALYSIS, SYMBOLIC_APPLICATION_FRONTEND_FLOW_STEP, ADD_BB_ECFG_EDGES, ADD_ARTIFICIAL_CALL_FLOW_EDGES, ADD_OP_EXIT_FLOW_EDGES, ADD_OP_LOOP_FLOW_EDGES, ADD_OP_PHI_FLOW_EDGES, BAMBU_FRONTEND_FLOW, BASIC_BLOCKS_CFG_COMPUTATION, BB_CONTROL_DEPENDENCE_COMPUTATION, BB_FEEDBACK_EDGES_IDENTIFICATION, BB_ORDER_COMPUTATION, BB_REACHABILITY_COMPUTATION, BIT_VALUE, BIT_VALUE_OPT, BITVALUE_RANGE, BIT_VALUE_IPA, BLOCK_FIX, BUILD_VIRTUAL_PHI, CALL_EXPR_FIX, CALL_GRAPH_BUILTIN_CALL, CHECK_SYSTEM_TYPE, COMPLETE_BB_GRAPH, COMPLETE_CALL_GRAPH, COMPUTE_IMPLICIT_CALLS, COMMUTATIVE_EXPR_RESTRUCTURING, COND_EXPR_RESTRUCTURING, CSE_STEP, DATAFLOW_CG_EXT, DEAD_CODE_ELIMINATION, DEAD_CODE_ELIMINATION_IPA, DETERMINE_MEMORY_ACCESSES, DOM_POST_DOM_COMPUTATION, EXTRACT_GIMPLE_COND_OP, EXTRACT_PATTERNS, FIX_STRUCTS_PASSED_BY_VALUE, FUNCTION_CALL_TYPE_CLEANUP, FUNCTION_CALL_OPT, FANOUT_OPT, FIX_VDEF, HDL_FUNCTION_DECL_FIX, HDL_VAR_DECL_FIX, HLS_DIV_CG_EXT, HWCALL_INJECTION, INTERFACE_INFER, IR_LOWERING, LOOP_COMPUTATION, LOOPS_ANALYSIS_BAMBU, LOOPS_COMPUTATION, LUT_TRANSFORMATION, MULTI_WAY_IF, MULTIPLE_ENTRY_IF_REDUCTION, NI_SSA_LIVENESS, OP_CONTROL_DEPENDENCE_COMPUTATION, OP_FEEDBACK_EDGES_IDENTIFICATION, OP_ORDER_COMPUTATION, OP_REACHABILITY_COMPUTATION, OPERATIONS_CFG_COMPUTATION, PARM2SSA, PARM_DECL_TAKEN_ADDRESS, PHI_OPT, PREDICATE_STATEMENTS, ESSA, RANGE_ANALYSIS, REBUILD_INITIALIZATION, REBUILD_INITIALIZATION2, REMOVE_CLOBBER_GA, REMOVE_ENDING_IF, SCALAR_SSA_DATA_FLOW_ANALYSIS, SERIALIZE_MUTUAL_EXCLUSIONS, SPLIT_RETURN, SHORT_CIRCUIT_TAF, SIMPLE_CODE_MOTION, SOFT_FLOAT_CG_EXT, STRING_CST_FIX, SWITCH_FIX, UN_COMPARISON_LOWERING, UNROLLING_DEGREE, USE_COUNTING, VAR_ANALYSIS, VAR_DECL_FIX, VECTORIZE, VERIFICATION_OPERATION, VIRTUAL_AGGREGATE_DATA_FLOW_ANALYSIS, VIRTUAL_PHI_NODES_SPLIT } FrontendFlowStepType
unsigned int GetBitValueVersion() const
Base class description of data information associated with each edge of a graph.
Data structures used to represent an edge in operation and basic block graphs.
refcount< T > lock() const
void ComputeRelationships(DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override
Compute the relationships of a step with other steps.
const unsigned int function_id
The index of the function to be analyzed.
const application_managerRef AppM
The application manager.
Class specification of the tree_reindex support class.
static const unsigned int ENTRY_BLOCK_ID
constant identifying the entry basic block
Class specification of the basic_block structure.
This file collects some hash functors.
This class contains the methods to create a frontend flow step.
DesignFlowStep_Status Exec() final
Execute the step.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Classes specification of the tree_node data structures not present in the gcc.
this class is used to manage the command-line or XML options.
unsigned int bitvalue_version
The version of the bitvalue information on which this step has been applied.
int debug_level
The debug level.
void PrintFinalIR() const override
Dump the final intermediate representation.
void PrintFinalIR() const override
Dump the final intermediate representation.
bool HasToBeExecuted0() const
Check if this function is reachable from the top functions.
#define CFG_SELECTOR
Control flow graph edge selector.
refcount< BBGraphInfo > BBGraphInfoRef
refcount definition of the class
This class models the application of a analysis to all the functions of an application.
Class specification of the manager of the tree structures extracted from the raw file.
A brief description of the C++ Header File.
const FunctionBehaviorRef function_behavior
The function behavior of the function to be analyzed.
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.
This structure defines graphs where nodes are basic_blocks.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...