PandA-2024.02
add_op_exit_flow_edges.cpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
45 
47 #include "Parameter.hpp"
48 
50 #include "basic_block.hpp"
51 #include "op_graph.hpp"
53 
55 #include "behavioral_helper.hpp"
56 
57 #include "dbgPrintHelper.hpp" // for DEBUG_LEVEL_
58 #include "hash_helper.hpp"
59 #include "string_manipulation.hpp" // for GET_CLASS
60 
62  unsigned int _function_id, const DesignFlowManagerConstRef _design_flow_manager)
63  : FunctionFrontendFlowStep(_AppM, _function_id, ADD_OP_EXIT_FLOW_EDGES, _design_flow_manager, _parameters)
64 {
65  debug_level = parameters->get_class_debug_level(GET_CLASS(*this), DEBUG_LEVEL_NONE);
66 }
67 
69 
72 {
74  switch(relationship_type)
75  {
77  {
78  relationships.insert(std::make_pair(OPERATIONS_CFG_COMPUTATION, SAME_FUNCTION));
79  relationships.insert(std::make_pair(OP_REACHABILITY_COMPUTATION, SAME_FUNCTION));
80  break;
81  }
84  {
85  break;
86  }
87  default:
88  {
90  }
91  }
92  return relationships;
93 }
94 
96 {
97  if(bb_version != 0 and bb_version != function_behavior->GetBBVersion())
98  {
100  if(boost::num_vertices(*flg) != 0)
101  {
102  EdgeIterator edge, edge_end;
103  for(boost::tie(edge, edge_end) = boost::edges(*flg); edge != edge_end; edge++)
104  {
105  if((GET_TYPE(flg, boost::target(*edge, *flg)) & TYPE_LAST_OP) != 0)
106  {
107  function_behavior->ogc->RemoveSelector(*edge, FLG_SELECTOR);
108  }
109  }
110  }
111  }
112 }
113 
115 {
117  const OpGraphConstRef fcfg = function_behavior->CGetOpGraph(FunctionBehavior::FCFG);
118 
120  const auto basic_block_graph = function_behavior->CGetBBGraph(FunctionBehavior::BB);
121 
123  VertexIterator v, v_end;
124  for(boost::tie(v, v_end) = boost::vertices(*fcfg); v != v_end; ++v)
125  {
126  if((GET_TYPE(fcfg, *v) & TYPE_LAST_OP) != 0)
127  {
128  for(const auto operation : basic_block_graph
129  ->CGetBBNodeInfo(basic_block_graph->CGetBBGraphInfo()
130  ->bb_index_map.find(fcfg->CGetOpNodeInfo(*v)->bb_index)
131  ->second)
132  ->statements_list)
133  {
134  const auto reachability = function_behavior->CheckReachability(operation, *v);
135  if(reachability and ((GET_TYPE(fcfg, operation) & TYPE_LAST_OP) == 0))
136  {
137  function_behavior->ogc->AddEdge(operation, *v, FLG_SELECTOR);
138  }
139  }
140  }
141  }
142  if(parameters->getOption<bool>(OPT_print_dot))
143  {
144  function_behavior->CGetOpGraph(FunctionBehavior::FLG)->WriteDot("OP_FL.dot");
145  function_behavior->CGetOpGraph(FunctionBehavior::FFLSAODG)->WriteDot("OP_FFLSAODG.dot");
146  }
148 }
#define FLG_SELECTOR
Flow edge selector.
Definition: op_graph.hpp:515
#define GET_TYPE(data, vertex_index)
Helper macro returning the type associated with a node.
Basic block control flow graph.
File containing functions and utilities to support the printing of debug messagges.
Analysis step which adds flow edges for scheduling to operation graphs.
string target
Definition: lenet_tvm.py:16
#define GET_CLASS(obj)
Macro returning the actual type of an object.
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.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
DesignFlowStep_Status InternalExec() override
Performs the adding of flow edges to operation graphs.
unsigned int bb_version
The version of the basic block intermediate representation on which this step has been applied...
Auxiliary methods for manipulating string.
boost::graph_traits< graph >::edge_iterator EdgeIterator
edge_iterator definition.
Definition: graph.hpp:1314
const OpNodeInfoConstRef CGetOpNodeInfo(const vertex node) const
Returns the info associated with a node.
Definition: op_graph.hpp:843
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
Definition: exceptions.hpp:292
unsigned edges[4545]
Definition: graph.h:25
AddOpExitFlowEdges(const ParameterConstRef _parameters, const application_managerRef AppM, unsigned int function_id, const DesignFlowManagerConstRef design_flow_manager)
Constructor.
This class specifies the characteristic of a particular operation working on a given functional unit...
boost::graph_traits< graph >::vertex_iterator VertexIterator
vertex_iterator definition.
Definition: graph.hpp:1307
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
~AddOpExitFlowEdges() override
Destructor.
#define DEBUG_LEVEL_NONE
no debugging print is performed.
Class specification of the basic_block structure.
This file collects some hash functors.
Data structures used in operations graph.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
this class is used to manage the command-line or XML options.
Control flow graph with feedback.
void Initialize() override
Initialize the step (i.e., like a constructor, but executed just before exec.
int debug_level
The debug level.
This class provides methods to build an operations graph.
System dependence + anti-dependence + output dependence graph + flow graph with feedback.
const FunctionBehaviorRef function_behavior
The function behavior of the function to be analyzed.
#define TYPE_LAST_OP
A vertex of type LAST_OP if it is the last operation of the application.
Definition: op_graph.hpp:197

Generated on Mon Feb 12 2024 13:02:51 for PandA-2024.02 by doxygen 1.8.13