PandA-2024.02
FixVdef.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) 2021-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  */
43 #include "FixVdef.hpp"
44 
45 #include "Parameter.hpp" // for Parameter
46 #include "application_manager.hpp" // for application_manager, app...
47 #include "dbgPrintHelper.hpp" // for DEBUG_LEVEL_VERY_PEDANTIC
48 #include "design_flow_graph.hpp" // for DesignFlowGraph, DesignF...
49 #include "design_flow_manager.hpp" // for DesignFlowManager, Desig...
50 #include "design_flow_step_factory.hpp" // for DesignFlowManagerConstRef
51 #include "exceptions.hpp" // for THROW_ASSERT, THROW_UNRE...
52 #include "hls_manager.hpp" // for HLS_manager
53 #include "string_manipulation.hpp" // for STR, GET_CLASS
54 #include "technology_flow_step.hpp" // for TechnologyFlowStep_Type
55 #include "technology_flow_step_factory.hpp" // for TechnologyFlowStepFactory
56 #include "tree_basic_block.hpp" // for bloc
57 #include "tree_manager.hpp" // for tree_manager
58 #include "tree_node.hpp" // for gimple_assign
59 #include "tree_reindex.hpp"
60 
61 FixVdef::FixVdef(const ParameterConstRef Param, const application_managerRef _AppM, unsigned int _function_id,
62  const DesignFlowManagerConstRef _design_flow_manager)
63  : FunctionFrontendFlowStep(_AppM, _function_id, FIX_VDEF, _design_flow_manager, Param)
64 {
65  debug_level = parameters->get_class_debug_level(GET_CLASS(*this));
66 }
67 
70 {
72  switch(relationship_type)
73  {
75  {
76  relationships.insert(std::make_pair(BLOCK_FIX, SAME_FUNCTION));
77  relationships.insert(std::make_pair(FIX_STRUCTS_PASSED_BY_VALUE, SAME_FUNCTION));
78  relationships.insert(std::make_pair(FUNCTION_ANALYSIS, WHOLE_APPLICATION));
79  relationships.insert(std::make_pair(HWCALL_INJECTION, SAME_FUNCTION));
80  relationships.insert(std::make_pair(REBUILD_INITIALIZATION, SAME_FUNCTION));
81  relationships.insert(std::make_pair(REMOVE_CLOBBER_GA, SAME_FUNCTION));
82  relationships.insert(std::make_pair(SWITCH_FIX, SAME_FUNCTION));
83  break;
84  }
86  {
87  break;
88  }
90  {
91  break;
92  }
93  default:
95  }
96  return relationships;
97 }
98 
99 FixVdef::~FixVdef() = default;
100 
102  const DesignFlowStep::RelationshipType relationship_type)
103 {
104  switch(relationship_type)
105  {
107  {
108  break;
109  }
111  {
112  const auto design_flow_graph = design_flow_manager.lock()->CGetDesignFlowGraph();
113  const auto technology_flow_step_factory = GetPointerS<const TechnologyFlowStepFactory>(
114  design_flow_manager.lock()->CGetDesignFlowStepFactory("Technology"));
115  const auto technology_flow_signature =
117  const auto technology_flow_step = design_flow_manager.lock()->GetDesignFlowStep(technology_flow_signature);
118  const auto technology_design_flow_step =
119  technology_flow_step ?
120  design_flow_graph->CGetDesignFlowStepInfo(technology_flow_step)->design_flow_step :
121  technology_flow_step_factory->CreateTechnologyFlowStep(TechnologyFlowStep_Type::LOAD_TECHNOLOGY);
122  relationship.insert(technology_design_flow_step);
123  break;
124  }
126  {
127  break;
128  }
129  default:
130  THROW_UNREACHABLE("");
131  }
132  FunctionFrontendFlowStep::ComputeRelationships(relationship, relationship_type);
133 }
134 
136 {
137  const auto TM = AppM->get_tree_manager();
138  const auto tn = TM->CGetTreeNode(function_id);
139  const auto fd = GetPointer<const function_decl>(tn);
140  THROW_ASSERT(fd && fd->body, "Node is not a function or it hasn't a body");
141  const auto sl = GetPointer<const statement_list>(GET_CONST_NODE(fd->body));
142  THROW_ASSERT(sl, "Body is not a statement_list");
143  THROW_ASSERT(GetPointer<const HLS_manager>(AppM), "unexpected condition");
144  const auto isSingleMem = GetPointerS<const HLS_manager>(AppM)->IsSingleWriteMemory();
145  for(const auto& block : sl->list_of_bloc)
146  {
147  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Analyzing BB" + STR(block.first));
148  for(const auto& s : block.second->CGetStmtList())
149  {
150  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Analyzing statement " + GET_NODE(s)->ToString());
151  const auto gn = GetPointerS<gimple_node>(GET_NODE(s));
152  if(isSingleMem)
153  {
154  gn->vdef = gn->memdef;
155  if(!gn->vuses.empty())
156  {
157  gn->vuses.clear();
158  }
159  if(gn->memuse)
160  {
161  gn->AddVuse(gn->memuse);
162  }
163  if(!gn->vovers.empty())
164  {
165  gn->vovers.clear();
166  }
167  }
168  gn->memdef = nullptr;
169  gn->memuse = nullptr;
170  }
171  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Analyzed BB" + STR(block.first));
172  }
174 }
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
Definition: tree_node.hpp:343
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
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.
Definition: FixVdef.cpp:69
Data structure representing the entire HLS information.
#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.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
Definition of the class representing a generic C application.
void ComputeRelationships(DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override
Compute the relationships of a step with other steps.
Definition: FixVdef.cpp:101
RelationshipType
The relationship type.
Source must be executed to satisfy target.
~FixVdef() override
Destructor.
exceptions managed by PandA
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.
std::string ToString(ActorGraphBackend_Type actor_graph_backend_type)
Header include.
void ComputeRelationships(DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override
Compute the relationships of a step with other steps.
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
Definition: exceptions.hpp:292
merge memory dependencies in virtual dependencies
Classes to describe design flow graph.
static const std::string ComputeSignature(const TechnologyFlowStep_Type technology_flow_step_type)
Compute the signature of a technology flow step.
Factory for technology flow step.
const Wrefcount< const DesignFlowManager > design_flow_manager
The design flow manager.
#define GET_CONST_NODE(t)
Definition: tree_node.hpp:347
Classes specification of the tree_node data structures.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
Wrapper of design_flow.
This struct specifies the block node.
Definition: tree_node.hpp:1820
DesignFlowStep_Status InternalExec() override
move memory dependencies to virtual in case of single wryte memories
Definition: FixVdef.cpp:135
refcount< T > lock() const
Definition: refcount.hpp:212
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.
FixVdef(const ParameterConstRef Param, const application_managerRef AppM, unsigned int function_id, const DesignFlowManagerConstRef design_flow_manager)
Constructor.
Definition: FixVdef.cpp:61
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.
int debug_level
The debug level.
Class specification of the manager of the tree structures extracted from the raw file.
Base class for technology flow steps.
int sl
Definition: adpcm.c:105
#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:52 for PandA-2024.02 by doxygen 1.8.13