84 switch(relationship_type)
88 relationships.insert(std::make_pair(DEAD_CODE_ELIMINATION,
ALL_FUNCTIONS));
89 relationships.insert(std::make_pair(PARM2SSA,
ALL_FUNCTIONS));
94 if(!
parameters->getOption<
int>(OPT_gcc_openmp_simd))
96 relationships.insert(std::make_pair(BIT_VALUE_OPT,
ALL_FUNCTIONS));
109 return relationships;
118 const auto DFG = DFM->CGetDesignFlowGraph();
119 std::vector<FrontendFlowStepType> step_types = {FrontendFlowStepType::DEAD_CODE_ELIMINATION};
120 if(!
parameters->getOption<
int>(OPT_gcc_openmp_simd))
122 step_types.push_back(FrontendFlowStepType::BIT_VALUE);
126 for(
auto step_type : step_types)
129 const auto frontend_step = DFM->GetDesignFlowStep(step_signature);
131 const auto design_flow_step = DFG->CGetDesignFlowStepInfo(frontend_step)->design_flow_step;
132 relationships.insert(design_flow_step);
135 fun_id_to_restart.clear();
139 const auto frontend_step = DFM->GetDesignFlowStep(step_signature);
141 const auto design_flow_step = DFG->CGetDesignFlowStepInfo(frontend_step)->design_flow_step;
142 relationships.insert(design_flow_step);
144 fun_id_to_restartParm.clear();
156 if(!
AppM->ApplyNewTransformation())
162 const auto TM =
AppM->get_tree_manager();
163 const auto CGM =
AppM->CGetCallGraphManager();
166 const auto top_functions =
parameters->getOption<std::vector<std::string>>(OPT_top_functions_names);
167 std::transform(top_functions.begin(), top_functions.end(),
168 std::inserter(interface_functions, interface_functions.end()),
170 const auto addr_funcs = CGM->GetAddressedFunctions();
171 interface_functions.insert(addr_funcs.begin(), addr_funcs.end());
173 const auto reached_body_fun_ids = CGM->GetReachedBodyFunctions();
174 for(
const auto f_id : reached_body_fun_ids)
176 const auto is_root = interface_functions.find(f_id) != interface_functions.end();
179 const auto fu_name =
AppM->CGetFunctionBehavior(f_id)->CGetBehavioralHelper()->get_function_name();
181 "-->Analyzing function \"" + fu_name +
"\": id = " +
STR(f_id));
182 const auto fu_node = TM->GetTreeNode(f_id);
183 auto fd = GetPointerS<function_decl>(fu_node);
184 THROW_ASSERT(fd && fd->body,
"Node is not a function or it hasn't a body");
185 if(!fd->list_of_args.empty())
194 const auto FB =
AppM->GetFunctionBehavior(f_id);
195 FB->UpdateBBVersion();
199 const auto FB =
AppM->GetFunctionBehavior(f_id);
200 FB->UpdateBBVersion();
210 std::vector<unsigned int> unused_parm_indices;
212 auto idx =
static_cast<unsigned int>(parms.size() - 1);
213 for(
auto it = parms.rbegin(); it != parms.rend(); ++it, --idx)
216 if(GetPointer<const ssa_name>(TM->
CGetTreeNode(ssa))->CGetUseStmts().empty())
218 unused_parm_indices.push_back(idx);
223 if(unused_parm_indices.empty())
231 "Unused parameter indices: " +
232 container_to_string(unused_parm_indices.rbegin(), unused_parm_indices.rend(),
", ",
false));
233 const auto arg_eraser = [&](std::vector<tree_nodeRef>& arg_list,
const tree_nodeRef& call_stmt) {
234 for(
const auto& idx : unused_parm_indices)
236 const auto arg_it = std::next(arg_list.begin(), idx);
237 auto ssa = GetPointer<ssa_name>(
GET_NODE(*arg_it));
241 "ssa " + ssa->ToString() +
" not used in " + call_stmt->ToString());
243 if(ssa->virtual_flag)
245 const auto gn = GetPointerS<gimple_node>(
GET_NODE(call_stmt));
246 if(gn->vuses.erase(*arg_it))
248 ssa->RemoveUse(call_stmt);
250 if(gn->vovers.erase(*arg_it))
252 ssa->RemoveUse(call_stmt);
257 ssa->RemoveUse(call_stmt);
260 arg_list.erase(arg_it);
263 const auto CGM =
AppM->CGetCallGraphManager();
264 const auto CG = CGM->CGetCallGraph();
265 const auto function_v = CGM->GetVertex(function_id);
269 std::vector<tree_nodeConstRef> argsT;
270 arg_eraser(loa,
nullptr);
271 std::transform(loa.cbegin(), loa.cend(), std::back_inserter(argsT),
277 BOOST_FOREACH(
EdgeDescriptor ie, boost::in_edges(function_v, *CG))
279 const auto caller_id = CGM->get_function(ie.m_source);
280 if(rFunctions.find(caller_id) != rFunctions.end())
282 const auto fei = CG->CGetFunctionEdgeInfo(ie);
285 "Analysing call points from " +
287 for(
const auto& call_id : fei->direct_call_points)
290 auto call_stmt =
GET_NODE(call_rdx);
293 if(call_stmt->get_kind() == gimple_call_K)
295 auto gc = GetPointerS<gimple_call>(call_stmt);
298 arg_eraser(gc->args, call_rdx);
300 else if(call_stmt->get_kind() == gimple_assign_K)
302 const auto ga = GetPointerS<const gimple_assign>(call_stmt);
303 auto ce = GetPointer<call_expr>(
GET_NODE(ga->op1));
307 arg_eraser(ce->args, call_rdx);
311 THROW_UNREACHABLE(
"Call point statement not handled: " + call_stmt->get_kind_text());
313 auto ae = GetPointer<addr_expr>(
GET_NODE(fn));
316 ae->type = ftype_ptr;
334 AppM->CGetFunctionBehavior(function_id)->CGetBehavioralHelper()))));
335 const auto HLSMgr = GetPointer<HLS_manager>(
AppM);
337 const auto func_arch = HLSMgr->module_arch->GetArchitecture(fname);
340 for(
auto i : unused_parm_indices)
343 const auto pname = GetPointer<parm_decl>(
GET_NODE(pnode))->name;
345 const auto pname_str = GetPointer<identifier_node>(
GET_NODE(pname))->strg;
346 func_arch->parms.erase(pname_str);
355 AppM->CGetFunctionBehavior(function_id)->CGetBehavioralHelper()))));
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
DesignFlowStep_Status Exec() override
Execute the step.
#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.
#define DEBUG_LEVEL_PEDANTIC
very verbose debugging print is performed.
Step successfully executed.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
Definition of the class representing a generic C application.
static std::string print_type(const tree_managerConstRef &TM, unsigned int type, bool global=false, bool print_qualifiers=false, bool print_storage=false, unsigned int var=0, const var_pp_functorConstRef &vppf=var_pp_functorConstRef(), const std::string &prefix="", const std::string &tail="")
Print a type and its variable in case var is not zero.
RelationshipType
The relationship type.
struct definition of the function_decl tree node.
Source must be executed to satisfy target.
This class contains the base representation for a generic frontend flow step which works on a single ...
Data structure describing a basic block at tree level.
redefinition of map to manage ordered/unordered structures
const tree_nodeConstRef CGetTreeNode(const unsigned int i) const
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.
Auxiliary methods for manipulating string.
CustomOrderedSet< unsigned int > fun_id_to_restartParm
stores the function ids of the functions whose Parm2SSA intra procedural steps have to be invalidated...
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
Standard functor that returns the name of a variable.
tree_nodeRef GetPointerType(const tree_nodeConstRef &ptd, unsigned long long algn=0) const
Function that creates a pointer type if it is not already present, otherwise it returns the one that ...
Classes to describe design flow graph.
Target must be reexecuted.
redefinition of set to manage ordered/unordered structures
tree_nodeRef GetTreeReindex(const unsigned int i)
Return a tree_reindex wrapping the i-th tree_node.
CustomOrderedSet< unsigned int > fun_id_to_restart
stores the function ids of the functions whose Bit_Value intra procedural steps have to be invalidate...
const Wrefcount< const DesignFlowManager > design_flow_manager
The design flow manager.
Classes specification of the tree_node data structures.
tree_nodeRef GetFunctionType(const tree_nodeConstRef &returnType, const std::vector< tree_nodeConstRef > &argsT) const
Create a function type.
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
This file collects some utility functions and macros.
Class defining some useful functions to create tree nodes and to manipulate the tree manager...
#define DEBUG_LEVEL_NONE
no debugging print is performed.
void ComputeRelationships(DesignFlowStepSet &relationships, const DesignFlowStep::RelationshipType relationship_type) override
Compute the relationships of a step with other steps.
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.
~dead_code_eliminationIPA() override
This file collects some utility functions.
std::vector< tree_nodeRef > list_of_args
args field holds a chain of parm_decl nodes for the arguments.
dead_code_eliminationIPA(const application_managerRef AM, const DesignFlowManagerConstRef dfm, const ParameterConstRef parameters)
refcount< T > lock() const
void ComputeRelationships(DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override
Compute the relationships of a step with other steps.
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.
bool HasToBeExecuted() const override
Check if this step has actually to be executed.
tree_nodeRef type
type field holds the data type of the object, when relevant.
this class is used to manage the command-line or XML options.
std::string container_to_string(_InputIt first, _InputIt last, const std::string &separator, bool trim_empty=true)
int debug_level
The debug level.
#define GET_INDEX_CONST_NODE(t)
refcount< const var_pp_functor > var_pp_functorConstRef
static tree_nodeConstRef GetFunctionReturnType(const tree_nodeConstRef &function, bool void_as_null=true)
Return the return type of a function.
bool signature_opt(const tree_managerRef &TM, function_decl *fd, unsigned int function_id, const CustomOrderedSet< unsigned int > &rFunctions)
#define NULL_VERTEX
null vertex definition
This class creates a layer to add nodes and to manipulate the tree_nodes manager. ...
Class specification of the manager of the tree structures extracted from the raw file.
A brief description of the C++ Header File.
static const std::string ComputeSignature(const FrontendFlowStepType frontend_flow_step_type, const unsigned int function_id)
Compute the signature of a function frontend flow step.
boost::graph_traits< graph >::edge_descriptor EdgeDescriptor
edge definition.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...