73 const DesignFlowManagerConstRef _design_flow_manager,
86 switch(relationship_type)
90 relationships.insert(std::make_pair(BB_FEEDBACK_EDGES_IDENTIFICATION,
SAME_FUNCTION));
91 relationships.insert(std::make_pair(BB_ORDER_COMPUTATION,
SAME_FUNCTION));
104 return relationships;
120 const std::list<LoopConstRef>& loops =
function_behavior->CGetLoops()->GetList();
123 std::list<LoopConstRef>::const_iterator loop, loop_end = loops.end();
124 for(loop = loops.begin(); loop != loop_end; ++loop)
126 if((*loop)->GetId() == 0)
134 (*loop)->get_recursively_bb(loop_bbs);
135 for(
auto cur_bb1 : (*loop)->get_entries())
137 for(
auto cur_bb2 : (*loop)->get_entries())
139 if(cur_bb1 != cur_bb2)
142 for(boost::tie(ie, ie_end) = boost::in_edges(cur_bb1, *fbb); ie != ie_end; ie++)
144 vertex source = boost::source(*ie, *fbb);
145 if(loop_bbs.find(source) == loop_bbs.end())
154 std::list<vertex> vertices;
157 catch(
const char* msg)
159 THROW_UNREACHABLE(
"ecfg graph of function " + function_name +
" is not acyclic");
161 catch(
const std::string& msg)
163 THROW_UNREACHABLE(
"ecfg graph of function " + function_name +
" is not acyclic");
165 catch(
const std::exception& ex)
167 THROW_UNREACHABLE(
"ecfg graph of function " + function_name +
" is not acyclic");
171 THROW_UNREACHABLE(
"ecfg graph of function " + function_name +
" is not acyclic");
190 for(
auto sp_back_edge : (*loop)->get_sp_back_edges())
193 if(fbb->
CGetBBNodeInfo(sp_back_edge.second)->loop_id == (*loop)->GetId())
195 sources.insert(sp_back_edge.first);
197 "---Found source BB" +
198 std::to_string(fbb->
CGetBBNodeInfo(sp_back_edge.first)->block->number) +
199 " (Target is BB" +
STR(fbb->
CGetBBNodeInfo(sp_back_edge.second)->block->number) +
")");
204 LoopConstRef other_loop = *loop;
206 while([&]() ->
bool {
207 for(
const auto landing_pad : landing_pads)
210 "---Analyzing landing pad " +
STR(fbb->
CGetBBNodeInfo(landing_pad)->block->number));
212 for(boost::tie(ie, ie_end) = boost::in_edges(landing_pad, *fbb); ie != ie_end; ie++)
214 const auto source = boost::source(*ie, *fbb);
216 "---Analyzing Edge BB" +
STR(fbb->
CGetBBNodeInfo(source)->block->number) +
"-->BB" +
223 "---Going to landing pad BB" +
225 STR(other_loop->GetId()) +
" is feedback edge. Going up one level");
231 other_loop->get_recursively_bb(bb_loops);
232 if(bb_loops.find(source) != bb_loops.end())
235 "---Going to landing pad BB" +
237 STR(other_loop->GetId()) +
" is feedback edge. Going up one level");
247 other_loop = other_loop->Parent();
248 landing_pads = other_loop->GetLandingPadBlocks();
250 targets.insert(landing_pads.begin(), landing_pads.end());
253 for(s = sources.begin(); s != s_end; ++s)
255 for(t = targets.begin(); t != t_end; ++t)
258 "---Adding edge from BB" + std::to_string(fbb->
CGetBBNodeInfo(*s)->block->number) +
259 " to BB" + std::to_string(fbb->
CGetBBNodeInfo(*t)->block->number));
267 std::list<vertex> vertices;
270 catch(
const char* msg)
272 THROW_UNREACHABLE(
"ecfg graph of function " + function_name +
" is not acyclic");
274 catch(
const std::string& msg)
276 THROW_UNREACHABLE(
"ecfg graph of function " + function_name +
" is not acyclic");
278 catch(
const std::exception& ex)
280 THROW_UNREACHABLE(
"ecfg graph of function " + function_name +
" is not acyclic");
284 THROW_UNREACHABLE(
"ecfg graph of function " + function_name +
" is not acyclic");
293 if(
parameters->getOption<
bool>(OPT_print_dot))
302 std::list<vertex> vertices;
305 catch(
const char* msg)
307 THROW_UNREACHABLE(
"ecfg graph of function " + function_name +
" is not acyclic");
309 catch(
const std::string& msg)
311 THROW_UNREACHABLE(
"ecfg graph of function " + function_name +
" is not acyclic");
313 catch(
const std::exception& ex)
315 THROW_UNREACHABLE(
"ecfg graph of function " + function_name +
" is not acyclic");
319 THROW_UNREACHABLE(
"ecfg graph of function " + function_name +
" is not acyclic");
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.
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
int GetSelector() const
Return the selector of this graph.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
File containing functions and utilities to support the printing of debug messagges.
DesignFlowStep_Status InternalExec() override
Performs the adding of flow edges.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
std::string get_function_name() const
Return the name of the function.
Definition of the class representing a generic C application.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
Class specification of the graph structures.
boost::graph_traits< graph >::in_edge_iterator InEdgeIterator
in_edge_iterator definition.
exceptions managed by PandA
Basic block control flow graph with edges imposing that basic block inside a loop are executed before...
This class provides methods to build a basic blocks graph.
Data structure describing a basic block at tree level.
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
#define FB_CFG_SELECTOR
Feedback control flow edge selector.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
Basic block control flow graph with feedback.
Target must be reexecuted.
redefinition of set to manage ordered/unordered structures
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
#define DEBUG_LEVEL_NONE
no debugging print is performed.
Analysis step which extends basic block cfg.
AddBbEcfgEdges(const application_managerRef AppM, unsigned int function_id, const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters)
Constructor.
void TopologicalSort(std::list< boost::graph_traits< graphs_collection >::vertex_descriptor > &sorted_vertices) const
Compute the topological order of the graph.
Class specification of the basic_block structure.
This file collects some hash functors.
const BBNodeInfoConstRef CGetBBNodeInfo(const vertex node) const
Return the info associated with a basic block.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
~AddBbEcfgEdges() override
Destructor.
interface of loops finding algorithm
this class is used to manage the command-line or XML options.
int debug_level
The debug level.
#define ECFG_SELECTOR
Extended control flow graph selector.
A brief description of the C++ Header File.
const FunctionBehaviorRef function_behavior
The function behavior of the function to be analyzed.