PandA-2024.02
FixStructsPassedByValue.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) 2004-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  */
40 
41 #include "Parameter.hpp"
42 #include "application_manager.hpp"
43 #include "behavioral_helper.hpp"
44 #include "call_graph_manager.hpp"
45 #include "dbgPrintHelper.hpp"
46 #include "function_behavior.hpp"
47 #include "hls_manager.hpp"
48 #include "op_graph.hpp"
49 #include "string_manipulation.hpp"
50 #include "tree_basic_block.hpp"
51 #include "tree_helper.hpp"
52 #include "tree_manager.hpp"
53 #include "tree_manipulation.hpp"
54 #include "tree_node.hpp"
55 #include "tree_reindex.hpp"
56 
58  unsigned int fun_id, const DesignFlowManagerConstRef dfm)
59  : FunctionFrontendFlowStep(AM, fun_id, FIX_STRUCTS_PASSED_BY_VALUE, dfm, params)
60 {
61  debug_level = parameters->get_class_debug_level(GET_CLASS(*this), DEBUG_LEVEL_NONE);
62 }
63 
65 
66 static bool cannot_have_struct_parameters(const function_decl* const fd, const function_type* const ft)
67 {
68  auto p_type_head = ft->prms;
69  if(p_type_head && GetPointer<const void_type>(GET_CONST_NODE(p_type_head)))
70  {
71  // if the function_type takes void argument there's nothing to do
72  THROW_ASSERT(fd->list_of_args.empty(), "function " + tree_helper::GetMangledFunctionName(fd) +
73  " has void parameter type but has a parm_decl " +
74  STR(GET_NODE(fd->list_of_args.front())));
75  return true;
76  }
77  if(p_type_head && fd->list_of_args.empty())
78  {
79  while(p_type_head)
80  {
81  const auto* p = GetPointerS<const tree_list>(GET_CONST_NODE(p_type_head));
82  p_type_head = p->chan;
83  /*
84  * from what I figured out from gcc, if the function_decl has no
85  * no parm_decl this means that there is no explicit declaration
86  * of that function in the source code. in principle it should
87  * not even compile, but this is not true for certain builtin
88  * functions like exit() or others. in these cases, even if the
89  * function is not declared and just used, gcc compiles and maps
90  * it to its own builtins and infers its own function_type that
91  * can have types for parameters (p_type_head is not null).
92  * anyways in all these cases it should never happen that these
93  * kinds of functions take structs passed by values as arguments.
94  * hence we can safely 'continue' without worries.
95  * if the assertion fails some of these assumptions are wrong
96  */
98  "function " + tree_helper::GetMangledFunctionName(fd) +
99  " has no parm_decl but in its function_type it takes a struct type " + STR(p->valu));
100  }
101  return true;
102  }
103  return false;
104 }
105 
108 {
110  switch(relationship_type)
111  {
113  {
114  relationships.insert(std::make_pair(BLOCK_FIX, SAME_FUNCTION));
115  relationships.insert(std::make_pair(STRING_CST_FIX, WHOLE_APPLICATION));
116  relationships.insert(std::make_pair(FIX_STRUCTS_PASSED_BY_VALUE, CALLING_FUNCTIONS));
117  relationships.insert(std::make_pair(REBUILD_INITIALIZATION, CALLING_FUNCTIONS));
118  break;
119  }
121  {
122  break;
123  }
125  {
126  break;
127  }
128  default:
129  {
130  THROW_UNREACHABLE("");
131  }
132  }
133  return relationships;
134 }
135 
137 {
138  bool changed = false;
139  const auto TM = AppM->get_tree_manager();
140  const auto tree_man = tree_manipulationRef(new tree_manipulation(TM, parameters, AppM));
141  const auto tn = TM->GetTreeNode(function_id);
142  const auto fd = GetPointer<function_decl>(tn);
143  THROW_ASSERT(fd && fd->body, "Node " + STR(tn) + "is not a function_decl or has no body");
144  const auto sl = GetPointer<const statement_list>(GET_CONST_NODE(fd->body));
145  THROW_ASSERT(sl, "Body is not a statement_list");
146  const auto fname = function_behavior->GetBehavioralHelper()->GetMangledFunctionName();
147  const auto ftype = GetPointer<const function_type>(GET_CONST_NODE(tree_helper::CGetType(tn)));
148  THROW_ASSERT(!ftype->varargs_flag, "function " + fname + " is varargs");
149  const auto HLSMgr = GetPointer<HLS_manager>(AppM);
150  const auto func_arch = HLSMgr ? HLSMgr->module_arch->GetArchitecture(fname) : nullptr;
151  // fix declaration
152  if(!cannot_have_struct_parameters(fd, ftype))
153  {
154  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Fixing declaration of function " + fname);
155  THROW_ASSERT(tn->get_kind() != tree_reindex_K, "function declaration " + STR(tn) + " is a tree_reindex");
156  unsigned int param_n = 0;
157  auto p_decl_it = fd->list_of_args.begin();
158  auto p_type_head = ftype->prms;
159  const auto has_param_types = static_cast<bool>(p_type_head);
160  for(; p_decl_it != fd->list_of_args.cend(); p_decl_it++, param_n++)
161  {
162  const auto p_decl = *p_decl_it;
163  const auto p_type = tree_helper::CGetType(p_decl);
165  "-->Analyzing parameter " + STR(p_decl) + " with type " + STR(p_type));
166  THROW_ASSERT(has_param_types == static_cast<bool>(p_type_head),
167  "function " + fname + " has " + STR(fd->list_of_args.size()) + " parameters, but argument " +
168  STR(param_n) + " (" + STR(p_decl) +
169  ") has not a corresponding underlying type in function_type");
170 
172  {
174  "function " + fname + " has a struct parameter: " + STR(p_decl) + " with type " +
175  STR(p_type));
176  // initialize some general stuff useful later
177  const auto pd = GetPointerS<const parm_decl>(GET_CONST_NODE(p_decl));
178  const auto srcp = pd->include_name + ":" + STR(pd->line_number) + ":" + STR(pd->column_number);
179  const auto original_param_name =
180  pd->name ? GetPointerS<const identifier_node>(GET_CONST_NODE(pd->name))->strg : "";
181 
182  auto ptd_type_size = tree_helper::Size(p_type);
183  if(ptd_type_size % 8)
184  {
185  ptd_type_size += 8;
186  }
187  ptd_type_size /= 8;
188 
189  // create new var_decl
190  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Creating new local var_decl");
191  const auto local_var_name = "bambu_artificial_local_param_copy_" + original_param_name;
192  const auto local_var_identifier = tree_man->create_identifier_node(local_var_name);
193  const auto new_local_var_decl = tree_man->create_var_decl(
194  local_var_identifier, p_type, pd->scpe, pd->size, tree_nodeRef(), tree_nodeRef(), srcp,
195  GetPointerS<const type_node>(GET_CONST_NODE(p_type))->algn, pd->used,
196  false); // artificial flag (should be true???)
197  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Created new local var_decl");
198 
199  // substitute var_decl to parm_decl in all the statements of the function
200  {
202  "-->Substituting var_decl " + STR(p_decl) + " to parm_decl " + STR(new_local_var_decl) +
203  " in all statements");
204  for(const auto& block : sl->list_of_bloc)
205  {
206  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Examining BB" + STR(block.first));
207  for(const auto& stmt : block.second->CGetStmtList())
208  {
210  "-->Examining statement " + GET_NODE(stmt)->ToString());
211  TM->ReplaceTreeNode(stmt, p_decl, new_local_var_decl);
213  "<--Examined statement " + GET_NODE(stmt)->ToString());
214  }
215  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Examined BB" + STR(block.first));
216  }
218  "<--Substituted var_decl " + STR(p_decl) + " to parm_decl " + STR(new_local_var_decl) +
219  " in all statements");
220  }
221 
222  // create pointer type for the new pointer-to-struct parameter
223  const auto ptr_type = tree_man->GetPointerType(p_type);
224 
225  // substitute parameter type in function_type if necessary
226  if(has_param_types)
227  {
229  "-->Substituting type of parameter " + STR(p_decl));
231  "---Changing type from " + STR(p_type) + " to " + STR(GET_NODE(ptr_type)));
232  GetPointerS<tree_list>(GET_NODE(p_type_head))->valu = ptr_type;
234  "<--Substituted type of parameter " + STR(p_decl));
235  }
236 
237  // create and substitute new pointer-to-struct parm_decl in function_decl
238  {
239  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Substituting parm_decl of " + STR(p_decl));
240  const auto ptr_p_name = "bambu_artificial_ptr_param_" + original_param_name;
241  const auto ptr_p_identifier = tree_man->create_identifier_node(ptr_p_name);
242  const auto ptr_p_decl = tree_man->create_parm_decl(ptr_p_identifier, ptr_type, pd->scpe, ptr_type,
243  tree_nodeRef(), tree_nodeRef(), srcp, 1, false, true);
244  if(func_arch)
245  {
246  const auto parm_it = func_arch->parms.find(original_param_name);
247  if(parm_it != func_arch->parms.end())
248  {
249  func_arch->parms[ptr_p_name] = parm_it->second;
250  func_arch->parms[ptr_p_name].at(FunctionArchitecture::parm_port) = ptr_p_name;
251  func_arch->parms.erase(parm_it);
252 
253  // NOTE: should also update HLS_manager::design_interface_io, but passed-by-value parameters cannot
254  // have associated I/O operations
255  }
256  }
258  "---Changing parm_decl from " + STR(p_decl) + " to " + STR(GET_NODE(ptr_p_decl)));
259  *p_decl_it = ptr_p_decl;
261  "<--Substituted parm_decl of " + STR(p_decl) + " with " + STR(GET_NODE(*p_decl_it)));
262  }
263 
264  /*
265  * find the first basic block of the function. it is the
266  * successor of the entry basic block that is not the exit basic
267  * block.
268  */
269  unsigned int bb_index = BB_ENTRY;
270  {
271  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Selecting first basic block of " + fname);
272  const auto entry_block = sl->list_of_bloc.at(BB_ENTRY);
273  const auto succ_blocks = entry_block->list_of_succ;
274  THROW_ASSERT(succ_blocks.size() == 1, "entry basic block of function " + fname + " has " +
275  STR(succ_blocks.size()) + " successors");
276  bb_index = *(succ_blocks.begin());
277  THROW_ASSERT(bb_index != BB_ENTRY and bb_index != BB_EXIT,
278  "first basic block of function " + fname + " not found");
280  "<--Selected first basic block of " + fname + ": " + STR(bb_index));
281  }
282  const auto first_block = sl->list_of_bloc.at(bb_index);
283 
284  // create the call to memcpy
285  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Creating new call to memcpy");
286  const auto memcpy_function = TM->GetFunction(MEMCPY);
287  THROW_ASSERT(AppM->get_tree_manager()->get_implementation_node(memcpy_function->index) != 0,
288  "inconsistent behavioral helper");
289  const auto formal_type_node = tree_helper::GetFormalIth(memcpy_function, 2);
290  const std::vector<tree_nodeRef> args = {
291  // & new_local_var_decl
292  tree_man->CreateAddrExpr(GET_NODE(new_local_var_decl), srcp),
293  // src is the new pointer-to-struct parm_decl
294  tree_man->create_ssa_name(*p_decl_it, ptr_type, tree_nodeRef(), tree_nodeRef()),
295  // sizeof(var_decl)
296  TM->CreateUniqueIntegerCst(static_cast<long long>(ptd_type_size), formal_type_node)};
297  const auto gimple_call_memcpy = tree_man->create_gimple_call(memcpy_function, args, function_id, srcp);
298  auto gn = GetPointer<gimple_node>(GET_NODE(gimple_call_memcpy));
299  /*
300  * the call is artificial. this is necessary because this memcpy
301  * should not be moved around by code motion or other steps. this
302  * call should always be performed as first operation of the
303  * function, before any other. this could be achieved in theory
304  * adding vdefs/vuses to force dependencies, but it becomes
305  * tricky to get it right when the address of the struct passed
306  * by value is taken, stored and used somewhere else. instead we
307  * set the call to artificial so that the other passes will not
308  * move it around
309  */
310  gn->artificial = true;
312  "<--Created new call to memcpy: " + STR(GET_NODE(gimple_call_memcpy)));
313  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Updating basic block");
314  first_block->PushFront(gimple_call_memcpy, AppM);
315  changed = true;
316  }
317 
318  if(has_param_types)
319  {
320  p_type_head = GetPointer<const tree_list>(GET_CONST_NODE(p_type_head))->chan;
321  }
322 
324  "<--Analyzed parameter " + STR(p_decl) + " with type " + STR(p_type));
325  }
326  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Fixed declaration of function " + fname);
327  }
328  // fix calls to other functions that accept structs passed by value as parameters
329  {
330  for(const auto& block : sl->list_of_bloc)
331  {
332  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Examining BB" + STR(block.first));
333  for(const auto& stmt : block.second->CGetStmtList())
334  {
336  "-->Examining statement " + GET_NODE(stmt)->ToString());
337  const auto gn = GetPointer<const gimple_node>(GET_CONST_NODE(stmt));
338  const auto srcp_default = gn->include_name + ":" + STR(gn->line_number) + ":" + STR(gn->column_number);
339  const auto stmt_kind = GET_CONST_NODE(stmt)->get_kind();
340  if(stmt_kind == gimple_assign_K or stmt_kind == gimple_call_K)
341  {
343  tree_nodeConstRef called_node;
344  std::vector<tree_nodeRef>* arguments;
345  unsigned int call_tree_node_id = 0;
346 
347  if(stmt_kind == gimple_assign_K)
348  {
349  const auto ga = GetPointer<const gimple_assign>(GET_CONST_NODE(stmt));
350  if(GET_CONST_NODE(ga->op1)->get_kind() != call_expr_K &&
351  GET_CONST_NODE(ga->op1)->get_kind() != aggr_init_expr_K)
352  {
353  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--RHS is not a call_expr");
354  continue;
355  }
356 
357  auto ce = GetPointer<call_expr>(GET_NODE(ga->op1));
358  called_node = GET_NODE(ce->fn);
359  arguments = &ce->args;
360  call_tree_node_id = ce->index;
361  }
362  else // GET_NODE(stmt)->get_kind() == gimple_call_K
363  {
364  auto gc = GetPointer<gimple_call>(GET_NODE(stmt));
365  called_node = GET_NODE(gc->fn);
366  arguments = &gc->args;
367  call_tree_node_id = gc->index;
368  }
369  if(!called_node)
370  {
371  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Not a gimple_call nor a call_expr");
372  continue;
373  }
374  if(called_node->get_kind() == ssa_name_K)
375  {
376  const auto called_ssa_name = STR(called_node);
378  "-->Indirect function call through ssa " + called_ssa_name);
379  const auto f_ptr = GetPointer<const pointer_type>(GET_CONST_NODE(tree_helper::CGetType(called_node)));
380  THROW_ASSERT(f_ptr, "");
381  const auto ft = GetPointer<const function_type>(GET_CONST_NODE(f_ptr->ptd));
382  THROW_ASSERT(ft, "");
383  unsigned int param_n = 0;
384  auto p_type_head = ft->prms;
385  while(p_type_head)
386  {
387  const auto* const p = GetPointer<const tree_list>(GET_CONST_NODE(p_type_head));
389  "-->Analyzing parameter type" + STR(GET_CONST_NODE(p->valu)));
390  if(tree_helper::IsUnionType(p->valu) || tree_helper::IsStructType(p->valu))
391  {
393  "function ssa " + called_ssa_name +
394  " has a struct parameter with type: " + STR(GET_CONST_NODE(p->valu)));
395  if(ft->varargs_flag)
396  {
397  THROW_ERROR("op: " + STR(stmt) + " id: " + STR(call_tree_node_id) +
398  " calls function pointer " + called_ssa_name +
399  ": varargs function taking structs argument not supported");
400  }
401  const auto& actual_argument_node = arguments->at(param_n);
403  "---Actual argument " + STR(actual_argument_node) + " is " +
404  GET_CONST_NODE(actual_argument_node)->get_kind_text());
405  THROW_ASSERT(tree_helper::IsUnionType(actual_argument_node) ||
406  tree_helper::IsStructType(actual_argument_node),
407  "op: " + STR(stmt) + " id: " + STR(call_tree_node_id) + " passes argument " +
408  STR(actual_argument_node) + " to a call to function " + called_ssa_name +
409  " which has a struct/union parameter with type: " +
410  STR(GET_CONST_NODE(p->valu)) + " but " + STR(actual_argument_node) + " is a " +
411  STR(tree_helper::CGetType(actual_argument_node)));
412  auto new_ga_node =
413  tree_man->CreateGimpleAssignAddrExpr(actual_argument_node, function_id, srcp_default);
415  "---Changing parameter: creating pointer " + STR(GET_NODE(new_ga_node)));
416  block.second->PushBefore(new_ga_node, stmt, AppM);
417  const auto new_ga = GetPointer<const gimple_assign>(GET_CONST_NODE(new_ga_node));
418  arguments->at(param_n) = new_ga->op0;
419  changed = true;
420  }
422  "<--Analyzed parameter type" + STR(GET_CONST_NODE(p->valu)));
423  p_type_head = p->chan;
424  }
426  "<--Analyzed indirect call to ssa " + called_ssa_name);
428  "<--Examined statement " + GET_NODE(stmt)->ToString());
429  continue;
430  }
431  THROW_ASSERT(called_node->get_kind() == addr_expr_K,
432  "called_node = " + STR(called_node) + " is a " + called_node->get_kind_text());
433  const auto ae = GetPointer<const addr_expr>(called_node);
434  const auto called_fu_decl_node = GET_NODE(ae->op);
435  THROW_ASSERT(called_fu_decl_node->get_kind() == function_decl_K,
436  "node " + STR(called_fu_decl_node) + " is not function_decl but " +
437  called_fu_decl_node->get_kind_text());
438  const auto called_fd = GetPointer<const function_decl>(called_fu_decl_node);
439  const auto called_fname = tree_helper::GetMangledFunctionName(called_fd);
440  const auto called_ftype =
441  GetPointer<const function_type>(GET_CONST_NODE(tree_helper::CGetType(called_fu_decl_node)));
442  /*
443  * if there is a call to a function without body we don't turn
444  * structs parameters into pointers, because we would also need
445  * to change the body of the function to alter how the parameter
446  * is used.
447  */
448  if(!fd->body)
449  {
451  "<--Function " + called_fname + " is varargs but has no body");
452  continue;
453  }
454  if(cannot_have_struct_parameters(called_fd, called_ftype))
455  {
456  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Cannot have struct parameters");
457  continue;
458  }
459  auto p_type_head = called_ftype->prms;
460  const auto has_param_types = static_cast<bool>(p_type_head);
461  unsigned int param_n = 0;
462  auto p_decl_it = called_fd->list_of_args.begin();
463  for(; p_decl_it != called_fd->list_of_args.cend(); p_decl_it++, param_n++)
464  {
465  const auto& p_decl = *p_decl_it;
466  const auto p_type = tree_helper::CGetType(p_decl);
468  "-->Analyzing parameter " + STR(p_decl) + " with type " + STR(p_type));
469 
470  THROW_ASSERT(static_cast<bool>(has_param_types) == static_cast<bool>(p_type_head),
471  "function " + called_fname + " has " + STR(called_fd->list_of_args.size()) +
472  " parameters, but argument " + STR(param_n) + " (" + STR(p_decl) +
473  ") has not a corresponding underlying type in function_type");
474  if(has_param_types)
475  {
476  p_type_head = GetPointer<const tree_list>(GET_CONST_NODE(p_type_head))->chan;
477  }
478 
480  {
482  "function " + called_fname + " has a struct parameter: " + STR(p_decl) +
483  " with type " + STR(p_type));
484  if(called_ftype->varargs_flag)
485  {
486  THROW_ERROR("op: " + STR(stmt) + " id: " + STR(call_tree_node_id) + " calls function " +
487  called_fname + ": varargs function taking structs argument not supported");
488  }
489  const auto& actual_argument_node = arguments->at(param_n);
491  "---Actual argument " + STR(actual_argument_node) + " is " +
492  GET_CONST_NODE(actual_argument_node)->get_kind_text());
493  THROW_ASSERT(tree_helper::IsUnionType(actual_argument_node) ||
494  tree_helper::IsStructType(actual_argument_node),
495  "op: " + STR(stmt) + " id: " + STR(call_tree_node_id) + " passes argument " +
496  STR(actual_argument_node) + " to a call to function " + called_fname +
497  " which has a struct/union parameter: " + STR(p_decl) + " but " +
498  STR(actual_argument_node) + " is a " +
499  STR(tree_helper::CGetType(actual_argument_node)));
500  const auto new_ga_node =
501  tree_man->CreateGimpleAssignAddrExpr(actual_argument_node, function_id, srcp_default);
503  "---Changing parameter: creating pointer " + STR(GET_NODE(new_ga_node)));
504  block.second->PushBefore(new_ga_node, stmt, AppM);
505  const auto* new_ga = GetPointer<const gimple_assign>(GET_CONST_NODE(new_ga_node));
506  arguments->at(param_n) = new_ga->op0;
507  changed = true;
508  }
510  "<--Analyzed parameter " + STR(p_decl) + " with type " + STR(p_type));
511  }
512  }
514  "<--Examined statement " + GET_NODE(stmt)->ToString());
515  }
516  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Examined BB" + STR(block.first));
517  }
518  }
519 
520  if(changed)
521  {
522  function_behavior->UpdateBBVersion();
524  }
526 }
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
Definition: tree_node.hpp:343
static tree_nodeConstRef GetFormalIth(const tree_nodeConstRef &obj, unsigned int parm_index)
Return the type of the ith formal parameter in case index_obj is a call_expr.
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
static bool IsUnionType(const tree_nodeConstRef &type)
Return if treenode is an union.
~FixStructsPassedByValue() override
Destructor.
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;.
#define MEMCPY
constant string identifying the operation performed when two objects are memcopied.
Definition: op_graph.hpp:310
File containing functions and utilities to support the printing of debug messagges.
Step successfully executed.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
#define BB_EXIT
constant identifying the basic block node of type exit
Definition of the class representing a generic C application.
refcount< tree_manipulation > tree_manipulationRef
struct definition of the source position.
Definition: tree_node.hpp:832
RelationshipType
The relationship type.
struct definition of the function_decl tree node.
Definition: tree_node.hpp:2759
Source must be executed to satisfy target.
static std::string GetString(const enum kind k)
Given a kind, return the corresponding string.
Definition: tree_node.cpp:120
tree_nodeRef prms
prms field is a list of types of arguments expected, this list is made of tree_list nodes...
Definition: tree_node.hpp:2981
FixStructsPassedByValue(const ParameterConstRef params, const application_managerRef AM, unsigned int fun_id, const DesignFlowManagerConstRef dfm)
Constructor.
struct definition of the function_type tree node.
Definition: tree_node.hpp:2960
Data structure describing a basic block at tree level.
std::string include_name
include_name is a filename string, this can be the location of a reference, if no definition has been...
Definition: tree_node.hpp:839
static std::string GetMangledFunctionName(const function_decl *fd)
Return the mangled function name.
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
Definition: exceptions.hpp:292
virtual std::string get_kind_text() const =0
Virtual function returning the name of the actual class.
static unsigned long long Size(const tree_nodeConstRef &tn)
Return the size of a tree object.
#define BB_ENTRY
constant identifying the basic block node of type entry
#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.
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 THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
This struct specifies the block node.
Definition: tree_node.hpp:1820
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.
Definition: tree_node.hpp:2841
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.
DesignFlowStep_Status InternalExec() override
Execute the step.
Data structures used in operations graph.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
static tree_nodeConstRef CGetType(const tree_nodeConstRef &node)
Return the treenode of the type of node.
static bool IsStructType(const tree_nodeConstRef &type)
Return true if treenode is a record.
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.
this class is used to manage the command-line or XML options.
static bool cannot_have_struct_parameters(const function_decl *const fd, const function_type *const ft)
refcount< tree_node > tree_nodeRef
RefCount type definition of the tree_node class structure.
Definition: tree_node.hpp:212
Wrapper to call graph.
int debug_level
The debug level.
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.
const FunctionBehaviorRef function_behavior
The function behavior of the function to be analyzed.
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