PandA-2024.02
function_behavior.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 #include "function_behavior.hpp"
46 
47 #include "config_HAVE_HOST_PROFILING_BUILT.hpp"
48 
49 #include "Dominance.hpp" // for dominance
50 #include "Parameter.hpp" // for ParameterConstRef
51 #include "application_manager.hpp" // for application_manager
52 #include "basic_block.hpp" // for BBGraph, BBGraphInfo
53 #include "basic_blocks_graph_constructor.hpp" // for BBGraphRef, BasicBl...
54 #include "behavioral_helper.hpp" // for BehavioralHelper
55 #include "cdfg_edge_info.hpp" // for CFG_SELECTOR, CDG_S...
56 #include "custom_set.hpp" // for CustomSet
57 #include "exceptions.hpp" // for THROW_ASSERT, THROW...
58 #include "graph.hpp" // for vertex, VertexIterator
59 #include "level_constructor.hpp" // for level_constructor
60 #include "loop.hpp" // for LoopsRef
61 #include "loops.hpp" // for ProfilingInformatio...
62 #include "op_graph.hpp" // for OpGraph, OpGraphCon...
63 #include "operations_graph_constructor.hpp" // for OpGraphRef, operati...
64 #include "tree_helper.hpp"
65 #include "tree_manager.hpp" // for pipeline_enabled
66 #include "tree_node.hpp" // for pipeline_enabled
67 #include "utility.hpp"
68 #if HAVE_HOST_PROFILING_BUILT
69 #include "profiling_information.hpp" // for BBGraphConstRef
70 #endif
71 #include "typed_node_info.hpp" // for GET_NAME
72 
73 #include <boost/graph/adjacency_list.hpp> // for adjacency_list
74 #include <boost/graph/filtered_graph.hpp> // for filtered_graph<>::v...
75 #include <boost/iterator/filter_iterator.hpp> // for filter_iterator
76 #include <boost/iterator/iterator_facade.hpp> // for operator!=, operator++
77 #include <boost/tuple/tuple.hpp> // for tie
78 #include <list> // for list, _List_const_i...
79 #include <ostream> // for operator<<, basic_o...
80 #include <string> // for operator+, char_traits
81 #include <utility> // for pair
82 
83 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
84 #pragma GCC diagnostic push
85 #pragma GCC diagnostic error "-Weffc++"
86 #endif
87 memory_access::memory_access(unsigned int _node_id, unsigned int _base_address, unsigned int _offset)
88  : node_id(_node_id), base_address(_base_address), offset(_offset)
89 {
90 }
91 
93  const ParameterConstRef _parameters)
94  : helper(_helper),
95  bb_graphs_collection(
96  new BBGraphsCollection(BBGraphInfoRef(new BBGraphInfo(_AppM, _helper->get_function_index())), _parameters)),
97  op_graphs_collection(new OpGraphsCollection(OpGraphInfoRef(new OpGraphInfo(helper)), _parameters)),
98  bb(new BBGraph(bb_graphs_collection, CFG_SELECTOR)),
99  extended_bb(new BBGraph(bb_graphs_collection, CFG_SELECTOR | ECFG_SELECTOR)),
100  cdg_bb(new BBGraph(bb_graphs_collection, CDG_SELECTOR)),
101  dj(new BBGraph(bb_graphs_collection, D_SELECTOR | J_SELECTOR)),
102  dt(new BBGraph(bb_graphs_collection, D_SELECTOR)),
103  fbb(new BBGraph(bb_graphs_collection, FCFG_SELECTOR)),
104  pdt(new BBGraph(bb_graphs_collection, PD_SELECTOR)),
105  ppg(new BBGraph(bb_graphs_collection, PP_SELECTOR | CFG_SELECTOR)),
106  cfg(new OpGraph(op_graphs_collection, CFG_SELECTOR)),
107  extended_cfg(new OpGraph(op_graphs_collection, CFG_SELECTOR | ECFG_SELECTOR)),
108  fcfg(new OpGraph(op_graphs_collection, FCFG_SELECTOR)),
109  adg(new OpGraph(op_graphs_collection, ADG_SELECTOR)),
110  fadg(new OpGraph(op_graphs_collection, FADG_SELECTOR)),
111  cdg(new OpGraph(op_graphs_collection, CDG_SELECTOR)),
112  fcdg(new OpGraph(op_graphs_collection, FCDG_SELECTOR)),
113  dfg(new OpGraph(op_graphs_collection, DFG_SELECTOR)),
114  fdfg(new OpGraph(op_graphs_collection, FDFG_SELECTOR)),
115  flg(new OpGraph(op_graphs_collection, FLG_SELECTOR)),
116  odg(new OpGraph(op_graphs_collection, ODG_SELECTOR)),
117  fodg(new OpGraph(op_graphs_collection, FODG_SELECTOR)),
118  flaoddg(new OpGraph(op_graphs_collection, FLG_SELECTOR | ADG_SELECTOR | ODG_SELECTOR | DFG_SELECTOR)),
119  fflaoddg(new OpGraph(op_graphs_collection, FLG_SELECTOR | FADG_SELECTOR | FODG_SELECTOR | FDFG_SELECTOR)),
120  flsaodg(new OpGraph(op_graphs_collection, FLG_SELECTOR | SDG_SELECTOR | ADG_SELECTOR | ODG_SELECTOR)),
121 #ifndef NDEBUG
122  flsaoddg(new OpGraph(op_graphs_collection,
124 #endif
125  fflsaodg(new OpGraph(op_graphs_collection, FLG_SELECTOR | FSDG_SELECTOR | FADG_SELECTOR | FODG_SELECTOR)),
126  saodg(new OpGraph(op_graphs_collection, SDG_SELECTOR | ADG_SELECTOR | ODG_SELECTOR)),
127  fsaodg(new OpGraph(op_graphs_collection, FSDG_SELECTOR | FADG_SELECTOR | FODG_SELECTOR)),
128  sdg(new OpGraph(op_graphs_collection, SDG_SELECTOR)),
129  fsdg(new OpGraph(op_graphs_collection, FSDG_SELECTOR)),
130  sg(new OpGraph(op_graphs_collection, SG_SELECTOR | FLG_SELECTOR)),
131  agg_virtualg(new OpGraph(op_graphs_collection, DFG_AGG_SELECTOR | ADG_AGG_SELECTOR)),
132 #if HAVE_HOST_PROFILING_BUILT
133  profiling_information(ProfilingInformationRef(new ProfilingInformation(bb))),
134 #endif
135  map_levels(),
136  bb_map_levels(),
137  deque_levels(),
138  bb_deque_levels(),
139  loops(),
140  mem_nodeID(),
141  dynamic_address(),
142  parm_decl_copied(),
143  parm_decl_loaded(),
144  parm_decl_stored(),
145  parameters(_parameters),
146  dereference_unknown_address(false),
147  unaligned_accesses(false),
148  bb_version(1),
149  bitvalue_version(1),
150  has_globals(false),
151  has_undefined_function_receiveing_pointers(false),
152  state_variables(),
153  pipeline_enabled(false),
154  simple_pipeline(false),
155  initiation_time(1),
156  _channels_number(
157  _parameters->isOption(OPT_channels_number) ? _parameters->getOption<unsigned int>(OPT_channels_number) : 0),
158  _channels_type(_parameters->getOption<MemoryAllocation_ChannelsType>(OPT_channels_type)),
159  _allocation_policy(_parameters->getOption<MemoryAllocation_Policy>(OPT_memory_allocation_policy)),
160  bb_reachability(),
161  feedback_bb_reachability(),
162  ogc(new operations_graph_constructor(op_graphs_collection)),
163  bbgc(new BasicBlocksGraphConstructor(bb_graphs_collection)),
164  lm(new level_constructor(map_levels, deque_levels)),
165  bb_lm(new level_constructor(bb_map_levels, bb_deque_levels)),
166  dominators(nullptr),
167  post_dominators(nullptr),
168  memory_info(),
169  packed_vars(false)
170 {
171  THROW_ASSERT(_AppM->get_tree_manager()->GetTreeNode(_helper->get_function_index())->get_kind() == function_decl_K,
172  "Called function_behavior on a node which is not a function_decl");
173  auto* decl_node = GetPointer<function_decl>(_AppM->get_tree_manager()->GetTreeNode(_helper->get_function_index()));
174  const auto fname = tree_helper::GetMangledFunctionName(decl_node);
175  if(!_parameters->isOption(OPT_pipelining))
176  {
177  pipeline_enabled = decl_node->is_pipelined();
178  simple_pipeline = decl_node->is_simple_pipeline();
179  initiation_time = decl_node->get_initiation_time();
181  {
182  INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, _parameters->getOption<int>(OPT_output_level),
183  "Required pipelining with II=1 for function: " + fname);
184  }
185  else if(pipeline_enabled)
186  {
187  INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, _parameters->getOption<int>(OPT_output_level),
188  "Required pipelining with II=" + STR(initiation_time) + " for function: " + fname);
189  }
190  }
191  else
192  {
193  auto tmp_string = _parameters->getOption<std::string>(OPT_pipelining);
194  if(tmp_string == "no-@ll")
195  {
196  // force no pipelining
197  }
198  else if(tmp_string == "@ll")
199  {
200  pipeline_enabled = true;
201  simple_pipeline = true;
202  INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, _parameters->getOption<int>(OPT_output_level),
203  "Required pipelining with II=1 for function: " + fname);
204  }
205  else
206  {
207  const auto funcs_values = string_to_container<std::vector<std::string>>(tmp_string, ",");
208  for(auto fun_pipeline : funcs_values)
209  {
210  if(!fun_pipeline.empty() && fun_pipeline.at(0) == '=')
211  {
212  fun_pipeline = fun_pipeline.substr(1);
213  }
214  const auto splitted = SplitString(fun_pipeline, "=");
215  if(!splitted.empty() &&
216  (fname == splitted.at(0) || (fname.find("__float") == 0 && fname.find(splitted.at(0)) == 0)))
217  {
218  if(splitted.size() == 1)
219  {
220  pipeline_enabled = true;
221  simple_pipeline = true;
222  INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, _parameters->getOption<int>(OPT_output_level),
223  "Required pipelining with II=1 for function: " + fname);
224  }
225  else if(splitted.size() == 2)
226  {
227  pipeline_enabled = true;
228  initiation_time = std::stoi(splitted.at(1));
229  if(initiation_time == 1)
230  {
231  simple_pipeline = true;
232  }
233  INDENT_OUT_MEX(OUTPUT_LEVEL_MINIMUM, _parameters->getOption<int>(OPT_output_level),
234  "Required pipelining with II=" + STR(initiation_time) + " for function: " + fname);
235  }
236  }
237  }
238  }
239  }
240 }
241 
243 {
244  if(dominators)
245  {
246  delete dominators;
247  }
248  if(post_dominators)
249  {
250  delete post_dominators;
251  }
252 }
253 
255 {
256  switch(gt)
257  {
258  case CFG:
259  return cfg;
260  case ECFG:
261  return extended_cfg;
262  case FCFG:
263  return fcfg;
264  case CDG:
265  return cdg;
266  case FCDG:
267  return fcdg;
268  case DFG:
269  return dfg;
270  case FDFG:
271  return fdfg;
272  case ADG:
273  return adg;
274  case FADG:
275  return fadg;
276  case ODG:
277  return odg;
278  case FODG:
279  return fodg;
280  case SDG:
281  return sdg;
282  case FSDG:
283  return fsdg;
284  case SAODG:
285  return saodg;
286  case FSAODG:
287  return fsaodg;
288  case FLSAODG:
289  return flsaodg;
290 #ifndef NDEBUG
291  case FLSAODDG:
292  return flsaoddg;
293 #endif
294  case FFLSAODG:
295  return fflsaodg;
296  case FLAODDG:
297  return flaoddg;
298  case FFLAODDG:
299  return fflaoddg;
300  case FLG:
301  return flg;
302  case SG:
303  return sg;
304  case AGG_VIRTUALG:
305  return agg_virtualg;
306  default:
307  THROW_UNREACHABLE("Not supported graph type");
308  }
309  return OpGraphRef();
310 }
311 
313 {
314  switch(gt)
315  {
316  case CFG:
317  return cfg;
318  case ECFG:
319  return extended_cfg;
320  case FCFG:
321  return fcfg;
322  case CDG:
323  return cdg;
324  case FCDG:
325  return fcdg;
326  case DFG:
327  return dfg;
328  case FDFG:
329  return fdfg;
330  case ADG:
331  return adg;
332  case FADG:
333  return fadg;
334  case ODG:
335  return odg;
336  case FODG:
337  return fodg;
338  case SDG:
339  return sdg;
340  case FSDG:
341  return fsdg;
342  case SAODG:
343  return saodg;
344  case FSAODG:
345  return fsaodg;
346  case FLSAODG:
347  return flsaodg;
348 #ifndef NDEBUG
349  case FLSAODDG:
350  return flsaoddg;
351 #endif
352  case FFLSAODG:
353  return fflsaodg;
354  case FLAODDG:
355  return flaoddg;
356  case FFLAODDG:
357  return fflaoddg;
358  case FLG:
359  return flg;
360  case SG:
361  return sg;
362  case AGG_VIRTUALG:
363  return agg_virtualg;
364  default:
365  THROW_UNREACHABLE("Not supported graph type");
366  }
367  return OpGraphConstRef();
368 }
369 
371 {
372  return helper;
373 }
374 
376 {
377  return helper;
378 }
379 
382  const OpVertexSet& statements) const
383 {
386  subset.insert(statements.begin(), statements.end());
387  switch(gt)
388  {
389  case CFG:
390  return OpGraphRef(new OpGraph(op_graphs_collection, CFG_SELECTOR, subset));
391 
392  case FCFG:
394 
395  case ECFG:
397 
398  case CDG:
399  return OpGraphRef(new OpGraph(op_graphs_collection, CDG_SELECTOR, subset));
400 
401  case FCDG:
403 
404  case DFG:
405  return OpGraphRef(new OpGraph(op_graphs_collection, DFG_SELECTOR, subset));
406 
407  case FDFG:
409 
410  case ADG:
411  return OpGraphRef(new OpGraph(op_graphs_collection, ADG_SELECTOR, subset));
412 
413  case FADG:
415 
416  case ODG:
417  return OpGraphRef(new OpGraph(op_graphs_collection, ODG_SELECTOR, subset));
418 
419  case FODG:
421 
422  case SDG:
423  return OpGraphRef(new OpGraph(op_graphs_collection, SDG_SELECTOR, subset));
424 
425  case FSDG:
427 
428  case SAODG:
430 
431  case FSAODG:
432  return OpGraphRef(
434 
435  case FLSAODG:
437 
438 #ifndef NDEBUG
439  case FLSAODDG:
441 #endif
442 
443  case FFLSAODG:
444  return OpGraphRef(
446 
447  case FLAODDG:
448  return OpGraphRef(
450 
451  case FFLAODDG:
452  return OpGraphRef(
454 
455  case FLG:
456  return OpGraphRef(new OpGraph(op_graphs_collection, FLG_SELECTOR, subset));
457 
458  case SG:
459  return OpGraphRef(new OpGraph(op_graphs_collection, SG_SELECTOR, subset));
460 
461  case AGG_VIRTUALG:
463  default:
464  THROW_UNREACHABLE("");
465  }
466  return OpGraphConstRef();
467 }
468 
470 {
471  switch(gt)
472  {
473  case BB:
474  return bb;
475  case FBB:
476  return fbb;
477  case EBB:
478  return extended_bb;
479  case CDG_BB:
480  return cdg_bb;
481  case DOM_TREE:
482  return dt;
483  case POST_DOM_TREE:
484  return pdt;
485  case PPG:
486  return ppg;
487  case DJ:
488  return dj;
489  default:
490  THROW_UNREACHABLE("");
491  }
492  return BBGraphRef();
493 }
494 
496 {
497  switch(gt)
498  {
499  case BB:
500  return bb;
501  case FBB:
502  return fbb;
503  case EBB:
504  return extended_bb;
505  case CDG_BB:
506  return cdg_bb;
507  case DOM_TREE:
508  return dt;
509  case POST_DOM_TREE:
510  return pdt;
511  case PPG:
512  return ppg;
513  case DJ:
514  return dj;
515  default:
516  THROW_UNREACHABLE("");
517  }
518  return BBGraphRef();
519 }
520 
521 void FunctionBehavior::print(std::ostream& os) const
522 {
523  os << "Function " << helper->get_function_name();
524  // os << "Bulk operation graph of " << og;
525  // os << ", , ";
526 }
527 
528 const std::deque<vertex>& FunctionBehavior::get_levels() const
529 {
530  return deque_levels;
531 }
532 
533 const std::deque<vertex>& FunctionBehavior::get_bb_levels() const
534 {
535  return bb_deque_levels;
536 }
537 
538 const std::map<vertex, unsigned int>& FunctionBehavior::get_map_levels() const
539 {
540  return map_levels;
541 }
542 
543 const std::map<vertex, unsigned int>& FunctionBehavior::get_bb_map_levels() const
544 {
545  return bb_map_levels;
546 }
547 
548 void FunctionBehavior::set_epp(EdgeDescriptor e, unsigned long long value)
549 {
550  ppg->GetBBEdgeInfo(e)->set_epp_value(value);
551 }
552 
553 const LoopsConstRef FunctionBehavior::CGetLoops() const
554 {
555  return loops;
556 }
557 
558 const LoopsRef FunctionBehavior::GetLoops() const
559 {
560  return loops;
561 }
562 
563 #if HAVE_HOST_PROFILING_BUILT
564 const ProfilingInformationConstRef FunctionBehavior::CGetProfilingInformation() const
565 {
566  return profiling_information;
567 }
568 #endif
569 
570 void FunctionBehavior::add_function_mem(unsigned int node_id)
571 {
572  mem_nodeID.insert(node_id);
573 }
574 
575 void FunctionBehavior::add_dynamic_address(unsigned int node_id)
576 {
577  // std::cerr << "addr taken " << node_id << std::endl;
578  dynamic_address.insert(node_id);
580 }
581 
583 {
584  dynamic_address.clear();
585 }
586 
587 bool FunctionBehavior::is_variable_mem(unsigned int node_id) const
588 {
589  return mem_nodeID.find(node_id) != mem_nodeID.end();
590 }
591 
592 void FunctionBehavior::add_parm_decl_copied(unsigned int node_id)
593 {
594  parm_decl_copied.insert(node_id);
595  dynamic_address.insert(node_id);
596 }
597 
598 void FunctionBehavior::add_parm_decl_loaded(unsigned int node_id)
599 {
600  parm_decl_loaded.insert(node_id);
601  dynamic_address.insert(node_id);
602 }
603 
604 void FunctionBehavior::add_parm_decl_stored(unsigned int node_id)
605 {
606  parm_decl_stored.insert(node_id);
607  dynamic_address.insert(node_id);
608 }
609 
611 {
612  return mem_nodeID;
613 }
614 
616 {
617  mem_nodeID.clear();
618 }
619 
621 {
622  return dynamic_address;
623 }
624 
626 {
627  return parm_decl_copied;
628 }
629 
631 {
632  parm_decl_copied.clear();
633 }
634 
636 {
637  return parm_decl_loaded;
638 }
639 
641 {
642  parm_decl_loaded.clear();
643 }
644 
646 {
647  return parm_decl_stored;
648 }
649 
651 {
652  parm_decl_stored.clear();
653 }
654 
656 {
658  // I simply have to go over all the vertices and get the used variables;
659  // the variables which have to be declared are all those variables but
660  // the globals ones
661  VertexIterator v, vEnd;
662  for(boost::tie(v, vEnd) = boost::vertices(*cfg); v != vEnd; v++)
663  {
664  const auto& varsTemp = cfg->CGetOpNodeInfo(*v)->cited_variables;
665  vars.insert(varsTemp.begin(), varsTemp.end());
666  }
667  for(const auto& funParam : helper->GetParameters())
668  {
669  vars.erase(funParam->index);
670  }
671  for(const auto& gblVariable : AppM->GetGlobalVariables())
672  {
673  vars.erase(gblVariable->index);
674  }
675  return vars;
676 }
677 
679 {
680  THROW_ASSERT(ref.find(x) != ref.end(), "Vertex " + GET_NAME(g, x) + " is not in topological_sort");
681  THROW_ASSERT(ref.find(y) != ref.end(), "Second " + GET_NAME(g, y) + " vertex is not in topological_sort");
682  return ref.find(x)->second < ref.find(y)->second;
683 }
684 
685 bool FunctionBehavior::CheckBBReachability(const vertex first_basic_block, const vertex second_basic_block) const
686 {
687  if(bb_reachability.find(first_basic_block) != bb_reachability.end() and
688  bb_reachability.find(first_basic_block)->second.find(second_basic_block) !=
689  bb_reachability.find(first_basic_block)->second.end())
690  {
691  return true;
692  }
693  else
694  {
695  return false;
696  }
697 }
698 
700  const vertex second_basic_block) const
701 {
702  if(CheckBBReachability(first_basic_block, second_basic_block))
703  {
704  return true;
705  }
706  if(feedback_bb_reachability.find(first_basic_block) != feedback_bb_reachability.end() and
707  feedback_bb_reachability.find(first_basic_block)->second.find(second_basic_block) !=
708  feedback_bb_reachability.find(first_basic_block)->second.end())
709  {
710  return true;
711  }
712  else
713  {
714  return false;
715  }
716 }
717 
718 bool FunctionBehavior::CheckReachability(const vertex first_operation, const vertex second_operation) const
719 {
720  const CustomUnorderedMap<unsigned int, vertex>& bb_index_map = bb->CGetBBGraphInfo()->bb_index_map;
721  const unsigned int first_bb_index = cfg->CGetOpNodeInfo(first_operation)->bb_index;
722  const unsigned int second_bb_index = cfg->CGetOpNodeInfo(second_operation)->bb_index;
723  const vertex first_bb_vertex = bb_index_map.find(first_bb_index)->second;
724  const vertex second_bb_vertex = bb_index_map.find(second_bb_index)->second;
725  if(CheckBBReachability(first_bb_vertex, second_bb_vertex))
726  {
727  return true;
728  }
729  if(first_bb_vertex == second_bb_vertex)
730  {
731  THROW_ASSERT(map_levels.size(), "");
732  THROW_ASSERT(map_levels.find(first_operation) != map_levels.end(),
733  "Level of " + GET_NAME(cfg, first_operation) + " not found");
734  THROW_ASSERT(map_levels.find(second_operation) != map_levels.end(),
735  "Level of " + GET_NAME(cfg, second_operation) + " not found");
736  if(map_levels.find(first_operation)->second < map_levels.find(second_operation)->second)
737  {
738  return true;
739  }
740  }
741  return false;
742 }
743 
744 bool FunctionBehavior::CheckFeedbackReachability(const vertex first_operation, const vertex second_operation) const
745 {
746  const CustomUnorderedMap<unsigned int, vertex>& bb_index_map = bb->CGetBBGraphInfo()->bb_index_map;
747  const unsigned int first_bb_index = cfg->CGetOpNodeInfo(first_operation)->bb_index;
748  const unsigned int second_bb_index = cfg->CGetOpNodeInfo(second_operation)->bb_index;
749  const vertex first_bb_vertex = bb_index_map.find(first_bb_index)->second;
750  const vertex second_bb_vertex = bb_index_map.find(second_bb_index)->second;
751  return CheckBBFeedbackReachability(first_bb_vertex, second_bb_vertex);
752 }
753 
754 unsigned int FunctionBehavior::GetBBVersion() const
755 {
756  return bb_version;
757 }
758 
760 {
761  bb_version++;
762  return bb_version;
763 }
764 
766 {
767  return bitvalue_version;
768 }
769 
771 {
773  return bitvalue_version;
774 }
775 
777 {
778  return _channels_number;
779 }
780 
782 {
783  _channels_number = val;
784 }
785 
787 {
788  return _channels_type;
789 }
790 
792 {
793  _channels_type = val;
794 }
795 
797 {
798  return _allocation_policy;
799 }
800 
802 {
803  _allocation_policy = val;
804 }
805 
806 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
807 #pragma GCC diagnostic pop
808 #endif
const OpGraphRef flg
The flow edge operation graph.
#define FLG_SELECTOR
Flow edge selector.
Definition: op_graph.hpp:515
Anti + Data flow graph dependence between aggregates.
System dependence graph.
~FunctionBehavior()
Destructor.
const BBGraphRef dj
The dj graph (used for loop computation)
unsigned int GetBitValueVersion() const
Return the version of the bitvalue information.
Basic block control flow graph.
Anti dependence + data dependence + output dependence + flow graph with feedback. ...
unsigned int UpdateBBVersion()
Update the version of the basic block intermediate representation.
void SetChannelsNumber(unsigned int val)
Definition of the class representing a generic C application.
const std::vector< std::string > SplitString(const std::string &input, const std::string &separators)
Function which splits a string into tokens.
class providing methods to manage an operations graph.
bool CheckFeedbackReachability(const vertex first_operation, const vertex second_operation) const
Check if a path from first_operation to second_operation exists in control flow graph with feedback...
bool operator()(const vertex x, const vertex y) const
Compare position of two vertices in topological sorted.
Data structore used to build the topological order of the operations vertices.
MemoryAllocation_ChannelsType GetChannelsType() const
CustomOrderedSet< unsigned int > get_local_variables(const application_managerConstRef AppM) const
Returns the set of local variables.
const OpGraphRef cdg
The control dependence graph.
void clean_parm_decl_loaded()
clean_parm_decl_loaded clean parm_decl_loaded data structure
#define INDENT_OUT_MEX(outLevel, curOutLevel, mex)
const OpGraphRef odg
The output-dependencies flow graph.
Anti-dependence graph with feedback.
const OpGraphRef saodg
The system dependence, antidependence and output dependence graph.
#define GET_NAME(data, vertex_index)
Helper macro returning the name associated with a node.
Class specification of the graph structures.
unsigned int bb_version
The version of basic block intermediate representation.
const OpGraphRef fodg
The output-dependencies flow graph with feedback.
void clean_dynamic_address()
remove all variables from the dynamic address set
exceptions managed by PandA
MemoryAllocation_ChannelsType
The number of channels.
#define FCFG_SELECTOR
Control flow graph with feedback edges.
#define DEBUG_SELECTOR
Debug selector.
Definition: op_graph.hpp:521
void add_parm_decl_stored(unsigned int node_id)
add a formal parameter that has to be initialized from the actual value
const OpGraphRef fdfg
The data flow graph with feedback.
const std::deque< vertex > & get_bb_levels() const
Return the vector of bb vertex index sorted in topological order.
Definition of the profiling information class.
#define D_SELECTOR
Selectors used only in basic block graphs; numbers continue from cdfg_edge_info.hpp.
Definition: basic_block.hpp:85
bool CheckBBReachability(const vertex first_basic_block, const vertex second_basic_block) const
Check if a path from the first basic block to the second basic block exists in control flow graph (wi...
Basic block control flow graph with edges imposing that basic block inside a loop are executed before...
CustomOrderedSet< unsigned int > dynamic_address
store memory objects which can be indirectly addressed through a dynamic address computation ...
refcount< const OpGraph > OpGraphConstRef
Definition: op_graph.hpp:923
#define FADG_SELECTOR
Anti-dependence graph selector with feedback edges.
Definition: op_graph.hpp:474
MemoryAllocation_Policy _allocation_policy
const BehavioralHelperRef helper
Behavioral helper associated with this behavioral_graph_manager.
Basic block post-dominator tree.
const OpGraphRef fcfg
The control flow graph with feedback.
This class provides methods to build a basic blocks graph.
const OpGraphRef fsdg
The system dependence graph with feedback.
Base class description of data information associated with each node of a graph.
#define OUTPUT_LEVEL_MINIMUM
minimum debugging print is performed.
dominance< BBGraph > * post_dominators
This class stores post-dominator information.
A set of operation vertices.
Definition: op_graph.hpp:654
const std::map< vertex, unsigned int > & get_bb_map_levels() const
Return the map of bb vertex index sorted in topological order.
static std::string GetMangledFunctionName(const function_decl *fd)
Return the mangled function name.
#define STR(s)
Macro which performs a lexical_cast to a string.
const BBGraphRef bb
The basic block CFG.
System dependence + anti-dependence + output dependence graph + flow graph + debug graph...
const BBGraphRef dt
The dominator tree of the CFG on basic blocks.
const OpGraphRef adg
The anti-dependencies graph.
const OpGraphRef sdg
The system dependence graph.
void clean_function_mem()
clean the function mem data structure
information associated with the whole graph
Definition: op_graph.hpp:556
std::deque< vertex > bb_deque_levels
list of operations vertices sorted by topological order in control flow graph; in the sorting then pa...
unsigned int UpdateBitValueVersion()
Update the version of the bitvalue information.
const BBGraphRef cdg_bb
The control dependence graph among basic blocks.
graph_type
Declaration of enum representing the type of graph.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
Definition: exceptions.hpp:292
System dependence graph with feedback.
void add_parm_decl_copied(unsigned int node_id)
Adds an identifier to the set of memory variables.
CustomOrderedSet< unsigned int > mem_nodeID
this set represents the memory variables accessed by the function
Class specification for storing profiling information.
bool CheckBBFeedbackReachability(const vertex first_basic_block, const vertex second_basic_block) const
Check if a path from the first basic block to the second basic block exists in control flow graph wit...
const std::deque< vertex > & get_levels() const
Return the vector of vertex index sorted in topological order.
System dependence + anti-dependence graph + output dependence graph with feedback.
#define J_SELECTOR
j graph edge selector for dj graph (used during loop computation)
Definition: basic_block.hpp:91
Output dependence graph.
Class used to describe a particular graph with basic blocks as nodes.
#define SAODG_SELECTOR
Control and Data dependence and antidependence graph edge selector.
Definition: op_graph.hpp:502
Control dependence graph.
#define PP_SELECTOR
Path Profiling Basic Block edge selector.
Definition: basic_block.hpp:94
absl::flat_hash_map< T, U, Hash, Eq, Alloc > CustomUnorderedMap
Definition: custom_map.hpp:148
#define CDG_SELECTOR
Control dependence edge selector.
const OpGraphRef flaoddg
The anti-dependence + data dependence + output dependence + flow graph.
const LoopsRef GetLoops() const
Return the loops.
const OpGraphRef sg
The speculation graph.
const OpGraphRef fflaoddg
The anti-dependence + data dependence + output dependence + flow graph with freedback.
Control flow graph.
#define SDG_SELECTOR
Control and Data dependence graph edge selector.
Definition: op_graph.hpp:492
const OpGraphRef cfg
The control flow graph.
#define ODG_SELECTOR
Output-dependence graph edge selector.
Definition: op_graph.hpp:481
const BBGraphRef extended_bb
The basic block Control Flow Graph extended with edges that impose that basic block inside a loop are...
const OpGraphRef dfg
The data flow graph.
Basic block dominator tree.
Information associated with the whole basic-block graph.
CustomUnorderedMapStable< vertex, CustomUnorderedSet< vertex > > feedback_bb_reachability
Reachability between basic blocks based on control flow graph with feedback.
OpGraphRef GetOpGraph(FunctionBehavior::graph_type gt)
This method returns the operation graphs.
Basic block control flow graph with feedback.
Extended control flow graph.
Control dependence graph with feedback.
redefinition of set to manage ordered/unordered structures
void print(std::ostream &os) const
Function that prints the class behavioral_manager.
void set_epp(EdgeDescriptor e, unsigned long long value)
Set epp associated with an edges.
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
memory_access(unsigned int _node_id, unsigned int _base_address, unsigned int _offset=0)
FunctionBehavior(const application_managerConstRef AppM, const BehavioralHelperRef _helper, const ParameterConstRef parameters)
Constructor.
unsigned offset[NUM_VERTICES+1]
Definition: graph.h:3
const OpGraphRef flsaodg
The system dependence, antidependence, output dependence and flow graph.
const OpGraphRef agg_virtualg
Anti + Data flow graph on aggregates.
Support basic block for path profiling.
const BehavioralHelperConstRef CGetBehavioralHelper() const
Returns the helper associated with the function.
boost::graph_traits< graph >::vertex_iterator VertexIterator
vertex_iterator definition.
Definition: graph.hpp:1307
Classes specification of the tree_node data structures.
#define FDFG_SELECTOR
Data flow graph with feedback edges.
Definition: op_graph.hpp:459
const OpGraphRef extended_cfg
The extended control flow graph.
BehavioralHelperRef GetBehavioralHelper()
Returns the helper associated with the function.
Basic block control dependence graph.
This file collects some utility functions and macros.
CustomOrderedSet< unsigned int > parm_decl_copied
this set represents the parameters that have to be copied from the caller
const OpGraphRef fsaodg
The system dependence, antidependence and output dependence graph with feedback.
#define FSDG_SELECTOR
Control and Data dependence graph and dependence edge selector.
Definition: op_graph.hpp:494
const std::map< vertex, unsigned int > & get_map_levels() const
Return the map of vertex index sorted in topological order.
int initiation_time
used only for stallable pipelines
#define DFG_SELECTOR
Data flow graph edge selector.
Definition: op_graph.hpp:451
#define ADG_SELECTOR
Anti-dependence graph edge selector.
Definition: op_graph.hpp:466
class providing methods to manage a basic blocks graph.
MemoryAllocation_ChannelsType _channels_type
Function scope channels type.
bool CheckReachability(const vertex first_operation, const vertex second_operation) const
Check if a path from first_operation to second_operation exists in control flow graph (without feedba...
This file collects some utility functions.
std::deque< vertex > deque_levels
list of operations vertices sorted by topological order in control flow graph; in the sorting then pa...
Output dependence graph with feedback.
void add_dynamic_address(unsigned int node_id)
Add the node_id to the set of object for which a dynamic address computation could be used...
dominance< BBGraph > * dominators
This class stores dominator information.
std::map< vertex, unsigned int > map_levels
Map operation vertex to position in topological order in control flow graph; in the sorting then part...
Data structures used to represent an edge in operation and basic block graphs.
#define FODG_SELECTOR
Output-dependence graph selector with feedback edges.
Definition: op_graph.hpp:489
bb_graph_type
Declaration of enum representing the type of bb_graph.
const BBGraphRef fbb
The basic block CFG with feedback.
CustomUnorderedMapStable< vertex, CustomUnorderedSet< vertex > > bb_reachability
Mutual exclusion between basic blocks (based on control flow graph with flow edges) ...
Speculation graph.
Data flow graph with feedback.
void SetChannelsType(MemoryAllocation_ChannelsType val)
#define SG_SELECTOR
Speculation graph.
Definition: op_graph.hpp:509
BBGraphRef GetBBGraph(FunctionBehavior::bb_graph_type gt=FunctionBehavior::BB)
This method returns the basic block graphs.
std::map< vertex, unsigned int > bb_map_levels
Map basic block vertex to position in topological order in control flow graph; in the sorting then pa...
DJ basic block graph (used for loop computation)
const OpGraphRef fadg
The anti-dependencies graph with feedback.
const OpGraphConstRef CGetOpGraph(FunctionBehavior::graph_type gt) const
This method returns the operation graphs.
CustomOrderedSet< unsigned int > parm_decl_loaded
this set represents the actual parameters that has to be loaded into the formal parameter from the ac...
Class specification of the basic_block structure.
bool is_variable_mem(unsigned int node_id) const
Checks if a variable has been allocated in memory.
unsigned int GetBBVersion() const
Return the version of the basic block intermediate representation.
unsigned int _channels_number
Function scope channels number.
Anti-dependence + data dependence + output dependence + flow graph.
#define PD_SELECTOR
post-dominator graph edge selector
Definition: basic_block.hpp:88
const BBGraphRef ppg
The support basic block graph for path profiling.
interface of a loop
LoopsRef loops
Loops of the function.
bool pipeline_enabled
true when pipelining is enabled for the function
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
unsigned int bitvalue_version
Version of the bitvalue information.
const BBGraphConstRef CGetBBGraph(FunctionBehavior::bb_graph_type gt=FunctionBehavior::BB) const
This method returns the basic block graphs.
const LoopsConstRef CGetLoops() const
Return the loops.
interface of loops finding algorithm
System dependence + anti-dependence + output dependence graph + flow graph.
this class is used to manage the command-line or XML options.
const CustomOrderedSet< unsigned int > & get_parm_decl_stored() const
Returns the set of the formal parameters that has to be stored into the formal parameter.
const CustomOrderedSet< unsigned int > & get_parm_decl_copied() const
Returns the set of parameters to be copied.
unsigned int GetChannelsNumber() const
const OpGraphRef flsaoddg
The system dependence, antidependence, output dependence, flow and debug graph.
bool simple_pipeline
true when the requested pipeline does not include unbounded functions
const OpGraphRef fcdg
The control dependence graph with feedback.
void clean_parm_decl_stored()
clean_parm_decl_stored clean parm_decl_stored data structure
const OpGraphsCollectionRef op_graphs_collection
Global graph storing CFG, DFG, FCFG, FDFG, SDG, FSDG, CDG. The nodes of this graph are operations...
#define DFG_AGG_SELECTOR
Data flow graph edge selector between computed on aggregates.
Definition: op_graph.hpp:449
Control flow graph with feedback.
x
Return the smallest n such that 2^n >= _x.
void clean_parm_decl_copied()
clean_parm_decl_copied clean parm_decl_copied data structure
void SetMemoryAllocationPolicy(MemoryAllocation_Policy val)
Class used to describe a particular graph with operations as nodes.
Definition: op_graph.hpp:783
refcount< OpGraph > OpGraphRef
refcount definition of the class
Definition: op_graph.hpp:922
This class provides methods to build an operations graph.
const BBGraphRef pdt
The post-dominator tree of the CFG on basic blocks.
#define ADG_AGG_SELECTOR
Anti-dependence graph edge selector computed on aggregates.
Definition: op_graph.hpp:464
const CustomOrderedSet< unsigned int > & get_parm_decl_loaded() const
Returns the set of the actual parameters that has to be loaded into the formal parameter.
#define CFG_SELECTOR
Control flow graph edge selector.
const CustomOrderedSet< unsigned int > & get_function_mem() const
Returns the set of memory variables.
System dependence + anti-dependence graph + output dependence graph.
System dependence + anti-dependence + output dependence graph + flow graph with feedback.
This structure defines graphs where nodes are operations.
Definition: op_graph.hpp:715
#define ECFG_SELECTOR
Extended control flow graph selector.
MemoryAllocation_Policy GetMemoryAllocationPolicy() const
const CustomOrderedSet< unsigned int > & get_dynamic_address() const
Returns the set of variables for which a dynamic address computation maybe required.
struct definition of the declaration node structures.
Definition: tree_node.hpp:877
MemoryAllocation_Policy
The allocation memory polycy.
void add_parm_decl_loaded(unsigned int node_id)
add an actual parameter that has to be loaded into the formal parameter
Class specification of the manager of the tree structures extracted from the raw file.
Anti-dependence graph.
A brief description of the C++ Header File.
void add_function_mem(unsigned int node_id)
Adds a memory variable to the function.
#define FB_ADG_SELECTOR
Feedback anti-dependence graph edge selector.
Definition: op_graph.hpp:472
const OpGraphRef fflsaodg
The system dependence, antidependence, output dependence and flow graph with feedback;.
refcount< BBGraph > BBGraphRef
refcount definition of the class
#define FCDG_SELECTOR
Control dependence graph selector with feedback edges.
CustomOrderedSet< unsigned int > parm_decl_stored
this set represents the formal parameters that has to be stored into the formal parameter from the ac...
This structure defines graphs where nodes are basic_blocks.
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:50 for PandA-2024.02 by doxygen 1.8.13