PandA-2024.02
CallSitesCollectorVisitor.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) 2015-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  */
37 // header for this class
39 
40 #include <utility>
41 
42 #include "Discrepancy.hpp"
43 #include "call_graph_manager.hpp"
44 #include "hls_manager.hpp"
45 #include "string_manipulation.hpp" // for STR
46 
48  : HLSMgr(_HLSMgr), CGMan(_HLSMgr->CGetCallGraphManager())
49 {
50 }
51 
53 
55 {
56  THROW_ASSERT(HLSMgr->RDiscr, "Discrepancy data structure not initialized");
57 }
58 
60 {
61  const unsigned int this_fun_id = CGMan->get_function(v);
62  HLSMgr->RDiscr->call_sites_info->fu_id_to_call_ids[this_fun_id];
63 }
64 
66 {
67  THROW_ERROR("Recursive functions not supported");
68 }
69 
71 {
72  const unsigned int called_id = CGMan->get_function(boost::target(e, g));
73  const unsigned int caller_id = CGMan->get_function(boost::source(e, g));
74  for(const unsigned int callid : g.CGetFunctionEdgeInfo(e)->direct_call_points)
75  {
76  HLSMgr->RDiscr->call_sites_info->fu_id_to_call_ids[caller_id].insert(callid);
77  THROW_ASSERT(HLSMgr->RDiscr->call_sites_info->call_id_to_called_id[callid].empty() or callid == 0,
78  "direct call " + STR(callid) + " calls more than one function");
79  HLSMgr->RDiscr->call_sites_info->call_id_to_called_id[callid].insert(called_id);
80  }
81  for(const unsigned int callid : g.CGetFunctionEdgeInfo(e)->indirect_call_points)
82  {
83  HLSMgr->RDiscr->call_sites_info->fu_id_to_call_ids[caller_id].insert(callid);
84  HLSMgr->RDiscr->call_sites_info->call_id_to_called_id[callid].insert(called_id);
85  HLSMgr->RDiscr->call_sites_info->indirect_calls.insert(callid);
86  }
87  // for(const unsigned int callid : g.CGetFunctionEdgeInfo(e)->function_addresses)
88  // {
89  // HLSMgr->RDiscr->call_sites_info->taken_addresses.insert(callid);
90  // }
91 }
Data structure representing the entire HLS information.
string target
Definition: lenet_tvm.py:16
CallSitesCollectorVisitor(const HLS_managerRef &_HLSMgr)
Constructor.
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
This class is the view of a call graph.
Definition: call_graph.hpp:160
const HLS_managerRef HLSMgr
A refcount to the HLSMgr.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
void back_edge(const EdgeDescriptor &, const CallGraph &)
const CallGraphManagerConstRef CGMan
A refcount to the call graph manager.
void start_vertex(const vertex &, const CallGraph &)
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
void discover_vertex(const vertex &v, const CallGraph &)
Wrapper to call graph.
const FunctionEdgeInfoConstRef CGetFunctionEdgeInfo(const EdgeDescriptor edge) const
Return the info associated with an edge.
Definition: call_graph.hpp:188
~CallSitesCollectorVisitor()
Destructor.
void examine_edge(const EdgeDescriptor &, const CallGraph &)
boost::graph_traits< graph >::edge_descriptor EdgeDescriptor
edge definition.
Definition: graph.hpp:1316
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...
Definition: exceptions.hpp:289

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