PandA-2024.02
pragma_analysis.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  */
45 #include "pragma_analysis.hpp"
47 
49 #include "application_manager.hpp"
50 
52 #include "pragma_constants.hpp"
53 
55 #include "token_interface.hpp"
56 
58 #include "PragmaParser.hpp"
59 
61 #include "custom_map.hpp"
62 #include <string>
63 
65 #include "ext_tree_node.hpp"
66 #include "tree_basic_block.hpp"
67 #include "tree_helper.hpp"
68 #include "tree_manager.hpp"
69 #include "tree_node.hpp"
70 #include "tree_reindex.hpp"
71 
72 #include "ext_tree_node.hpp"
73 #include "pragma_manager.hpp"
74 
76 #include "Parameter.hpp"
77 #include "dbgPrintHelper.hpp"
78 #include "exceptions.hpp"
79 #include "string_manipulation.hpp" // for GET_CLASS
80 #include <fstream>
81 
82 PragmaAnalysis::PragmaAnalysis(const application_managerRef _AppM, const DesignFlowManagerConstRef _design_flow_manager,
83  const ParameterConstRef _parameters)
84  : ApplicationFrontendFlowStep(_AppM, PRAGMA_ANALYSIS, _design_flow_manager, _parameters)
85 {
86  debug_level = parameters->get_class_debug_level(GET_CLASS(*this), DEBUG_LEVEL_NONE);
87 }
88 
90 
93 {
95  switch(relationship_type)
96  {
98  {
99  relationships.insert(std::make_pair(CREATE_TREE_MANAGER, WHOLE_APPLICATION));
100  break;
101  }
103  {
104  break;
105  }
107  {
108  break;
109  }
110  default:
111  {
112  THROW_UNREACHABLE("");
113  }
114  }
115  return relationships;
116 }
117 
118 std::list<tree_nodeRef> OpenParallelSections;
119 
120 std::string PragmaAnalysis::get_call_parameter(unsigned int tree_node, unsigned int idx) const
121 {
122  const tree_managerRef TM = AppM->get_tree_manager();
124  "-->Asking parameter " + std::to_string(idx) + " " + STR(tree_node));
125  auto tn = TM->get_tree_node_const(tree_node);
126  const gimple_call* ce = GetPointer<gimple_call>(tn);
127  if(idx >= ce->args.size())
128  {
130  return "";
131  }
132  const tree_nodeConstRef arg = GET_NODE(ce->args[idx]);
133  const auto* ae = GetPointer<const addr_expr>(arg);
134  THROW_ASSERT(ae, "Argument of call is not addr_expr: " + arg->get_kind_text());
135  const tree_nodeConstRef ae_arg = GET_NODE(ae->op);
136  std::string string_arg;
137  if(ae_arg->get_kind() == var_decl_K)
138  {
139  auto vd = GetPointer<const var_decl>(ae_arg);
140  THROW_ASSERT(vd, "unexpected condition");
141  THROW_ASSERT(vd->init, "unexpected condition");
142  auto vd_init = GET_NODE(vd->init);
143  if(vd_init->get_kind() == constructor_K)
144  {
145  const auto* co = GetPointer<const constructor>(vd_init);
146  for(const auto& idx_valu : co->list_of_idx_valu)
147  {
148  THROW_ASSERT(GET_NODE(idx_valu.second)->get_kind() == integer_cst_K, "unexpected condition");
149  const auto cst_val = tree_helper::GetConstValue(idx_valu.second);
150  char val = static_cast<char>(cst_val);
151  if(!val)
152  {
153  break;
154  }
155  string_arg.push_back(val);
156  }
157  }
158  else
159  {
160  THROW_ERROR("unexpected condition");
161  }
162  }
163  else
164  {
165  const auto* sc = GetPointer<const string_cst>(
166  ae_arg->get_kind() == string_cst_K ? ae_arg : GET_NODE(GetPointer<const array_ref>(ae_arg)->op0));
167  string_arg = sc->strg;
168  }
169  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--parameter is " + string_arg);
170  return string_arg;
171 }
172 
173 void PragmaAnalysis::create_omp_pragma(const unsigned int tree_node) const
174 {
175  const tree_managerRef TM = AppM->get_tree_manager();
176  const pragma_managerRef PM = AppM->get_pragma_manager();
177  const tree_nodeRef curr_tn = TM->get_tree_node_const(tree_node);
178  const auto* gc = GetPointer<const gimple_call>(curr_tn);
180  "-->Creating openmp pragma starting from " + curr_tn->ToString());
181  const tree_nodeRef& tn = GET_NODE(gc->fn);
182  const tree_nodeRef& fn = GET_NODE(GetPointer<addr_expr>(tn)->op);
183  const tree_nodeRef& name = GET_NODE(GetPointer<function_decl>(fn)->name);
184  const std::string& function_name = GetPointer<identifier_node>(name)->strg;
185 
187 
188  std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> tree_node_schema;
189  std::string include_name = GetPointer<srcp>(TM->get_tree_node_const(tree_node))->include_name;
190  unsigned int line_number = GetPointer<srcp>(TM->get_tree_node_const(tree_node))->line_number;
191  unsigned int column_number = GetPointer<srcp>(TM->get_tree_node_const(tree_node))->column_number;
192  tree_node_schema[TOK(TOK_SRCP)] =
193  include_name + ":" + std::to_string(line_number) + ":" + std::to_string(column_number);
194 
195  std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> local_tn_schema;
196  unsigned int directive_idx = 0, scope_idx = TM->new_tree_node_id();
197  TM->create_tree_node(scope_idx, omp_pragma_K, local_tn_schema);
198 
199  bool is_block = false;
200  bool is_opening = false;
201  if(function_name == STR_CST_pragma_function_start)
202  {
203  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---pragma opens a block");
204  is_block = true;
205  is_opening = true;
206  switch(directive)
207  {
209  {
210  THROW_ERROR("Unsupported omp directive " + pragma_manager::omp_directive_keywords[directive]);
211  break;
212  }
220  {
221  THROW_UNREACHABLE("Unexpected omp directive " + pragma_manager::omp_directive_keywords[directive]);
222  break;
223  }
225  {
226  directive_idx = TM->new_tree_node_id();
227  TM->create_tree_node(directive_idx, omp_critical_pragma_K, tree_node_schema);
228  auto* pn = GetPointer<omp_critical_pragma>(TM->get_tree_node_const(directive_idx));
229  pn->clauses = PM->ExtractClauses(get_call_parameter(tree_node, 2));
230  break;
231  }
233  {
234  directive_idx = TM->new_tree_node_id();
235  TM->create_tree_node(directive_idx, omp_parallel_pragma_K, tree_node_schema);
236  auto* pn = GetPointer<omp_parallel_pragma>(TM->get_tree_node_const(directive_idx));
237  pn->clauses = PM->ExtractClauses(get_call_parameter(tree_node, 2));
238  break;
239  }
241  {
242  std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> local_tn_schema1;
243  local_tn_schema1[TOK(TOK_PRAGMA_OMP_SHORTCUT)] = STR(true);
244  unsigned int node_parallel = TM->new_tree_node_id();
245  TM->create_tree_node(node_parallel, omp_parallel_pragma_K, local_tn_schema1);
246  auto* pn = GetPointer<omp_parallel_pragma>(TM->get_tree_node_const(node_parallel));
247  pn->clauses = PM->ExtractClauses(get_call_parameter(tree_node, 2));
248 
249  unsigned int node_sections = TM->new_tree_node_id();
250  TM->create_tree_node(node_sections, omp_sections_pragma_K, local_tn_schema1);
251 
252  tree_node_schema[TOK(TOK_OP0)] = std::to_string(node_parallel);
253  tree_node_schema[TOK(TOK_OP1)] = std::to_string(node_sections);
254  directive_idx = TM->new_tree_node_id();
255  TM->create_tree_node(directive_idx, omp_parallel_sections_pragma_K, tree_node_schema);
256 
257  OpenParallelSections.push_back(TM->get_tree_node_const(directive_idx));
258  break;
259  }
261  {
262  directive_idx = TM->new_tree_node_id();
263  TM->create_tree_node(directive_idx, omp_section_pragma_K, tree_node_schema);
264  break;
265  }
267  {
268  directive_idx = TM->new_tree_node_id();
269  TM->create_tree_node(directive_idx, omp_sections_pragma_K, tree_node_schema);
270  break;
271  }
273  {
274  directive_idx = TM->new_tree_node_id();
275  TM->create_tree_node(directive_idx, omp_task_pragma_K, tree_node_schema);
276  auto* pn = GetPointer<omp_task_pragma>(TM->get_tree_node_const(directive_idx));
277  pn->clauses = PM->ExtractClauses(get_call_parameter(tree_node, 2));
278  break;
279  }
280  default:
281  {
282  THROW_UNREACHABLE("");
283  }
284  }
285  }
286  else if(function_name == STR_CST_pragma_function_end)
287  {
288  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---pragma closes a block");
289  is_block = true;
290  is_opening = false;
291  switch(directive)
292  {
294  {
295  THROW_ERROR("Unsupported omp directive " + pragma_manager::omp_directive_keywords[directive]);
296  break;
297  }
305  {
306  THROW_UNREACHABLE("Unexpected omp directive " + pragma_manager::omp_directive_keywords[directive]);
307  break;
308  }
310  {
311  std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> local_tree_node_schema;
312  directive_idx = TM->new_tree_node_id();
313  TM->create_tree_node(directive_idx, omp_critical_pragma_K, local_tree_node_schema);
314  auto* pn = GetPointer<omp_critical_pragma>(TM->get_tree_node_const(directive_idx));
315  pn->clauses = PM->ExtractClauses(get_call_parameter(tree_node, 2));
316  break;
317  }
319  {
320  std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> local_tree_node_schema;
321  directive_idx = TM->new_tree_node_id();
322  TM->create_tree_node(directive_idx, omp_parallel_pragma_K, local_tree_node_schema);
323  break;
324  }
326  {
327  const tree_nodeRef& pn = OpenParallelSections.back();
328  local_tn_schema[TOK(TOK_OP0)] =
329  std::to_string(GET_INDEX_NODE(GetPointer<omp_parallel_sections_pragma>(pn)->op0));
330  local_tn_schema[TOK(TOK_OP1)] =
331  std::to_string(GET_INDEX_NODE(GetPointer<omp_parallel_sections_pragma>(pn)->op1));
332  directive_idx = TM->new_tree_node_id();
333  TM->create_tree_node(directive_idx, omp_parallel_sections_pragma_K, local_tn_schema);
334 
335  OpenParallelSections.pop_back();
336  break;
337  }
339  {
340  std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> local_tree_node_schema;
341  directive_idx = TM->new_tree_node_id();
342  TM->create_tree_node(directive_idx, omp_section_pragma_K, local_tree_node_schema);
343  break;
344  }
346  {
347  std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> local_tree_node_schema;
348  directive_idx = TM->new_tree_node_id();
349  TM->create_tree_node(directive_idx, omp_sections_pragma_K, local_tree_node_schema);
350  break;
351  }
353  {
354  std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> local_tree_node_schema;
355  directive_idx = TM->new_tree_node_id();
356  TM->create_tree_node(directive_idx, omp_task_pragma_K, local_tree_node_schema);
357  break;
358  }
359  default:
360  {
361  THROW_UNREACHABLE("");
362  }
363  }
364  }
365  else if(function_name == STR_CST_pragma_function_single_line_one_argument)
366  {
367  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---single line pragma");
368  switch(directive)
369  {
371  {
372  THROW_ERROR("Unsupported omp directive " + pragma_manager::omp_directive_keywords[directive]);
373  break;
374  }
376  {
377  directive_idx = TM->new_tree_node_id();
378  TM->create_tree_node(directive_idx, omp_atomic_pragma_K, tree_node_schema);
379  break;
380  }
383  {
384  directive_idx = TM->new_tree_node_id();
385  TM->create_tree_node(directive_idx, omp_for_pragma_K, tree_node_schema);
386  auto* fp = GetPointer<omp_for_pragma>(TM->get_tree_node_const(directive_idx));
387  fp->clauses = PM->ExtractClauses(get_call_parameter(tree_node, 2));
388  break;
389  }
391  {
392  directive_idx = TM->new_tree_node_id();
393  TM->create_tree_node(directive_idx, omp_declare_simd_pragma_K, tree_node_schema);
394  auto* sp = GetPointer<omp_declare_simd_pragma>(TM->get_tree_node_const(directive_idx));
395  sp->clauses = PM->ExtractClauses(get_call_parameter(tree_node, 2));
396  break;
397  }
399  {
400  directive_idx = TM->new_tree_node_id();
401  TM->create_tree_node(directive_idx, omp_simd_pragma_K, tree_node_schema);
402  auto* sp = GetPointer<omp_simd_pragma>(TM->get_tree_node_const(directive_idx));
403  sp->clauses = PM->ExtractClauses(get_call_parameter(tree_node, 2));
404  break;
405  }
407  {
408  directive_idx = TM->new_tree_node_id();
409  TM->create_tree_node(directive_idx, omp_target_pragma_K, tree_node_schema);
410  auto* tp = GetPointer<omp_target_pragma>(TM->get_tree_node_const(directive_idx));
411  tp->clauses = PM->ExtractClauses(get_call_parameter(tree_node, 2));
412  break;
413  }
421  {
422  THROW_UNREACHABLE("Unexpected omp directive " + pragma_manager::omp_directive_keywords[directive]);
423  break;
424  }
425  default:
426  {
427  THROW_UNREACHABLE("");
428  }
429  }
430  }
431 
432  tree_node_schema.clear();
433  tree_node_schema[TOK(TOK_SRCP)] =
434  include_name + ":" + std::to_string(line_number) + ":" + std::to_string(column_number);
435  tree_node_schema[TOK(TOK_SCPE)] = STR(GET_INDEX_CONST_NODE(gc->scpe));
436  tree_node_schema[TOK(TOK_IS_BLOCK)] = STR(is_block);
437  tree_node_schema[TOK(TOK_OPEN)] = STR(is_opening);
438  tree_node_schema[TOK(TOK_PRAGMA_SCOPE)] = std::to_string(scope_idx);
439  tree_node_schema[TOK(TOK_PRAGMA_DIRECTIVE)] = std::to_string(directive_idx);
440  tree_node_schema[TOK(TOK_BB_INDEX)] = std::to_string(gc->bb_index);
441  if(gc->memuse)
442  {
443  tree_node_schema[TOK(TOK_MEMUSE)] = std::to_string(GET_INDEX_NODE(gc->memuse));
444  }
445  if(gc->memdef)
446  {
447  tree_node_schema[TOK(TOK_MEMDEF)] = std::to_string(GET_INDEX_NODE(gc->memdef));
448  }
449  TM->create_tree_node(tree_node, gimple_pragma_K, tree_node_schema);
450  GetPointer<gimple_pragma>(TM->get_tree_node_const(tree_node))->vuses = gc->vuses;
451  GetPointer<gimple_pragma>(TM->get_tree_node_const(tree_node))->vdef = gc->vdef;
452  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Created openmp pragma");
453 }
454 
455 void PragmaAnalysis::create_map_pragma(const unsigned int node_id) const
456 {
457  const tree_managerRef TM = AppM->get_tree_manager();
459  "-->Creating mapping pragma starting from tree node " + std::to_string(node_id));
460  const tree_nodeRef curr_tn = TM->get_tree_node_const(node_id);
461  const auto* gc = GetPointer<const gimple_call>(curr_tn);
462 #if HAVE_ASSERTS
463  const tree_nodeRef& tn = GET_NODE(gc->fn);
464  const tree_nodeRef& fn = GET_NODE(GetPointer<addr_expr>(tn)->op);
465  const tree_nodeRef& name = GET_NODE(GetPointer<function_decl>(fn)->name);
466  const std::string& function_name = GetPointer<identifier_node>(name)->strg;
467 #endif
468 
469  std::string include_name = GetPointer<srcp>(TM->get_tree_node_const(node_id))->include_name;
470  unsigned int line_number = GetPointer<srcp>(TM->get_tree_node_const(node_id))->line_number;
471  unsigned int column_number = GetPointer<srcp>(TM->get_tree_node_const(node_id))->column_number;
472 
473  std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> scope_tn_schema;
474  unsigned int directive_idx = TM->new_tree_node_id(), scope_idx = TM->new_tree_node_id();
475 
476  TM->create_tree_node(scope_idx, map_pragma_K, scope_tn_schema);
477 
479  "Error in map pragma replacing function " + function_name);
480 
481  std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> directive_tn_schema;
482  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Component is " + get_call_parameter(node_id, 2));
483  directive_tn_schema[TOK(TOK_HW_COMPONENT)] = get_call_parameter(node_id, 2);
484 
485  const std::string fourth_parameter = get_call_parameter(node_id, 3);
486  if(fourth_parameter != "")
487  {
488  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Fourth parameter is " + fourth_parameter);
489  if(fourth_parameter != STR_CST_pragma_keyword_recursive)
490  {
491  THROW_ERROR("Error in pragma syntax: second parameter of mapping pragma is " + fourth_parameter);
492  }
493  directive_tn_schema[TOK(TOK_RECURSIVE)] = STR(true);
494  }
495  TM->create_tree_node(directive_idx, call_point_hw_pragma_K, directive_tn_schema);
496 
497  std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> tree_node_schema;
498  tree_node_schema[TOK(TOK_SRCP)] =
499  include_name + ":" + std::to_string(line_number) + ":" + std::to_string(column_number);
500  tree_node_schema[TOK(TOK_SCPE)] = STR(GET_INDEX_CONST_NODE(gc->scpe));
501  tree_node_schema[TOK(TOK_IS_BLOCK)] = STR(false);
502  tree_node_schema[TOK(TOK_OPEN)] = STR(false);
503  tree_node_schema[TOK(TOK_PRAGMA_SCOPE)] = std::to_string(scope_idx);
504  tree_node_schema[TOK(TOK_PRAGMA_DIRECTIVE)] = std::to_string(directive_idx);
505  tree_node_schema[TOK(TOK_BB_INDEX)] = std::to_string(gc->bb_index);
506  TM->create_tree_node(node_id, gimple_pragma_K, tree_node_schema);
508  "<--Created mapping pragma starting from tree node " + std::to_string(node_id));
509 }
510 
512 {
513  const tree_managerRef TM = AppM->get_tree_manager();
514  const pragma_managerRef PM = AppM->get_pragma_manager();
515 
517  for(const auto function : functions)
518  {
519  const tree_nodeRef curr_tn = TM->get_tree_node_const(function);
520  auto* fd = GetPointer<function_decl>(curr_tn);
521  if(not fd->body)
522  {
523  continue;
524  }
525  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Examining function " + STR(function));
526  auto* sl = GetPointer<statement_list>(GET_NODE(fd->body));
527  std::map<unsigned int, blocRef>& blocks = sl->list_of_bloc;
528  std::map<unsigned int, blocRef>::iterator it, it_end;
529  it_end = blocks.end();
530  for(it = blocks.begin(); it != it_end; ++it)
531  {
532  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Examining BB" + std::to_string(it->first));
533  const auto list_of_stmt = it->second->CGetStmtList();
534  auto it2 = list_of_stmt.begin();
535  while(it2 != list_of_stmt.end())
536  {
538  "-->Examining statement " + std::to_string(GET_INDEX_NODE(*it2)));
539  const tree_nodeRef& TN = GET_NODE(*it2);
540  if(TN->get_kind() == gimple_call_K)
541  {
542  const tree_nodeRef& tn = GET_NODE(GetPointer<gimple_call>(TN)->fn);
543  if(tn and tn->get_kind() == addr_expr_K)
544  {
545  const tree_nodeRef& fn = GET_NODE(GetPointer<addr_expr>(tn)->op);
546  if(fn)
547  {
548  const tree_nodeRef& name = GET_NODE(GetPointer<function_decl>(fn)->name);
549  const std::string& function_name = GetPointer<identifier_node>(name)->strg;
550  if(function_name.find(STR_CST_pragma_prefix) == std::string::npos)
551  {
553  "<--Skip statement " + std::to_string(GET_INDEX_NODE(*it2)));
554  it2++;
555  continue;
556  }
558  std::map<TreeVocabularyTokenTypes_TokenEnum, std::string> tree_node_schema;
559  std::string include_name = GetPointer<srcp>(TN)->include_name;
560  unsigned int line_number = GetPointer<srcp>(TN)->line_number;
561  unsigned int column_number = GetPointer<srcp>(TN)->column_number;
562  tree_node_schema[TOK(TOK_SRCP)] =
563  include_name + ":" + std::to_string(line_number) + ":" + std::to_string(column_number);
564  tree_node_schema[TOK(TOK_SCPE)] = STR(function);
565 
566  // unsigned int scope, directive;
567  if(!starts_with(function_name, STR_CST_pragma_function_generic))
568  {
569  std::string scope = get_call_parameter(GET_INDEX_NODE(*it2), 0);
570  if(scope == STR_CST_pragma_keyword_omp)
571  {
573  }
574  else if(scope == STR_CST_pragma_keyword_map)
575  {
577  }
578  }
579  else
580  {
581  TM->create_tree_node(GET_INDEX_NODE(*it2), gimple_pragma_K, tree_node_schema);
582  std::string num = function_name;
583  num = num.substr(10, num.size());
584  num = num.substr(0, num.find('_'));
585  std::string string_base = PM->getGenericPragma(static_cast<unsigned>(std::stoul(num)));
586  string_base = string_base.substr(string_base.find("#pragma") + 8, string_base.size());
587  auto* el = GetPointer<gimple_pragma>(TM->get_tree_node_const(GET_INDEX_NODE(*it2)));
588  el->line = string_base;
589  decltype(it2) next;
590  for(next = it2; next != list_of_stmt.end(); next++)
591  {
592  auto* en = GetPointer<gimple_node>(GET_NODE(*next));
593  if(en)
594  {
595  en->pragmas.push_back(*it2);
597  if(it2 == list_of_stmt.begin())
598  {
599  it->second->RemoveStmt(*it2, AppM);
600  it2 = list_of_stmt.begin();
601  }
603  else
604  {
605  next = it2;
606  next++;
607  it->second->RemoveStmt(*it2, AppM);
608  next--;
609  it2 = next;
610  }
611  break;
612  }
613  }
615  if(next == list_of_stmt.end())
616  {
617  break;
618  }
619  continue;
620  }
621  }
622  }
623  }
625  "<--Examined statement " + std::to_string(GET_INDEX_NODE(*it2)));
626  it2++;
627  }
628  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Examined BB" + std::to_string(it->first));
629  }
630  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Examined function " + STR(function));
631  }
632 
634 }
#define GET_NODE(t)
Macro used to hide implementation details when accessing a tree_node from another tree_node...
Definition: tree_node.hpp:343
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
static const std::string omp_directive_keywords[OMP_UNKNOWN]
The list of omp directive keywords.
File containing functions and utilities to support the printing of debug messagges.
std::string ToString() const
Print this node as string in gimple format.
#define STR_CST_pragma_function_generic
The function replacin a generic pragma.
const CustomUnorderedSet< unsigned int > GetAllFunctions() const
Returns all the functions in the tree_manager.
#define GET_CLASS(obj)
Macro returning the actual type of an object.
Definition of the class representing a generic C application.
#define STR_CST_pragma_prefix
The prefix common to all functions replacing pragma.
RelationshipType
The relationship type.
Source must be executed to satisfy target.
void create_omp_pragma(const unsigned int tree_node) const
Create an omp pragma.
#define STR_CST_pragma_function_end
The function replacing an ending pragma.
exceptions managed by PandA
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...
Definition: tree_node.hpp:361
std::list< tree_nodeRef > OpenParallelSections
void create_map_pragma(const unsigned int node_id) const
Create a map pragma.
std::vector< tree_nodeRef > args
The arguments of the gimple_call.
Definition: tree_node.hpp:1968
Data structure describing a basic block at tree level.
redefinition of map to manage ordered/unordered structures
constant strings used in pragma identification
#define TOK(token)
Macro used to convert a token symbol into a treeVocabularyTokenTypes.
Abstract pure class for the tree structure.
Definition: tree_node.hpp:139
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.
const tree_nodeRef get_tree_node_const(unsigned int i) const
Return the reference to the i-th tree_node Constant version of get_tree_node.
#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.
bool starts_with(const std::string &str, const std::string &pattern)
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 STR_CST_pragma_function_single_line_two_arguments
The function replacing a single line pragma with two argument.
#define STR_CST_pragma_function_single_line_one_argument
The function replacing a single line pragma with single argument.
unsigned int new_tree_node_id(const unsigned int ask=0)
Return a new node id in the intermediate representation.
Manager for pragma annotations.
void create_tree_node(const unsigned int node_id, enum kind tree_node_type, std::map< TreeVocabularyTokenTypes_TokenEnum, std::string > &tree_node_schema)
Factory method.
std::string get_call_parameter(const unsigned int tree_node, const unsigned int idx) const
Given the index of a function replacing a pragma, returns a parameter.
Classes specification of the tree_node data structures.
OmpPragmaType
The possible openmp pragmas Note that sections has to go before section but after parallel sections o...
const ParameterConstRef parameters
Set of input parameters.
DesignFlowStep_Status
The status of a step.
#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
DesignFlowStep_Status Exec() override
Performes the analysis of the pragmas.
#define STR_CST_pragma_keyword_map
The keyword &#39;map&#39; which identifies mapping pragmas.
This file collects some utility functions.
~PragmaAnalysis() override
Destructor.
Parsing pragma from C sources.
#define STR_CST_pragma_keyword_omp
The keyword &#39;omp&#39; which identifies openmp pragmas.
#define STR_CST_pragma_keyword_recursive
The keyword &#39;omp&#39; which identifies openmp recursive.
const application_managerRef AppM
The application manager.
int el
Definition: adpcm.c:105
Class specification of the tree_reindex support class.
PragmaAnalysis(const application_managerRef AppM, const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters)
Constructor.
Analysis step that recognizes the pragma calls in the specification.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
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.
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)
Definition: tree_node.hpp:363
static OmpPragmaType GetOmpPragmaType(const std::string &directive)
Returns the identifier corresponding to an openmp directive.
#define STR_CST_pragma_function_start
The function replacing an opening pragma.
This struct specifies the gimple_call node.
Definition: tree_node.hpp:1959
Class specification of the manager of the tree structures extracted from the raw file.
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