92 unsigned int _function_id,
const DesignFlowManagerConstRef _design_flow_manager)
94 TreeM(_AppM->get_tree_manager()),
107 switch(relationship_type)
111 relationships.insert(std::make_pair(COMPUTE_IMPLICIT_CALLS,
SAME_FUNCTION));
112 relationships.insert(std::make_pair(FIX_STRUCTS_PASSED_BY_VALUE,
SAME_FUNCTION));
113 relationships.insert(std::make_pair(FUNCTION_CALL_TYPE_CLEANUP,
SAME_FUNCTION));
114 relationships.insert(std::make_pair(IR_LOWERING,
SAME_FUNCTION));
115 relationships.insert(std::make_pair(USE_COUNTING,
SAME_FUNCTION));
126 relationships.insert(std::make_pair(FUNCTION_CALL_TYPE_CLEANUP,
SAME_FUNCTION));
135 return relationships;
144 const auto fd = GetPointerS<function_decl>(curr_tn);
145 const auto sl = GetPointerS<statement_list>(
GET_NODE(fd->body));
147 THROW_ASSERT(GetPointer<const HLS_manager>(
AppM)->get_HLS_device(),
"unexpected condition");
148 const auto hls_d = GetPointer<const HLS_manager>(
AppM)->get_HLS_device();
149 if(fname !=
"__umul64" && fname !=
"__mul64")
151 if((hls_d->has_parameter(
"use_soft_64_mul") && hls_d->get_parameter<
size_t>(
"use_soft_64_mul")) ||
152 (
parameters->isOption(OPT_DSP_fracturing) &&
parameters->getOption<std::string>(OPT_DSP_fracturing) ==
"16") ||
153 (
parameters->isOption(OPT_DSP_fracturing) &&
parameters->getOption<std::string>(OPT_DSP_fracturing) ==
"32"))
158 if(fname !=
"__umul32" && fname !=
"__mul32")
160 if((hls_d->has_parameter(
"use_soft_32_mul") && hls_d->get_parameter<
size_t>(
"use_soft_32_mul")) ||
161 (
parameters->isOption(OPT_DSP_fracturing) &&
parameters->getOption<std::string>(OPT_DSP_fracturing) ==
"16"))
167 bool modified =
false;
168 for(
const auto& idx_bb : sl->list_of_bloc)
170 const auto& BB = idx_bb.second;
171 for(
const auto& stmt : BB->CGetStmtList())
193 bool modified =
false;
195 const auto get_current_srcp = [curr_tn]() -> std::string {
196 const auto srcp_tn = GetPointer<const srcp>(curr_tn);
199 return srcp_tn->include_name +
":" +
STR(srcp_tn->line_number) +
":" +
STR(srcp_tn->column_number);
206 case aggr_init_expr_K:
210 case gimple_assign_K:
212 const auto gm = GetPointerS<gimple_assign>(curr_tn);
228 current = GetPointer<tree_list>(
GET_NODE(current))->chan;
234 const auto ue = GetPointerS<unary_expr>(curr_tn);
240 const auto be = GetPointerS<binary_expr>(curr_tn);
241 const auto be_type = be->get_kind();
245 if(be_type == exact_div_expr_K || be_type == trunc_div_expr_K || be_type == trunc_mod_expr_K)
250 const auto bitsize =
std::max(bitsize0, bitsize1);
252 const auto div_by_constant = [&]() {
256 if((cst_val & (cst_val - 1)) == 0)
264 if(!div_by_constant &&
GET_CONST_NODE(expr_type)->get_kind() == integer_type_K &&
265 (bitsize == 32 || bitsize == 64))
267 const auto fu_suffix = be_type == trunc_mod_expr_K ?
"mod" :
"div";
268 const auto bitsize_str = bitsize == 32 ?
"s" :
"d";
270 const std::string fu_name =
"__" +
STR(unsignedp ?
"u" :
"") + fu_suffix + bitsize_str +
"i3" +
271 ((bitsize0 == 64 && bitsize1 == 32) ?
"6432" :
"");
272 const auto called_function =
TreeM->GetFunction(fu_name);
273 THROW_ASSERT(called_function,
"The library miss this function " + fu_name);
275 "inconsistent behavioral helper");
277 const std::vector<tree_nodeRef>
args = {be->op0, be->op1};
278 const auto ce = tree_man->
CreateCallExpr(called_function, args, get_current_srcp());
280 TreeM->ReplaceTreeNode(current_statement, current_tree_node, ce);
288 else if(be_type == frem_expr_K)
293 const std::string fu_name = bitsize == 32 ?
"fmodf" :
"fmod";
294 const auto called_function =
TreeM->GetFunction(fu_name);
295 THROW_ASSERT(called_function,
"Add option -lm to the command line for frem/fmod");
296 THROW_ASSERT(
TreeM->get_implementation_node(called_function->index) != 0,
"inconsistent behavioral helper");
298 const std::vector<tree_nodeRef>
args = {be->op0, be->op1};
299 const auto ce = tree_man->
CreateCallExpr(called_function, args, get_current_srcp());
301 TreeM->ReplaceTreeNode(current_statement, current_tree_node, ce);
308 else if(be_type == mult_expr_K)
313 const auto bitsize =
std::max(bitsize0, bitsize1);
314 auto doTransf =
false;
319 fname = unsignedp ?
"__umul64" :
"__mul64";
325 fname = unsignedp ?
"__umul32" :
"__mul32";
330 const auto called_function =
TreeM->GetFunction(fname);
331 THROW_ASSERT(called_function,
"The library miss this function " + fname);
332 THROW_ASSERT(
AppM->get_tree_manager()->get_implementation_node(called_function->index) != 0,
333 "inconsistent behavioral helper");
335 const std::vector<tree_nodeRef>
args = {be->op0, be->op1};
336 const auto ce = tree_man->
CreateCallExpr(called_function, args, get_current_srcp());
338 TreeM->ReplaceTreeNode(current_statement, current_tree_node, ce);
350 const ternary_expr* te = GetPointer<ternary_expr>(curr_tn);
382 const constructor* co = GetPointer<constructor>(curr_tn);
396 case gimple_switch_K:
397 case gimple_multi_way_if_K:
398 case gimple_return_K:
403 case template_decl_K:
404 case target_mem_ref_K:
405 case target_mem_ref461_K:
411 case function_decl_K:
417 case case_label_expr_K:
422 case gimple_pragma_K:
430 case gimple_predict_K:
432 case identifier_node_K:
434 case namespace_decl_K:
436 case placeholder_expr_K:
437 case statement_list_K:
438 case translation_unit_decl_K:
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
#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.
Step successfully executed.
#define CASE_BINARY_EXPRESSION
This macro collects all case labels for binary_expr objects.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
bool recursive_examinate(const tree_nodeRef ¤t_tree_node, const tree_nodeRef ¤t_statement, const tree_manipulationRef tree_man)
Recursive examine tree node.
Definition of the class representing a generic C application.
std::vector< std::pair< tree_nodeRef, tree_nodeRef > > list_of_idx_valu
store the list initializers: <index, value>
hls_div_cg_ext(const ParameterConstRef _parameters, const application_managerRef AppM, unsigned int _function_id, const DesignFlowManagerConstRef design_flow_manager)
Constructor.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
mathematical utility function not provided by standard libraries
exceptions managed by PandA
tree_nodeRef op2
The third operand of the ternary expression.
tree_nodeRef op1
The second operand of the Quaternary expression.
A simple interface to token object of the raw files.
#define GET_INDEX_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
struct definition of the ternary node structures.
This class provides methods to build a basic blocks graph.
Data structure describing a basic block at tree level.
Constructor: return an aggregate value made from specified components.
redefinition of map to manage ordered/unordered structures
const tree_managerRef TreeM
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.
tree_nodeRef op3
The fourth operand of the Quaternary expression.
std::string ToString(ActorGraphBackend_Type actor_graph_backend_type)
Header include.
static void addCallPointAndExpand(CustomUnorderedSet< unsigned int > &AV, const application_managerRef AM, unsigned int caller_id, unsigned int called_id, unsigned int call_id, enum FunctionEdgeInfo::CallType call_type, int DL)
static bool IsUnsignedIntegerType(const tree_nodeConstRef &type)
Return true if the treenode is of unsigned integer type.
Step that extends the call graph with the division and modulus function calls where appropriate...
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
virtual std::string get_kind_text() const =0
Virtual function returning the name of the actual class.
DesignFlowStep_Status InternalExec() override
Fixes the var_decl duplication.
struct definition of the Quaternary node structures.
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
Base class for step of design flow.
#define CASE_QUATERNARY_EXPRESSION
This macro collects all case labels for quaternary_expr objects.
#define CASE_UNARY_EXPRESSION
This macro collects all case labels for unary_expr objects.
Classes to describe design flow graph.
Target must be reexecuted.
CustomUnorderedSet< unsigned int > already_visited
Already visited tree node (used to avoid infinite recursion)
#define GET_CONST_NODE(t)
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.
~hls_div_cg_ext() override
Destructor.
Class defining some useful functions to create tree nodes and to manipulate the tree manager...
#define DEBUG_LEVEL_NONE
no debugging print is performed.
#define CASE_TYPE_NODES
This macro collects all case labels for type objects.
This file collects some utility functions.
tree_nodeRef CreateCallExpr(const tree_nodeConstRef &called_function, const std::vector< tree_nodeRef > &args, const std::string &srcp) const
Create a call_expr.
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.
Class specification of the basic_block structure.
tree_nodeRef op0
The first operand of the Quaternary expression.
tree_nodeRef op0
The first operand of the ternary expression.
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.
#define THROW_ERROR_CODE(code, str_expr)
helper function used to throw an error with a code error
Classes specification of the tree_node data structures not present in the gcc.
this class is used to manage the command-line or XML options.
#define CASE_CPP_NODES
This macro collects all case labels for cpp nodes.
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.
static std::string GetFunctionName(const tree_managerConstRef &TM, const tree_nodeConstRef &decl)
Return the name of the function.
static integer_cst_t GetConstValue(const tree_nodeConstRef &tn, bool is_signed=true)
Get value from integer constant.
int debug_level
The debug level.
#define GET_INDEX_CONST_NODE(t)
tree_nodeRef op1
The second operand of the ternary expression.
This class creates a layer to add nodes and to manipulate the tree_nodes manager. ...
This class models the application of a analysis to all the functions of an application.
#define CASE_TERNARY_EXPRESSION
This macro collects all case labels for ternary_expr objects.
tree_nodeRef op2
The third operand of the Quaternary expression.
Class specification of the manager of the tree structures extracted from the raw file.
HLS specialization of generic_device.
A brief description of the C++ Header File.
const FunctionBehaviorRef function_behavior
The function behavior of the function to be analyzed.
#define CASE_PRAGMA_NODES
This macro collects all case labels for pragma objects.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...