51 #include <boost/graph/topological_sort.hpp> 69 unsigned int _function_id,
const DesignFlowManagerConstRef _design_flow_manager)
71 TM(_AppM->get_tree_manager())
82 switch(relationship_type)
90 if(!
parameters->getOption<
int>(OPT_gcc_openmp_simd))
92 relationships.insert(std::make_pair(BIT_VALUE,
SAME_FUNCTION));
117 relationships.insert(std::make_pair(CSE_STEP,
SAME_FUNCTION));
118 relationships.insert(std::make_pair(EXTRACT_PATTERNS,
SAME_FUNCTION));
124 return relationships;
130 if(
GET_NODE(t)->get_kind() == gimple_assign_K)
132 auto* temp_assign = GetPointer<gimple_assign>(
GET_NODE(t));
133 if(
GET_NODE(temp_assign->op1)->get_kind() == mult_expr_K ||
134 GET_NODE(temp_assign->op1)->get_kind() == widen_mult_expr_K ||
135 GET_NODE(temp_assign->op1)->get_kind() == ternary_plus_expr_K ||
136 GET_NODE(temp_assign->op1)->get_kind() == ternary_mm_expr_K ||
137 GET_NODE(temp_assign->op1)->get_kind() == ternary_pm_expr_K ||
138 GET_NODE(temp_assign->op1)->get_kind() == ternary_mp_expr_K)
148 if(
parameters->IsParameter(
"disable-fanout_opt"))
152 bool IR_changed =
false;
155 auto* fd = GetPointer<function_decl>(temp);
156 auto*
sl = GetPointer<statement_list>(
GET_NODE(fd->body));
159 for(
const auto&
block : sl->list_of_bloc)
162 for(
const auto& stmt :
block.second->CGetStmtList())
164 if(not
AppM->ApplyNewTransformation())
169 if(
GET_NODE(stmt)->get_kind() == gimple_assign_K)
171 auto* ga = GetPointer<gimple_assign>(
GET_NODE(stmt));
172 const std::string srcp_default =
173 ga->include_name +
":" +
STR(ga->line_number) +
":" +
STR(ga->column_number);
174 if(
GET_NODE(ga->op0)->get_kind() == ssa_name_K)
176 auto* ssa_defined = GetPointer<ssa_name>(
GET_NODE(ga->op0));
177 if(ssa_defined->CGetNumberUses() > 1)
181 "---the assigned ssa_name " +
STR(
GET_NODE(ga->op0)) +
" has type " +
182 STR(assigned_ssa_type_node));
183 bool is_first_stmt =
true;
184 std::list<tree_nodeRef> list_of_dest_statements;
185 for(
const auto& dest_statement : ssa_defined->CGetUseStmts())
189 is_first_stmt =
false;
193 list_of_dest_statements.push_back(dest_statement.first);
196 for(
const auto& dest_statement : list_of_dest_statements)
199 tree_man->CreateGimpleAssign(assigned_ssa_type_node, ssa_defined->min, ssa_defined->max,
202 "---create a temporary assignment " + temp_assign->
ToString());
203 block.second->PushAfter(temp_assign, stmt,
AppM);
205 GetPointer<gimple_assign>(
GET_NODE(temp_assign))->keep =
true;
206 GetPointer<gimple_assign>(
GET_NODE(temp_assign))->temporary_address = ga->temporary_address;
207 GetPointer<ssa_name>(
GET_NODE(temp_ssa_var))->SetDefStmt(temp_assign);
209 "---dest statement before replacement " + dest_statement->ToString());
210 TM->ReplaceTreeNode(dest_statement, ga->op0, temp_ssa_var);
212 "---dest statement after replacement " + dest_statement->ToString());
221 if(!
parameters->getOption<
int>(OPT_gcc_openmp_simd))
224 for(
const auto&
phi :
block.second->CGetPhiList())
227 auto* ssa_defined = GetPointer<ssa_name>(
GET_NODE(gp->res));
229 if(ssa_defined->CGetNumberUses() > 1)
231 bool is_first_stmt =
true;
232 std::list<tree_nodeRef> list_of_dest_statements;
233 for(
const auto& dest_statement : ssa_defined->CGetUseStmts())
237 is_first_stmt =
false;
241 list_of_dest_statements.push_back(dest_statement.first);
244 for(
const auto& dest_statement : list_of_dest_statements)
247 std::vector<std::pair<tree_nodeRef, unsigned int>> list_of_def_edge;
248 for(
const auto& def_edge : gp->CGetDefEdgesList())
250 list_of_def_edge.push_back(std::pair<tree_nodeRef, unsigned int>(def_edge.first, def_edge.second));
256 auto new_res_var_ssa = GetPointer<ssa_name>(
GET_NODE(new_res_var));
257 new_res_var_ssa->min = ssa_defined->min;
258 new_res_var_ssa->max = ssa_defined->max;
259 GetPointer<gimple_phi>(
GET_NODE(new_phi))->SetSSAUsesComputed();
261 block.second->AddPhi(new_phi);
262 GetPointer<gimple_phi>(
GET_NODE(new_phi))->keep =
true;
264 "---dest statement before replacement " + dest_statement->ToString());
265 TM->ReplaceTreeNode(dest_statement, gp->res, new_res_var);
267 "---dest statement after replacement " + dest_statement->ToString());
276 for(
const auto& stmt :
block.second->CGetStmtList())
290 if(GetPointer<const HLS_manager>(
AppM) and GetPointer<const HLS_manager>(
AppM)->get_HLS(
function_id) and
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
void Initialize() override
Initialize the step (i.e., like a constructor, but executed just before exec)
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
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.
std::string ToString() const
Print this node as string in gimple format.
Step successfully executed.
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 GET_CLASS(obj)
Macro returning the actual type of an object.
Definition of the class representing a generic C application.
refcount< tree_manipulation > tree_manipulationRef
Step successfully executed but without any IR change.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
#define GET_INDEX_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
const tree_managerRef TM
tree manager
Data structure describing a basic block at tree level.
DesignFlowStep_Status InternalExec() override
perform fanout_opt analysis
virtual enum kind get_kind() const =0
Virtual function returning the type of the actual class.
#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.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
void UpdateTime(const unsigned int operation_index, bool update_cs=true)
Compute the starting and the ending time of a statement.
Data structure used to store the schedule of the operations.
fanout_opt(const ParameterConstRef _parameters, const application_managerRef _AppM, unsigned int function_id, const DesignFlowManagerConstRef design_flow_manager)
Constructor.
bool is_dest_relevant(tree_nodeRef t, bool is_phi)
return true in case the use is relevant for the fanout optimization
Target must be reexecuted.
DesignFlowStep_Status GetStatus() const
Return the status of this design step.
Classes specification of the tree_node data structures.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
Class defining some useful functions to create tree nodes and to manipulate the tree manager...
#define DEBUG_LEVEL_NONE
no debugging print is performed.
ScheduleRef schedule
The scheduling solution.
This struct specifies the block node.
This file collects some utility functions.
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.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
static tree_nodeConstRef CGetType(const tree_nodeConstRef &node)
Return the treenode of the type of node.
Fanout optimization step.
this class is used to manage the command-line or XML options.
int debug_level
The debug level.
#define GET_INDEX_CONST_NODE(t)
Data structure definition for high-level synthesis flow.
Step is symbolic and it has already been marked.
This class creates a layer to add nodes and to manipulate the tree_nodes manager. ...
~fanout_opt() override
Destructor.
Class specification of the manager of the tree structures extracted from the raw file.
A brief description of the C++ Header File.
const FunctionBehaviorRef function_behavior
The function behavior of the function to be analyzed.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...