61 const DesignFlowManagerConstRef DFM)
102 const auto TM =
AppM->get_tree_manager();
103 const auto fd = GetPointer<const function_decl>(TM->CGetTreeNode(
function_id));
104 THROW_ASSERT(fd && fd->body,
"Node is not a function or it hasn't a body");
105 const auto sl = GetPointerS<statement_list>(
GET_NODE(fd->body));
108 const auto isHardwareCall = [&](
const tree_nodeRef& expr) ->
bool {
111 if(expr->get_kind() == gimple_call_K)
113 const auto GC = GetPointerS<gimple_call>(expr);
118 else if(expr->get_kind() == gimple_assign_K)
120 const auto GA = GetPointerS<const gimple_assign>(expr);
124 const auto CE = GetPointerS<const call_expr>(
GET_CONST_NODE(GA->op1));
137 const auto FDPtr = GetPointerS<const function_decl>(
GET_CONST_NODE(FD));
138 result = FDPtr->hwcall_flag;
141 const auto cmdArg =
parameters->getOption<std::string>(OPT_additional_top);
142 const auto additionalTops =
SplitString(cmdArg,
",");
144 result |= std::find(additionalTops.begin(), additionalTops.end(), name) != additionalTops.end();
157 for(
const auto&
block :
sl->list_of_bloc)
159 const auto list_of_stmt =
block.second->CGetStmtList();
160 auto stmt = list_of_stmt.begin();
161 while(stmt != list_of_stmt.end())
164 const auto& cur_stmt = *std::prev(stmt);
165 if(isHardwareCall(
GET_NODE(cur_stmt)))
179 const auto stmt_kind =
GET_NODE(stmt)->get_kind();
180 const auto TM =
AppM->get_tree_manager();
185 const auto vararg_list_idx = TM->new_tree_node_id();
186 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> attr_map;
188 TM->create_tree_node(vararg_list_idx, tree_list_K, attr_map);
191 const auto ftype_idx = TM->new_tree_node_id();
195 const auto funTypeSize = TM->CreateUniqueIntegerCst(8, IRman->GetSignedIntegerType());
198 TM->create_tree_node(ftype_idx, function_type_K, attr_map);
210 const auto gn = GetPointerS<gimple_node>(
GET_NODE(stmt));
211 const auto srcp_str = gn->include_name +
":" +
STR(gn->line_number) +
":" +
STR(gn->column_number);
213 const auto builtin_stmt_idx = TM->new_tree_node_id();
215 const auto addr_expr_idx = TM->new_tree_node_id();
216 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> attr_map;
221 TM->create_tree_node(addr_expr_idx, addr_expr_K, attr_map);
225 if(stmt_kind == gimple_call_K)
227 const auto GC = GetPointerS<const gimple_call>(
GET_NODE(stmt));
230 else if(stmt_kind == gimple_assign_K)
232 const auto GA = GetPointerS<const gimple_assign>(
GET_NODE(stmt));
236 TM->create_tree_node(builtin_stmt_idx, gimple_call_K, attr_map);
239 const auto builtin_stmt = TM->GetTreeReindex(builtin_stmt_idx);
240 const auto builtin_call = GetPointerS<gimple_call>(
GET_NODE(builtin_stmt));
242 if(stmt_kind == gimple_call_K)
244 const auto GC = GetPointerS<gimple_call>(
GET_NODE(stmt));
245 builtin_call->AddArg(GC->fn);
247 const auto has_return = TM->CreateUniqueIntegerCst(0, IRman->GetSignedIntegerType());
248 builtin_call->AddArg(has_return);
250 for(
const auto&
arg : GC->args)
252 builtin_call->AddArg(
arg);
255 builtin_call->memuse = GC->memuse;
256 builtin_call->memdef = GC->memdef;
257 builtin_call->vdef = GC->vdef;
258 builtin_call->vuses = GC->vuses;
259 builtin_call->vovers = GC->vovers;
261 builtin_call->pragmas = GC->pragmas;
262 builtin_call->use_set = GC->use_set;
263 builtin_call->clobbered_set = GC->clobbered_set;
264 builtin_call->scpe = GC->scpe;
265 builtin_call->bb_index = GC->bb_index;
266 builtin_call->include_name = GC->include_name;
267 builtin_call->line_number = GC->line_number;
268 builtin_call->column_number = GC->column_number;
270 else if(stmt_kind == gimple_assign_K)
272 const auto GA = GetPointerS<gimple_assign>(
GET_NODE(stmt));
273 if(
GET_NODE(GA->op1)->get_kind() == call_expr_K ||
GET_NODE(GA->op1)->get_kind() == aggr_init_expr_K)
275 const auto CE = GetPointerS<const call_expr>(
GET_CONST_NODE(GA->op1));
276 builtin_call->AddArg(CE->fn);
278 const auto has_return = TM->CreateUniqueIntegerCst(1, IRman->GetSignedIntegerType());
279 builtin_call->AddArg(has_return);
281 for(
const auto&
arg : CE->args)
283 builtin_call->AddArg(
arg);
286 if(
const auto ssaRet = GetPointer<const ssa_name>(
GET_CONST_NODE(GA->op0)))
289 unsigned int ret_var_algn;
292 ret_var_type = ssaRet->type;
293 ret_var_size = GetPointerS<const type_node>(
GET_CONST_NODE(ssaRet->type))->size;
294 ret_var_algn = GetPointerS<const type_node>(
GET_CONST_NODE(ssaRet->type))->algn;
298 const auto vd = GetPointerS<const var_decl>(
GET_CONST_NODE(ssaRet->var));
299 ret_var_type = vd->type;
300 ret_var_size = GetPointerS<const type_node>(
GET_CONST_NODE(vd->type))->size;
301 ret_var_algn = GetPointerS<const type_node>(
GET_CONST_NODE(vd->type))->algn;
303 retVar = IRman->create_var_decl(
304 IRman->create_identifier_node(
"__return_value"), ret_var_type, GA->scpe, ret_var_size,
nullptr,
nullptr,
305 STR(GA->include_name +
":" +
STR(GA->line_number) +
":" +
STR(GA->column_number)), ret_var_algn, 1,
316 const auto addrExprReturnValue = TM->new_tree_node_id();
318 std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> addrExprReturnValueMap;
323 TM->create_tree_node(addrExprReturnValue, addr_expr_K, addrExprReturnValueMap);
325 builtin_call->AddArg(TM->GetTreeReindex(addrExprReturnValue));
327 builtin_call->memdef = GA->memdef;
328 builtin_call->memuse = GA->memuse;
329 builtin_call->vdef = GA->vdef;
330 builtin_call->vuses = GA->vuses;
331 builtin_call->vovers = GA->vovers;
333 builtin_call->pragmas = GA->pragmas;
334 builtin_call->use_set = GA->use_set;
335 builtin_call->clobbered_set = GA->clobbered_set;
336 builtin_call->scpe = GA->scpe;
337 builtin_call->bb_index = GA->bb_index;
338 builtin_call->include_name = GA->include_name;
339 builtin_call->line_number = GA->line_number;
340 builtin_call->column_number = GA->column_number;
342 GA->memdef =
nullptr;
343 GA->memuse = builtin_call->memdef;
347 THROW_ASSERT(builtin_call->vdef,
"Unexpected condition");
348 GA->AddVuse(builtin_call->vdef);
361 "---Added to BB" +
STR(block->number) +
" " +
STR(builtin_stmt));
362 block->PushBefore(builtin_stmt, stmt,
AppM);
366 "---Removed from BB" +
STR(block->number) +
" " +
STR(stmt));
367 block->RemoveStmt(stmt,
AppM);
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
static unsigned int builtinWaitCallDeclIdx
parser/compiler include
This struct specifies a point-to solution.
refcount< PointToSolution > PointToSolutionRef
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
void buildBuiltinCall(const blocRef &block, const tree_nodeRef &stmt)
#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.
HWCallInjection(const ParameterConstRef Param, const application_managerRef AppM, unsigned int funId, const DesignFlowManagerConstRef DFM)
bool HasToBeExecuted() const override
Check if this step has actually to be executed.
Definition of the class representing a generic C application.
refcount< tree_manipulation > tree_manipulationRef
const std::vector< std::string > SplitString(const std::string &input, const std::string &separators)
Function which splits a string into tokens.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
A simple interface to token object of the raw files.
#define BUILTIN_WAIT_CALL
constant defining the builtin wait call intrinsic function
#define GET_INDEX_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
static std::string print_function_name(const tree_managerConstRef &TM, const function_decl *fd)
Return the name of the function in a string.
Data structure describing a basic block at tree level.
unsigned int bb_version
The version of the basic block intermediate representation on which this step has been applied...
#define TOK(token)
Macro used to convert a token symbol into a treeVocabularyTokenTypes.
#define STR(s)
Macro which performs a lexical_cast to a string.
Auxiliary methods for manipulating string.
#define THROW_UNREACHABLE(str_expr)
helper function used to specify that some points should never be reached
~HWCallInjection() override
Target must be reexecuted.
redefinition of set to manage ordered/unordered structures
#define GET_CONST_NODE(t)
const CustomUnorderedSet< std::pair< FrontendFlowStepType, FunctionRelationship > > ComputeFrontendRelationships(const DesignFlowStep::RelationshipType RT) const override
Return the set of analyses in relationship with 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.
This struct specifies the block node.
This file collects some utility functions.
DesignFlowStep_Status InternalExec() override
Execute the step.
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.
Data structures used in operations graph.
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.
this class is used to manage the command-line or XML options.
int debug_level
The debug level.
#define GET_INDEX_CONST_NODE(t)
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.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...