PandA-2024.02
Parameter.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  */
41 #include "Parameter.hpp"
42 
43 #include "constant_strings.hpp"
44 #include "dbgPrintHelper.hpp"
46 #include "fileIO.hpp"
47 #include "polixml.hpp"
48 #include "refcount.hpp"
49 #include "string_manipulation.hpp"
50 #include "utility.hpp"
51 #include "xml_dom_parser.hpp"
52 #include "xml_helper.hpp"
53 
54 #include "config_HAVE_FROM_C_BUILT.hpp"
55 #include "config_HAVE_I386_CLANG10_COMPILER.hpp"
56 #include "config_HAVE_I386_CLANG11_COMPILER.hpp"
57 #include "config_HAVE_I386_CLANG12_COMPILER.hpp"
58 #include "config_HAVE_I386_CLANG13_COMPILER.hpp"
59 #include "config_HAVE_I386_CLANG16_COMPILER.hpp"
60 #include "config_HAVE_I386_CLANG4_COMPILER.hpp"
61 #include "config_HAVE_I386_CLANG5_COMPILER.hpp"
62 #include "config_HAVE_I386_CLANG6_COMPILER.hpp"
63 #include "config_HAVE_I386_CLANG7_COMPILER.hpp"
64 #include "config_HAVE_I386_CLANG8_COMPILER.hpp"
65 #include "config_HAVE_I386_CLANG9_COMPILER.hpp"
66 #include "config_HAVE_I386_CLANGVVD_COMPILER.hpp"
67 #include "config_HAVE_I386_GCC49_COMPILER.hpp"
68 #include "config_HAVE_I386_GCC5_COMPILER.hpp"
69 #include "config_HAVE_I386_GCC6_COMPILER.hpp"
70 #include "config_HAVE_I386_GCC7_COMPILER.hpp"
71 #include "config_HAVE_I386_GCC8_COMPILER.hpp"
72 #include "config_HAVE_TO_DATAFILE_BUILT.hpp"
73 #include "config_PACKAGE_BUGREPORT.hpp"
74 #include "config_PACKAGE_STRING.hpp"
75 
76 #if HAVE_HLS_BUILT
77 #include "constraints_xml.hpp"
78 #endif
79 
80 #if HAVE_TO_DATAFILE_BUILT
81 #include "latex_table_xml.hpp"
82 #endif
83 
84 #if HAVE_TECHNOLOGY_BUILT
85 #include "technology_xml.hpp"
86 #endif
87 
88 #if HAVE_FROM_C_BUILT
89 #include "compiler_wrapper.hpp"
90 #include "token_interface.hpp"
91 #endif
92 
93 #include <cstdlib>
94 #include <filesystem>
95 #include <iosfwd>
96 
97 const std::string branch_name = {
98 #include "branch_name.hpp"
99 };
100 
101 const std::string revision_hash = {
102 #include "revision_hash.hpp"
103 };
104 
105 #define OPTION_NAME(r, data, elem) option_name[BOOST_PP_CAT(OPT_, elem)] = #elem;
106 
107 Parameter::Parameter(const std::string& _program_name, int _argc, char** const _argv, int _debug_level)
108  : argc(_argc), argv(_argv), debug_level(_debug_level)
109 {
110  setOption(OPT_program_name, _program_name);
118  // This part has been added since boost macro does not expand correctly
119  std::map<enum enum_option, std::string>::iterator it, it_end = option_name.end();
120  for(it = option_name.begin(); it != it_end; it++)
121  {
122  it->second = "OPT_" + it->second.substr(19);
123  it->second = it->second.substr(0, it->second.find(')'));
124  }
126 }
127 
129  : argc(other.argc),
130  argv(other.argv),
131  Options(other.Options),
132  enum_options(other.enum_options),
133  option_name(other.option_name),
135  debug_level(other.debug_level)
136 {
137 }
138 
140 {
141  const auto temporary_directory = getOption<std::string>(OPT_output_temporary_directory);
142  if(std::filesystem::exists(temporary_directory))
143  {
144  std::filesystem::remove_all(temporary_directory);
145  }
146  std::filesystem::create_directory(temporary_directory);
148  const auto output_directory = getOption<std::string>(OPT_output_directory);
149  if(!std::filesystem::exists(output_directory))
150  {
151  std::filesystem::create_directory(output_directory);
152  }
153  if(!std::filesystem::exists(output_directory))
154  {
155  THROW_ERROR("not able to create directory " + output_directory);
156  }
157  if(getOption<bool>(OPT_print_dot))
158  {
159  const auto dot_directory = getOption<std::string>(OPT_dot_directory);
160  if(std::filesystem::exists(dot_directory))
161  {
162  std::filesystem::remove_all(dot_directory);
163  }
164  std::filesystem::create_directory(dot_directory);
165  if(!std::filesystem::exists(dot_directory))
166  {
167  THROW_ERROR("not able to create directory " + dot_directory);
168  }
169  }
170 
171 #if HAVE_FROM_C_BUILT
172  if(isOption(OPT_gcc_m32_mx32))
173  {
174  const auto mopt = getOption<std::string>(OPT_gcc_m32_mx32);
175  const auto default_compiler = getOption<CompilerWrapper_CompilerTarget>(OPT_default_compiler);
176  if(mopt == "-m32" && CompilerWrapper::hasCompilerGCCM32(default_compiler))
177  {
178  setOption(OPT_gcc_m32_mx32, "-m32 -mno-sse2");
179  }
180  else if((mopt == "-m32" && !CompilerWrapper::hasCompilerCLANGM32(default_compiler)) ||
181  (mopt == "-mx32" && !CompilerWrapper::hasCompilerMX32(default_compiler)) ||
182  (mopt == "-m64" && !CompilerWrapper::hasCompilerM64(default_compiler)))
183  {
184  THROW_ERROR("Option " + mopt + " not supported by " + CompilerWrapper::getCompilerSuffix(default_compiler) +
185  " compiler.");
186  }
187  }
188 #endif
189 }
190 
191 Parameter::~Parameter() = default;
192 
194 {
195  // Recurse through child nodes:
196  const xml_node::node_list list = node->get_children();
197  for(const auto& iter : list)
198  {
199  const auto* EnodeC = GetPointer<const xml_element>(iter);
200  if(!EnodeC)
201  {
202  continue;
203  }
205  if(CE_XVM(value, EnodeC))
206  {
207  Options[GET_NODE_NAME(EnodeC)] = GET_STRING_VALUE(EnodeC);
208  }
209  if(EnodeC->get_children().size())
210  {
212  }
213  }
214 }
215 
217 {
218  try
219  {
220  XMLDomParser parser(filename);
221  parser.Exec();
222  if(parser)
223  {
224  // Walk the tree:
225  const xml_element* node = parser.get_document()->get_root_node(); // deleted by DomParser.
226 
227  // Recurse through child nodes:
228  const xml_node::node_list list = node->get_children();
229  for(const auto& iter : list)
230  {
231  const auto* EnodeC = GetPointer<const xml_element>(iter);
232  if(!EnodeC)
233  {
234  continue;
235  }
237  if(CE_XVM(value, EnodeC))
238  {
239  Options[GET_NODE_NAME(EnodeC)] = GET_STRING_VALUE(EnodeC);
240  }
241  if(EnodeC->get_children().size())
242  {
244  }
245  }
246  }
247  }
248  catch(const char* msg)
249  {
250  std::cerr << msg << std::endl;
251  }
252  catch(const std::string& msg)
253  {
254  std::cerr << msg << std::endl;
255  }
256  catch(const std::exception& ex)
257  {
258  std::cout << "Exception caught: " << ex.what() << std::endl;
259  }
260  catch(...)
261  {
262  std::cerr << "unknown exception" << std::endl;
263  }
264 }
265 
267 {
268  xml_document document;
269 
270  xml_element* parameters = document.create_root_node("parameters");
271 
272  for(auto Op = Options.begin(); Op != Options.end(); ++Op)
273  {
274  xml_element* node = parameters->add_child_element(Op->first);
275  WRITE_XNVM2("value", Op->second, node);
276  }
277 
278  document.write_to_file_formatted(filename);
279 }
280 
282 {
284  std::string current_dir = GetCurrentPath();
285  std::string temporary_directory = current_dir + "/" STR_CST_temporary_directory;
286 
287  setOption(OPT_dot_directory, current_dir + "/dot/");
288  setOption(OPT_output_temporary_directory, temporary_directory + "/");
289  setOption(OPT_print_dot, false);
290 
291  setOption(OPT_gcc_openmp_simd, 0);
292 
293  setOption(OPT_no_clean, false);
294  if(revision_hash == "")
295  {
296  setOption(OPT_revision, "unknown-trunk");
297  }
298  else
299  {
300  setOption(OPT_revision, revision_hash + (branch_name != "" ? "-" + branch_name : ""));
301  }
302  setOption(OPT_seed, 0);
303 
304  setOption(OPT_max_transformations, std::numeric_limits<size_t>::max());
305  setOption(OPT_find_max_transformations, false);
306 }
307 
308 void Parameter::print(std::ostream& os) const
309 {
310  os << "List of parameters: " << std::endl;
311  for(const auto& Option : Options)
312  {
313  os << Option.first << ": " << Option.second << std::endl;
314  }
315  std::map<enum enum_option, std::string>::const_iterator option, option_end = enum_options.end();
316  for(option = enum_options.begin(); option != option_end; ++option)
317  {
318  os << option_name.find(option->first)->second << ": " << option->second << std::endl;
319  }
320  os << " === " << std::endl;
321 }
322 
323 int Parameter::get_class_debug_level(const std::string& class_name, int _debug_level) const
324 {
325  auto temp = class_name;
326  temp.erase(std::remove(temp.begin(), temp.end(), '_'), temp.end());
327  if(debug_classes.find(boost::to_upper_copy(temp)) != debug_classes.end() or
329  {
330  return DEBUG_LEVEL_INFINITE;
331  }
332  else if(_debug_level < 0)
333  {
334  return getOption<int>(OPT_debug_level);
335  }
336  else
337  {
338  return _debug_level;
339  }
340 }
341 
342 int Parameter::GetFunctionDebugLevel(const std::string& class_name, const std::string& function_name) const
343 {
344  auto canonic_class_name = class_name;
345  canonic_class_name.erase(std::remove(canonic_class_name.begin(), canonic_class_name.end(), '_'),
346  canonic_class_name.end());
347  auto canonic_function_name = function_name;
348  canonic_function_name.erase(std::remove(canonic_function_name.begin(), canonic_function_name.end(), '_'),
349  canonic_function_name.end());
350  const auto canonic_full_function_name = canonic_class_name + std::string("::") + canonic_function_name;
351  if(debug_classes.find(boost::to_upper_copy(canonic_full_function_name)) != debug_classes.end())
352  {
353  return DEBUG_LEVEL_INFINITE;
354  }
355  else
356  {
357  return get_class_debug_level(class_name);
358  }
359 }
360 
361 void Parameter::add_debug_class(const std::string& class_name)
362 {
363  auto temp = class_name;
364  temp.erase(std::remove(temp.begin(), temp.end(), '_'), temp.end());
365  debug_classes.insert(boost::to_upper_copy(temp));
366 }
367 
368 void Parameter::PrintFullHeader(std::ostream& os) const
369 {
370  PrintProgramName(os);
371  os << " Politecnico di Milano - DEIB" << std::endl;
372  os << " System Architectures Group" << std::endl;
373  os << "********************************************************************************" << std::endl;
374  os << " Copyright (C) 2004-2024 Politecnico di Milano" << std::endl;
375  std::string version = PrintVersion();
376  if(version.size() < 80)
377  {
378  os << std::string(40 - (version.size() / 2), ' ') << version << std::endl;
379  }
380  else
381  {
382  os << version << std::endl;
383  }
384  os << std::endl;
385 }
386 
387 std::string Parameter::PrintVersion() const
388 {
389  return std::string("Version: ") + PACKAGE_STRING + " - Revision " + getOption<std::string>(OPT_revision);
390 }
391 
392 void Parameter::PrintUsage(std::ostream& os) const
393 {
394  PrintFullHeader(os);
395  PrintHelp(os);
396 }
397 
398 bool Parameter::ManageDefaultOptions(int next_option, char* optarg_param, bool& exit_success)
399 {
400  exit_success = false;
401  switch(next_option)
402  {
403  case INPUT_OPT_NO_CLEAN:
404  setOption(OPT_no_clean, true);
405  break;
406  case 'h': // print help message and exit
407  PrintUsage(std::cout);
408  exit_success = true;
409  break;
410  case 'V':
411  PrintFullHeader(std::cout);
412  exit_success = true;
413  break;
414 #if !RELEASE
416  {
417  setOption(OPT_read_parameter_xml, optarg_param);
418  load_xml_configuration_file(getOption<std::string>(OPT_read_parameter_xml));
419  break;
420  }
422  {
423  setOption(OPT_write_parameter_xml, optarg_param);
424  break;
425  }
426 #endif
427  case 'v':
428  {
429  setOption(OPT_output_level, optarg_param);
430  break;
431  }
432  case OPT_BENCHMARK_NAME:
433  {
434  setOption(OPT_benchmark_name, optarg_param);
435  break;
436  }
438  {
440  break;
441  }
443  {
444  setOption(OPT_max_transformations, optarg_param);
445  break;
446  }
448  {
449  setOption(OPT_find_max_transformations, true);
450  break;
451  }
453  {
454  setOption(OPT_configuration_name, optarg_param);
455  break;
456  }
457  case 'd':
458  {
459 #if HAVE_FROM_C_BUILT
460  if(std::string(optarg_param) == "umpversion")
461  {
462  const auto preferred_compiler = getOption<CompilerWrapper_CompilerTarget>(OPT_default_compiler);
464  CompilerWrapper::getCompilerVersion(static_cast<int>(preferred_compiler)));
465  exit_success = true;
466  break;
467  }
468 #endif
469  if(std::string(optarg_param) == "N")
470  {
471  std::string gcc_extra_options = "-dN";
472  if(isOption(OPT_gcc_extra_options))
473  {
474  gcc_extra_options = getOption<std::string>(OPT_gcc_extra_options) + " " + gcc_extra_options;
475  }
476  setOption(OPT_gcc_extra_options, gcc_extra_options);
477  break;
478  }
479 #ifndef NDEBUG
480  else
481  {
482  debug_level = std::stoi(optarg_param);
483  setOption(OPT_debug_level, optarg_param);
484  break;
485  }
486 #endif
487  return true;
488  }
489 #ifndef NDEBUG
490  case OPT_DEBUG_CLASSES:
491  {
492  std::vector<std::string> Splitted = SplitString(optarg_param, ",");
493  for(const auto& i : Splitted)
494  {
495  add_debug_class(i);
496  }
497  setOption(OPT_no_clean, true);
498  break;
499  }
500 #endif
502  {
503  error_on_warning = true;
504  break;
505  }
506  case INPUT_OPT_PRINT_DOT:
507  {
508  setOption(OPT_print_dot, true);
509  break;
510  }
511  case INPUT_OPT_SEED:
512  {
513  setOption(OPT_seed, optarg_param);
514  break;
515  }
517  {
519  const auto path =
520  unique_path(GetPath(std::string(optarg_param)) + "/" STR_CST_temporary_directory "-%%%%-%%%%-%%%%-%%%%");
521  std::filesystem::create_directories(path);
522  setOption(OPT_output_temporary_directory, path.string() + "/");
523  break;
524  }
526  {
527  std::string param_pair(optarg_param);
528  std::vector<std::string> splitted = SplitString(param_pair, "=");
529  if(splitted.size() != 2)
530  {
531  THROW_ERROR("panda-parameter should be in the form <parameter>=<value>: " + param_pair);
532  }
533  panda_parameters[splitted[0]] = splitted[1];
534  break;
535  }
536  default:
537  {
539  return true;
540  }
541  }
542  return false;
543 }
544 
545 #if HAVE_FROM_C_BUILT
546 bool Parameter::ManageGccOptions(int next_option, char* optarg_param)
547 {
548  switch(next_option)
549  {
550  case 'c':
551  {
552  setOption(OPT_gcc_c, true);
553  break;
554  }
555  case 'D':
556  {
557  std::string defines;
558  if(isOption(OPT_gcc_defines))
559  {
560  defines = getOption<std::string>(OPT_gcc_defines) + STR_CST_string_separator;
561  }
562  defines += std::string(optarg_param);
563  setOption(OPT_gcc_defines, defines);
564  break;
565  }
566  case 'f':
567  {
568  if(std::string(optarg_param).find("openmp-simd") != std::string::npos)
569  {
570  if(std::string(optarg_param).find('=') != std::string::npos)
571  {
572  setOption(OPT_gcc_openmp_simd,
573  std::string(optarg_param).substr(std::string(optarg_param).find('=') + 1));
574  }
575  else
576  {
577  setOption(OPT_gcc_openmp_simd, 4);
578  }
579  break;
580  }
581  else if(std::string(optarg_param).find("openmp") != std::string::npos)
582  {
583  setOption(OPT_parse_pragma, true);
584  break;
585  }
586  else
587  {
588  std::string optimizations;
589  if(isOption(OPT_gcc_optimizations))
590  {
591  optimizations = getOption<std::string>(OPT_gcc_optimizations) + STR_CST_string_separator;
592  }
593  THROW_ASSERT(optarg_param != nullptr && optarg_param[0] != 0, "-f alone not allowed");
594  setOption(OPT_gcc_optimizations, optimizations + optarg_param);
595  break;
596  }
597  }
598  case 'g':
599  {
601  break;
602  }
603  case 'm':
604  {
605  if(optarg_param)
606  {
607  const std::string opt_level = std::string(optarg_param);
608  if(opt_level == "32")
609  {
610  setOption(OPT_gcc_m32_mx32, "-m32");
611  }
612  else if(opt_level == "x32")
613  {
614  setOption(OPT_gcc_m32_mx32, "-mx32");
615  }
616  else if(opt_level == "64")
617  {
618  setOption(OPT_gcc_m32_mx32, "-m64");
619  }
620  }
621  break;
622  }
623  case 'W':
624  {
625  std::string gcc_warnings;
626  if(isOption(OPT_gcc_warnings))
627  {
628  gcc_warnings = getOption<std::string>(OPT_gcc_warnings) + STR_CST_string_separator;
629  }
630  setOption(OPT_gcc_warnings, gcc_warnings + optarg_param);
631  break;
632  }
633  case 'E':
634  {
635  setOption(OPT_gcc_E, true);
636  break;
637  }
638  case 'I':
639  {
640  std::string includes = "-I " + GetPath(std::string(optarg));
641  if(isOption(OPT_gcc_includes))
642  {
643  includes = getOption<std::string>(OPT_gcc_includes) + " " + includes;
644  }
645  setOption(OPT_gcc_includes, includes);
646  break;
647  }
648  case 'l':
649  {
650  std::string libraries;
651  if(isOption(OPT_gcc_libraries))
652  {
653  libraries = getOption<std::string>(OPT_gcc_libraries) + STR_CST_string_separator;
654  }
655  setOption(OPT_gcc_libraries, libraries + optarg_param);
656  break;
657  }
658  case 'L':
659  {
660  std::string library_directories;
661  if(isOption(OPT_gcc_library_directories))
662  {
663  library_directories = getOption<std::string>(OPT_gcc_library_directories) + STR_CST_string_separator;
664  }
665  setOption(OPT_gcc_library_directories, library_directories + GetPath(optarg_param));
666  break;
667  }
668  case 'O':
669  {
670  if(optarg_param)
671  {
672  const std::string opt_level = std::string(optarg_param);
673  if(opt_level == "0")
674  {
675  setOption(OPT_compiler_opt_level, CompilerWrapper_OptimizationSet::O0);
676  }
677  else if(opt_level == "1")
678  {
679  setOption(OPT_compiler_opt_level, CompilerWrapper_OptimizationSet::O1);
680  }
681  else if(opt_level == "2")
682  {
683  setOption(OPT_compiler_opt_level, CompilerWrapper_OptimizationSet::O2);
684  }
685  else if(opt_level == "3")
686  {
687  setOption(OPT_compiler_opt_level, CompilerWrapper_OptimizationSet::O3);
688  }
689  else if(opt_level == "4")
690  {
691  setOption(OPT_compiler_opt_level, CompilerWrapper_OptimizationSet::O4);
692  }
693  else if(opt_level == "5")
694  {
695  setOption(OPT_compiler_opt_level, CompilerWrapper_OptimizationSet::O5);
696  }
697  else if(opt_level == "g")
698  {
699  setOption(OPT_compiler_opt_level, CompilerWrapper_OptimizationSet::Og);
700  }
701  else if(opt_level == "s")
702  {
703  setOption(OPT_compiler_opt_level, CompilerWrapper_OptimizationSet::Os);
704  }
705  else if(opt_level == "fast")
706  {
707  setOption(OPT_compiler_opt_level, CompilerWrapper_OptimizationSet::Ofast);
708  }
709  else if(opt_level == "z")
710  {
711  setOption(OPT_compiler_opt_level, CompilerWrapper_OptimizationSet::Oz);
712  }
713  else
714  {
715  THROW_ERROR("Unknown optimization level: " + opt_level);
716  }
717  }
718  else
719  {
720  setOption(OPT_compiler_opt_level, CompilerWrapper_OptimizationSet::O1);
721  }
722  break;
723  }
724  case 'U':
725  {
726  std::string undefines;
727  if(isOption(OPT_gcc_undefines))
728  {
729  undefines = getOption<std::string>(OPT_gcc_undefines) + STR_CST_string_separator;
730  }
731  if(std::string(optarg_param).find('=') != std::string::npos)
732  {
733  bool has_parenthesis = std::string(optarg_param).find('(') != std::string::npos &&
734  std::string(optarg_param).find(')') != std::string::npos;
735  std::string temp_var = std::string(optarg_param);
736  boost::replace_first(temp_var, "=", "=\'");
737  if(has_parenthesis)
738  {
739  undefines += "\'" + temp_var + "\'" + "\'";
740  }
741  else
742  {
743  undefines += temp_var + "\'";
744  }
745  }
746  else
747  {
748  setOption(OPT_gcc_undefines, undefines + optarg_param);
749  }
750  break;
751  }
753  {
754  setOption(OPT_gcc_extra_options, optarg);
755  break;
756  }
757 #if !RELEASE
759  {
760  setOption(OPT_compute_size_of, true);
761  break;
762  }
763 #endif
764  case INPUT_OPT_COMPILER:
765  {
766 #if HAVE_I386_GCC49_COMPILER
767  if(std::string(optarg_param) == "I386_GCC49")
768  {
769  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_GCC49));
770  break;
771  }
772 #endif
773 #if HAVE_I386_GCC5_COMPILER
774  if(std::string(optarg_param) == "I386_GCC5")
775  {
776  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_GCC5));
777  break;
778  }
779 #endif
780 #if HAVE_I386_GCC6_COMPILER
781  if(std::string(optarg_param) == "I386_GCC6")
782  {
783  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_GCC6));
784  break;
785  }
786 #endif
787 #if HAVE_I386_GCC7_COMPILER
788  if(std::string(optarg_param) == "I386_GCC7")
789  {
790  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_GCC7));
791  break;
792  }
793 #endif
794 #if HAVE_I386_GCC8_COMPILER
795  if(std::string(optarg_param) == "I386_GCC8")
796  {
797  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_GCC8));
798  break;
799  }
800 #endif
801 #if HAVE_I386_CLANG4_COMPILER
802  if(std::string(optarg_param) == "I386_CLANG4")
803  {
804  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_CLANG4));
805  break;
806  }
807 #endif
808 #if HAVE_I386_CLANG5_COMPILER
809  if(std::string(optarg_param) == "I386_CLANG5")
810  {
811  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_CLANG5));
812  break;
813  }
814 #endif
815 #if HAVE_I386_CLANG6_COMPILER
816  if(std::string(optarg_param) == "I386_CLANG6")
817  {
818  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_CLANG6));
819  break;
820  }
821 #endif
822 #if HAVE_I386_CLANG7_COMPILER
823  if(std::string(optarg_param) == "I386_CLANG7")
824  {
825  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_CLANG7));
826  break;
827  }
828 #endif
829 #if HAVE_I386_CLANG8_COMPILER
830  if(std::string(optarg_param) == "I386_CLANG8")
831  {
832  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_CLANG8));
833  break;
834  }
835 #endif
836 #if HAVE_I386_CLANG9_COMPILER
837  if(std::string(optarg_param) == "I386_CLANG9")
838  {
839  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_CLANG9));
840  break;
841  }
842 #endif
843 #if HAVE_I386_CLANG10_COMPILER
844  if(std::string(optarg_param) == "I386_CLANG10")
845  {
846  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_CLANG10));
847  break;
848  }
849 #endif
850 #if HAVE_I386_CLANG11_COMPILER
851  if(std::string(optarg_param) == "I386_CLANG11")
852  {
853  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_CLANG11));
854  break;
855  }
856 #endif
857 #if HAVE_I386_CLANG12_COMPILER
858  if(std::string(optarg_param) == "I386_CLANG12")
859  {
860  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_CLANG12));
861  break;
862  }
863 #endif
864 #if HAVE_I386_CLANG13_COMPILER
865  if(std::string(optarg_param) == "I386_CLANG13")
866  {
867  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_CLANG13));
868  break;
869  }
870 #endif
871 #if HAVE_I386_CLANG16_COMPILER
872  if(std::string(optarg_param) == "I386_CLANG16")
873  {
874  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_CLANG16));
875  break;
876  }
877 #endif
878 #if HAVE_I386_CLANGVVD_COMPILER
879  if(std::string(optarg_param) == "I386_CLANGVVD")
880  {
881  setOption(OPT_default_compiler, static_cast<int>(CompilerWrapper_CompilerTarget::CT_I386_CLANGVVD));
882  break;
883  }
884 #endif
885  THROW_ERROR("Unknown compiler " + std::string(optarg_param));
886  break;
887  }
889  {
890  setOption(OPT_gcc_config, true);
891  break;
892  }
894  {
895  setOption(OPT_gcc_include_sysdir, true);
896  break;
897  }
898  case INPUT_OPT_PARAM:
899  {
900  std::string parameters;
901  if(isOption(OPT_gcc_parameters))
902  {
903  parameters = getOption<std::string>(OPT_gcc_parameters) + STR_CST_string_separator;
904  }
905  setOption(OPT_gcc_parameters, parameters + optarg_param);
906  break;
907  }
909  {
910  setOption(OPT_gcc_read_xml, GetPath(optarg));
911  break;
912  }
913  case INPUT_OPT_STD:
914  {
915  setOption(OPT_gcc_standard, optarg_param);
916  break;
917  }
918  case INPUT_OPT_USE_RAW:
919  {
920  setOption(OPT_input_format, static_cast<int>(Parameters_FileFormat::FF_RAW));
921  break;
922  }
924  {
925  setOption(OPT_gcc_write_xml, GetPath(optarg));
926  break;
927  }
928  default:
929  {
931  return true;
932  }
933  }
934  return false;
935 }
936 #endif
937 
938 Parameters_FileFormat Parameter::GetFileFormat(const std::filesystem::path& file_name,
939  const bool check_xml_root_node) const
940 {
941  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "-->Getting file format of file " + file_name.string());
942  const auto extension = file_name.extension().string();
943  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Extension is " + extension);
944 #if HAVE_FROM_AADL_ASN_BUILT
945  if(extension == ".aadl" or extension == ".AADL")
946  {
948  return Parameters_FileFormat::FF_AADL;
949  }
950  if(extension == ".asn" or extension == ".ASN")
951  {
953  return Parameters_FileFormat::FF_ASN;
954  }
955 #endif
956 #if HAVE_FROM_C_BUILT
957  if(extension == ".c" or extension == ".i")
958  {
960  return Parameters_FileFormat::FF_C;
961  }
962  if(extension == ".m" or extension == ".mi")
963  {
964  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Objective C source file");
965  return Parameters_FileFormat::FF_OBJECTIVEC;
966  }
967  if(extension == ".mm" or extension == ".M" or extension == ".mii")
968  {
969  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Objective C++ source file");
970  return Parameters_FileFormat::FF_OBJECTIVECPP;
971  }
972  if(extension == ".ii" or extension == ".cc" or extension == ".cp" or extension == ".cxx" or extension == ".cpp" or
973  extension == ".CPP" or extension == ".c++" or extension == ".C")
974  {
975  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--C++ source file");
976  return Parameters_FileFormat::FF_CPP;
977  }
978  if(extension == ".f" or extension == ".for" or extension == ".ftn" or extension == ".F" or extension == ".FOR" or
979  extension == ".fpp" or extension == ".FPP" or extension == ".FTN" or extension == ".f90" or extension == ".f95" or
980  extension == ".f03" or extension == ".f08" or extension == ".F90" or extension == ".F95" or extension == ".F03" or
981  extension == ".F08")
982  {
983  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Fortran source file");
984  return Parameters_FileFormat::FF_FORTRAN;
985  }
986  if(extension == ".ll")
987  {
988  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--LLVM bitcode source file");
989  const auto sub_extension = std::filesystem::path(file_name).replace_extension().extension().string();
990  if(sub_extension == ".cpp")
991  {
992  return Parameters_FileFormat::FF_LLVM_CPP;
993  }
994  else
995  {
996  return Parameters_FileFormat::FF_LLVM;
997  }
998  }
999  if(extension == ".LL")
1000  {
1001  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--LLVM bitcode source file");
1002 
1003  return Parameters_FileFormat::FF_LLVM_CPP;
1004  }
1005 #endif
1006  if(extension == ".csv")
1007  {
1008  const auto sub_extension = std::filesystem::path(file_name).replace_extension().extension().string();
1011  }
1012  if(extension == ".tex")
1013  {
1016  }
1017  if(extension == ".v")
1018  {
1021  }
1022  if(extension == ".vhd" or extension == ".vhdl")
1023  {
1026  }
1027  if(extension == ".xml")
1028  {
1029  if(check_xml_root_node)
1030  {
1031  XMLDomParser parser(file_name.string());
1032  parser.Exec();
1033  THROW_ASSERT(parser, "Impossible to parse xml file " + file_name.string());
1034 
1035 #if HAVE_TO_DATAFILE_BUILT
1036  const xml_element* root = parser.get_document()->get_root_node();
1037  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "---Root node is " + root->get_name());
1038 #if HAVE_BAMBU_RESULTS_XML
1039  if(root->get_name() == "bambu_results")
1040  {
1042  return Parameters_FileFormat::FF_XML_BAMBU_RESULTS;
1043  }
1044 #endif
1045 #if HAVE_HLS_BUILT
1046  if(root->get_name() == STR_XML_constraints_root)
1047  {
1049  return Parameters_FileFormat::FF_XML_CON;
1050  }
1051 #endif
1052  if(root->get_name() == STR_XML_experimental_setup_root)
1053  {
1054  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Experimental setup");
1056  }
1057 #if HAVE_TECHNOLOGY_BUILT
1058  if(root->get_name() == STR_XML_technology_target_root)
1059  {
1060  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Target device information");
1061  return Parameters_FileFormat::FF_XML_TARGET;
1062  }
1063  if(root->get_name() == STR_XML_technology_root)
1064  {
1065  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Technology libraries");
1066  return Parameters_FileFormat::FF_XML_TEC;
1067  }
1068 #endif
1069 #if HAVE_TO_DATAFILE_BUILT
1070  if(root->get_name() == STR_XML_latex_table_root)
1071  {
1072  INDENT_DBG_MEX(DEBUG_LEVEL_VERY_PEDANTIC, debug_level, "<--Latex table format");
1074  }
1075 #endif
1076 #endif
1077  }
1080  }
1081 #if HAVE_FROM_C_BUILT
1082  if(std::filesystem::exists(file_name))
1083  {
1084  const auto opened_file = fileIO_istream_open(file_name.string());
1085  std::string line;
1086  if(!opened_file->eof())
1087  {
1088  getline(*opened_file, line);
1089  if(line.find(STOK(TOK_COMPILER_VERSION)) != std::string::npos)
1090  {
1092  return Parameters_FileFormat::FF_RAW;
1093  }
1094  }
1095  }
1096 #endif
1098 }
1099 
1100 void Parameter::PrintBugReport(std::ostream& os) const
1101 {
1102  os << "Please report bugs to <" << PACKAGE_BUGREPORT << ">\n" << std::endl;
1103 }
1104 
1105 void Parameter::PrintGeneralOptionsUsage(std::ostream& os) const
1106 {
1107  os << " General options:\n\n"
1108  << " --help, -h\n"
1109  << " Display this usage information.\n\n"
1110  << " --version, -V\n"
1111  << " Display the version of the program.\n\n"
1112  << " --seed=<number>\n"
1113  << " Set the seed of the random number generator (default=0).\n\n"
1114 #if !RELEASE
1115  << " --read-parameters-XML=<xml_file_name>\n"
1116  << " Read command line options from a XML file.\n\n"
1117  << " --write-parameters-XML=<xml_file_name>\n"
1118  << " Dump the parsed command line options into a XML file.\n\n"
1119 #endif
1120  << std::endl;
1121 }
1122 
1123 void Parameter::PrintOutputOptionsUsage(std::ostream& os) const
1124 {
1125  os << " Output options:\n\n"
1126  << " --verbosity, -v <level>\n"
1127  << " Set the output verbosity level\n"
1128  << " Possible values for <level>:\n"
1129  << " 0 - NONE\n"
1130  << " 1 - MINIMUM\n"
1131  << " 2 - VERBOSE\n"
1132  << " 3 - PEDANTIC\n"
1133  << " 4 - VERY PEDANTIC\n"
1134  << " (default = 1)\n"
1135  << "\n"
1136 #if !RELEASE
1137  << " --debug, -d <level>\n"
1138  << " Set the verbosity level of debugging information\n"
1139  << " Possible values for <level>:\n"
1140  << " 0 - NONE\n"
1141  << " 1 - MINIMUM\n"
1142  << " 2 - VERBOSE\n"
1143  << " 3 - PEDANTIC\n"
1144  << " 4 - VERY PEDANTIC\n"
1145  << " (default = 1).\n\n"
1146  << " --debug-classes=<classes_list>\n"
1147  << " Set maximum debug level for classes in <classes_list>\n\n"
1148  << " --max-transformations=<number>\n"
1149  << " Set a maximum number of transformations.\n\n"
1150  << " To reduce the disk usage two PandA parameter could be used:\n"
1151  << " --panda-parameter=print-tree-manager=0\n"
1152  << " --panda-parameter=print-dot-FF=0\n\n"
1153  << " --find-max-transformations\n"
1154  << " Find the maximum number of transformations raising an exception.\n\n"
1155 #endif
1156  << " --no-clean\n"
1157  << " Do not remove temporary files.\n\n"
1158  << " --benchmark-name=<name>\n"
1159  << " Set the name of the current benchmark for data collection.\n"
1160  << " Mainly useful for data collection from extensive regression tests.\n\n"
1161  << " --configuration-name=<name>\n"
1162  << " Set the name of the current tool configuration for data collection.\n"
1163  << " Mainly useful for data collection from extensive regression tests.\n\n"
1164  << " --benchmark-fake-parameters\n"
1165  << " Set the parameters string for data collection. The parameters in the\n"
1166  << " string are not actually used, but they are used for data collection in\n"
1167  << " extensive regression tests.\n\n"
1168  << " --output-temporary-directory=<path>\n"
1169  << " Set the directory where temporary files are saved.\n"
1170  << " Default is '" << STR_CST_temporary_directory << "'\n\n"
1171  << " --print-dot\n"
1172  << " Dump to file several different graphs used in the IR of the tool.\n"
1173  << " The graphs are saved in .dot files, in graphviz format\n\n"
1174 #if !RELEASE
1175  << " --error-on-warning\n"
1176  << " Convert all runtime warnings to errors.\n\n"
1177 #endif
1178  ;
1179 }
1180 
1181 #if HAVE_FROM_C_BUILT
1182 void Parameter::PrintGccOptionsUsage(std::ostream& os) const
1183 {
1184  os << " GCC/CLANG front-end compiler options:\n\n"
1185  << " --compiler=<compiler_version>\n"
1186  << " Specify which compiler is used.\n"
1187  << " Possible values for <compiler_version> are:\n"
1188 #if HAVE_I386_GCC49_COMPILER
1189  << " I386_GCC49\n"
1190 #endif
1191 #if HAVE_I386_GCC5_COMPILER
1192  << " I386_GCC5\n"
1193 #endif
1194 #if HAVE_I386_GCC6_COMPILER
1195  << " I386_GCC6\n"
1196 #endif
1197 #if HAVE_I386_GCC7_COMPILER
1198  << " I386_GCC7\n"
1199 #endif
1200 #if HAVE_I386_GCC8_COMPILER
1201  << " I386_GCC8\n"
1202 #endif
1203 #if HAVE_I386_CLANG4_COMPILER
1204  << " I386_CLANG4\n"
1205 #endif
1206 #if HAVE_I386_CLANG5_COMPILER
1207  << " I386_CLANG5\n"
1208 #endif
1209 #if HAVE_I386_CLANG6_COMPILER
1210  << " I386_CLANG6\n"
1211 #endif
1212 #if HAVE_I386_CLANG7_COMPILER
1213  << " I386_CLANG7\n"
1214 #endif
1215 #if HAVE_I386_CLANG8_COMPILER
1216  << " I386_CLANG8\n"
1217 #endif
1218 #if HAVE_I386_CLANG9_COMPILER
1219  << " I386_CLANG9\n"
1220 #endif
1221 #if HAVE_I386_CLANG10_COMPILER
1222  << " I386_CLANG10\n"
1223 #endif
1224 #if HAVE_I386_CLANG11_COMPILER
1225  << " I386_CLANG11\n"
1226 #endif
1227 #if HAVE_I386_CLANG12_COMPILER
1228  << " I386_CLANG12\n"
1229 #endif
1230 #if HAVE_I386_CLANG13_COMPILER
1231  << " I386_CLANG13\n"
1232 #endif
1233 #if HAVE_I386_CLANG16_COMPILER
1234  << " I386_CLANG16\n"
1235 #endif
1236 #if HAVE_I386_CLANGVVD_COMPILER
1237  << " I386_CLANGVVD\n"
1238 #endif
1239  << "\n"
1240  << " -O<level>\n"
1241  << " Enable a specific optimization level. Possible values are the usual\n"
1242  << " optimization flags accepted by compilers, plus some others:\n"
1243  << " -O0,-O1,-O2,-O3,-Os,-O4,-O5.\n\n"
1244  << " -f<option>\n"
1245  << " Enable or disable a GCC/CLANG optimization option. All the -f or -fno options\n"
1246  << " are supported. In particular, -ftree-vectorize option triggers the\n"
1247  << " high-level synthesis of vectorized operations.\n\n"
1248  << " -I<path>\n"
1249  << " Specify a path where headers are searched for.\n\n"
1250  << " -W<warning>\n"
1251  << " Specify a warning option passed to GCC/CLANG. All the -W options available in\n"
1252  << " GCC/CLANG are supported.\n\n"
1253  << " -E\n"
1254  << " Enable preprocessing mode of GCC/CLANG.\n\n"
1255  << " --std=<standard>\n"
1256  << " Assume that the input sources are for <standard>. All\n"
1257  << " the --std options available in GCC/CLANG are supported.\n"
1258  << " The default value is gnu90/gnu11 for C and gnu++98/gnu++14 for C++ \n"
1259  << " depending on the selected frontend compiler support.\n\n"
1260  << " -D<name>\n"
1261  << " Predefine name as a macro, with definition 1.\n\n"
1262  << " -D<name=definition>\n"
1263  << " Tokenize <definition> and process as if it appeared as a #define directive.\n\n"
1264  << " -U<name>\n"
1265  << " Remove existing definition for macro <name>.\n\n"
1266  << " --param <name>=<value>\n"
1267  << " Set the amount <value> for the GCC/CLANG parameter <name> that could be used for\n"
1268  << " some optimizations.\n\n"
1269  << " -l<library>\n"
1270  << " Search the library named <library> when linking.\n\n"
1271  << " -L<dir>\n"
1272  << " Add directory <dir> to the list of directories to be searched for -l.\n\n"
1273  << " --use-raw\n"
1274  << " Specify that input file is already a raw file and not a source file.\n\n"
1275  << " -m<machine-option>\n"
1276  << " Specify machine dependend options (currently not used).\n\n"
1277 #if !RELEASE
1278  << " --read-GCC-XML=<xml_file_name>\n"
1279  << " Read GCC options from a XML file.\n\n"
1280  << " --write-GCC-XML=<xml_file_name>\n"
1281  << " Dump the parsed GCC/CLANG compiler options into a XML file.\n\n"
1282 #endif
1283  << " --Include-sysdir\n"
1284  << " Return the system include directory used by the wrapped GCC/CLANG compiler.\n\n"
1285  << " --gcc-config\n"
1286  << " Return the GCC/CLANG configuration.\n\n"
1287 #if !RELEASE
1288  << " --compute-sizeof\n"
1289  << " Replace sizeof with the computed valued for the considered target\n"
1290  << " architecture.\n\n"
1291 #endif
1292  << " --extra-gcc-options\n"
1293  << " Specify custom extra options to the compiler.\n\n"
1294  << std::endl;
1295 }
1296 #endif
1297 
1298 template <>
1300 {
1301  return string_to_container<CustomSet<std::string>>(getOption<std::string>(name), STR_CST_string_separator);
1302 }
1303 
1304 template <>
1305 std::list<std::string> Parameter::getOption(const enum enum_option name) const
1306 {
1307  return string_to_container<std::list<std::string>>(getOption<std::string>(name), STR_CST_string_separator);
1308 }
1309 
1310 template <>
1311 std::vector<std::string> Parameter::getOption(const enum enum_option name) const
1312 {
1313  return string_to_container<std::vector<std::string>>(getOption<std::string>(name), STR_CST_string_separator);
1314 }
1315 
1316 const std::vector<std::string> Parameter::CGetArgv() const
1317 {
1318  std::vector<std::string> ret;
1319  for(int arg = 0; arg < argc; arg++)
1320  {
1321  ret.push_back(std::string(argv[arg]));
1322  }
1323  return ret;
1324 }
1325 
1326 #if HAVE_HOST_PROFILING_BUILT
1327 template <>
1329 {
1330  return static_cast<HostProfiling_Method>(getOption<int>(name));
1331 }
1332 #endif
1333 
1334 #if HAVE_FROM_C_BUILT
1335 template <>
1337 {
1338  return static_cast<CompilerWrapper_CompilerTarget>(getOption<int>(name));
1339 }
1340 #endif
1341 
1342 template <>
1344 {
1345  return static_cast<Parameters_FileFormat>(getOption<int>(name));
1346 }
1347 
1348 #if HAVE_FROM_C_BUILT
1349 template <>
1351 {
1352  return static_cast<CompilerWrapper_OptimizationSet>(getOption<int>(name));
1353 }
1354 template <>
1356 {
1357  enum_options[name] = std::to_string(static_cast<int>(value));
1358 }
1359 #endif
1360 
1361 #if HAVE_TO_C_BUILT
1362 template <>
1364 {
1365  return static_cast<ActorGraphBackend_Type>(getOption<int>(name));
1366 }
1367 #endif
1368 #if HAVE_HLS_BUILT
1369 template <>
1370 HLSFlowStep_Type Parameter::getOption(const enum enum_option name) const
1371 {
1372  return static_cast<HLSFlowStep_Type>(getOption<int>(name));
1373 }
1374 
1375 template <>
1376 void Parameter::setOption(const enum enum_option name, const HLSFlowStep_Type hls_flow_step_type)
1377 {
1378  enum_options[name] = std::to_string(static_cast<int>(hls_flow_step_type));
1379 }
1380 
1381 template <>
1383 {
1384  return static_cast<MemoryAllocation_Policy>(getOption<int>(name));
1385 }
1386 
1387 template <>
1388 void Parameter::setOption(const enum enum_option name, const MemoryAllocation_Policy memory_allocation_policy)
1389 {
1390  enum_options[name] = std::to_string(static_cast<int>(memory_allocation_policy));
1391 }
1392 
1393 template <>
1395 {
1396  return static_cast<MemoryAllocation_ChannelsType>(getOption<int>(name));
1397 }
1398 
1399 template <>
1400 void Parameter::setOption(const enum enum_option name,
1401  const MemoryAllocation_ChannelsType memory_allocation_channels_type)
1402 {
1403  enum_options[name] = std::to_string(static_cast<int>(memory_allocation_channels_type));
1404 }
1405 
1406 template <>
1408 {
1409  return static_cast<CliqueCovering_Algorithm>(getOption<int>(name));
1410 }
1411 
1412 template <>
1413 void Parameter::setOption(const enum enum_option name, const CliqueCovering_Algorithm clique_covering_algorithm)
1414 {
1415  enum_options[name] = std::to_string(static_cast<int>(clique_covering_algorithm));
1416 }
1417 
1418 template <>
1419 Evaluation_Mode Parameter::getOption(const enum enum_option name) const
1420 {
1421  return static_cast<Evaluation_Mode>(getOption<int>(name));
1422 }
1423 
1424 template <>
1425 void Parameter::setOption(const enum enum_option name, const Evaluation_Mode evaluation_mode)
1426 {
1427  enum_options[name] = std::to_string(static_cast<int>(evaluation_mode));
1428 }
1429 
1430 template <>
1432 {
1433  return static_cast<ParametricListBased_Metric>(getOption<int>(name));
1434 }
1435 
1436 template <>
1437 void Parameter::setOption(const enum enum_option name, const ParametricListBased_Metric parametric_list_based_metric)
1438 {
1439  enum_options[name] = std::to_string(static_cast<int>(parametric_list_based_metric));
1440 }
1441 
1442 template <>
1443 SDCScheduling_Algorithm Parameter::getOption(const enum enum_option name) const
1444 {
1445  return static_cast<SDCScheduling_Algorithm>(getOption<int>(name));
1446 }
1447 
1448 template <>
1449 void Parameter::setOption(const enum enum_option name, const SDCScheduling_Algorithm sdc_scheduling_algorithm)
1450 {
1451  enum_options[name] = std::to_string(static_cast<int>(sdc_scheduling_algorithm));
1452 }
1453 
1454 #endif
1455 bool Parameter::IsParameter(const std::string& name) const
1456 {
1457  return panda_parameters.find(name) != panda_parameters.end();
1458 }
void write_xml_configuration_file(const std::string &filename)
Write an XML configuration file with the parameters actually stored.
Definition: Parameter.cpp:266
std::map< enum enum_option, std::string > enum_options
Map between an enum option and the related string-form value.
Definition: Parameter.hpp:320
#define BAMBU_OPTIONS
Definition: Parameter.hpp:96
xml nodes used in file specifying latex table format
#define DEBUG_LEVEL_VERY_PEDANTIC
extremely verbose debugging print is performed.
void load_xml_configuration_file_rec(const xml_element *node)
Loads an XML configuration file (recursive method)
Definition: Parameter.cpp:193
#define INPUT_OPT_ERROR_ON_WARNING
Definition: Parameter.hpp:190
#define INDENT_DBG_MEX(dbgLevel, curDbgLevel, mex)
We are producing a debug version of the program, so the message is printed;.
#define TREE_PANDA_COMPILER_OPTIONS
Definition: Parameter.hpp:153
#define INPUT_OPT_NO_CLEAN
Definition: Parameter.hpp:194
void setOption(const std::string &name, const G value)
Sets the value of an option.
Definition: Parameter.hpp:516
File containing functions and utilities to support the printing of debug messagges.
xml nodes used in technology libraries files
#define STOK(token)
Macro used to convert a token symbol into the corresponding string.
#define OUTPUT_LEVEL_NONE
no output print is performed.
#define OPT_READ_PARAMETERS_XML
Definition: Parameter.hpp:185
#define STR_CST_string_separator
The character used to separate concatenated string.
Definition: utility.hpp:61
std::string filename
#define SPIDER_OPTIONS
Definition: Parameter.hpp:146
char **const argv
The input parameters;.
Definition: Parameter.hpp:311
const std::vector< std::string > SplitString(const std::string &input, const std::string &separators)
Function which splits a string into tokens.
#define OPT_WRITE_PARAMETERS_XML
Definition: Parameter.hpp:186
int GetFunctionDebugLevel(const std::string &class_name, const std::string &function_name) const
Return the debug_level of a function.
Definition: Parameter.cpp:342
void PrintBugReport(std::ostream &os) const
Print the bug report request.
Definition: Parameter.cpp:1100
#define STR_XML_technology_root
The root node of technology libraries file.
virtual ~Parameter()
Destructor.
MemoryAllocation_ChannelsType
The number of channels.
static bool hasCompilerM64(CompilerWrapper_CompilerTarget ct)
#define STR_XML_constraints_root
The root node of constraints file.
bool error_on_warning
Transform warning into errors.
void print(std::ostream &os) const
Definition: Parameter.cpp:308
A simple interface to token object of the raw files.
#define INPUT_OPT_COMPILER
Definition: Parameter.hpp:225
#define CE_XVM(variable, node)
Check existence XML Value Macro. Check if an XML attribute is present in the XML tree.
Definition: xml_helper.hpp:88
#define DEBUG_LEVEL_INFINITE
everything is printed.
#define INPUT_OPT_CONFIGURATION_NAME
Definition: Parameter.hpp:195
CliqueCovering_Algorithm
Defines all clique covering algorithm.
#define INPUT_OPT_GCC_CONFIG
Definition: Parameter.hpp:226
#define STR_CST_temporary_directory
The temporary directory pattern.
#define OPTION_NAME(r, data, elem)
Definition: Parameter.cpp:105
void SetCommonDefaults()
Sets the default values common to all tools.
Definition: Parameter.cpp:281
#define OPT_BENCHMARK_NAME
Definition: Parameter.hpp:188
CompilerWrapper_OptimizationSet
Possible optimization sets.
void PrintUsage(std::ostream &os) const
Print the usage of this tool = PrintHeader() + PrintHelp()
Definition: Parameter.cpp:392
void line(int x1, int y1, int x2, int y2, unsigned int color)
Definition: main.c:110
Auxiliary methods for manipulating string.
#define max
Definition: backprop.h:17
std::string PrintVersion() const
This function prints the version of the tool.
Definition: Parameter.cpp:387
#define INPUT_OPT_READ_GCC_XML
Definition: Parameter.hpp:229
Parameters_FileFormat GetFileFormat(const std::filesystem::path &file, bool check_cml_root_node=false) const
Return the file format given the file name or the extension.
Definition: Parameter.cpp:938
#define INPUT_OPT_PRINT_DOT
Definition: Parameter.hpp:192
std::filesystem::path unique_path(const std::filesystem::path &model)
Definition: fileIO.cpp:286
Evaluation_Mode
Definition: evaluation.hpp:52
#define FRAMEWORK_OPTIONS
Definition: Parameter.hpp:126
Parameter(const std::string &program_name, int argc, char **const argv, int debug_level=0)
Constructor.
Definition: Parameter.cpp:107
#define STR_XML_experimental_setup_root
The root node.
#define OPT_BENCHMARK_FAKE_PARAMETERS
Definition: Parameter.hpp:189
const std::string revision_hash
Definition: Parameter.cpp:101
#define EUCALIPTUS_OPTIONS
Definition: Parameter.hpp:151
#define INPUT_OPT_MAX_TRANSFORMATIONS
Definition: Parameter.hpp:196
HostProfiling_Method
Different profiling method.
enum_option
Possible options.
Definition: Parameter.hpp:159
HLSFlowStep_Type
Definition: hls_step.hpp:95
#define GET_NODE_NAME(node)
Definition: xml_helper.hpp:85
#define OPT_DEBUG_CLASSES
Definition: Parameter.hpp:187
bool IsParameter(const std::string &name) const
Return if a parameter has been set.
Definition: Parameter.cpp:1455
void write_to_file_formatted(const std::filesystem::path &filename)
Write the document to a file.
virtual void CheckParameters()=0
Checks the compatibility among the different parameters and determines the implications.
Definition: Parameter.cpp:139
virtual void PrintFullHeader(std::ostream &os) const
This function prints the header of the tool = PrintProgramName() + PrintVersion() ...
Definition: Parameter.cpp:368
#define STR_XML_technology_target_root
The root node of target file.
xml_element * create_root_node(const std::string &_name)
Creates the root node.
#define INPUT_OPT_COMPUTE_SIZEOF
Definition: Parameter.hpp:224
XML DOM parser.
XML DOM parser.
utility function used to read files.
CompilerWrapper_CompilerTarget
target of the compiler
#define INPUT_OPT_STD
Definition: Parameter.hpp:230
This file collects some utility functions and macros.
void Exec()
Parse an XML document from a file.
#define INPUT_OPT_PARAM
Definition: Parameter.hpp:228
fileIO_istreamRef fileIO_istream_open(const std::string &name)
this function returns an istream compressed or not.
Definition: fileIO.cpp:55
(Input) comma separated value
std::list< xml_nodeRef > node_list
type for list of xml nodes
Definition: xml_node.hpp:90
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
const std::vector< std::string > CGetArgv() const
Return argv.
Definition: Parameter.cpp:1316
static bool hasCompilerGCCM32(CompilerWrapper_CompilerTarget ct)
static bool hasCompilerMX32(CompilerWrapper_CompilerTarget ct)
OptionMap Options
Map between the name of the option and the related string-form value.
Definition: Parameter.hpp:314
#define INPUT_OPT_CUSTOM_OPTIONS
Definition: Parameter.hpp:223
Template definition of refcount.
#define WRITE_XNVM2(name, value, node)
WRITE XML Name Value Macro second version. Insert a value in an XML tree given the name of the attrib...
Definition: xml_helper.hpp:58
static bool hasCompilerCLANGM32(CompilerWrapper_CompilerTarget ct)
int get_class_debug_level(const std::string &class_name, int debug_level=-1) const
Return the debug level for a specific class.
Definition: Parameter.cpp:323
ActorGraphBackend_Type
C thread backend to be used.
int debug_level
debug level
Definition: Parameter.hpp:329
#define INPUT_OPT_INCLUDE_SYSDIR
Definition: Parameter.hpp:227
#define STR_XML_latex_table_root
The root node.
#define INPUT_OPT_PANDA_PARAMETER
Definition: Parameter.hpp:198
std::string GetPath(std::filesystem::path path)
Definition: fileIO.hpp:140
ParametricListBased_Metric
#define INPUT_OPT_FIND_MAX_TRANSFORMATIONS
Definition: Parameter.hpp:197
static std::string getCompilerVersion(int ct)
#define STR_OPT_benchmark_fake_parameters
Parameter of the current benchmark for table results (this value is not used for profiling) ...
(Output) Latex table
CustomUnorderedSet< std::string > debug_classes
Classes to be debugged.
Definition: Parameter.hpp:326
#define SYNTHESIS_OPTIONS
Definition: Parameter.hpp:142
xml nodes used in file specifying experimental setup
xml_documentRef get_document()
Obtain the parsed document.
Parameters_FileFormat
File formats.
Definition: Parameter.hpp:261
(Input) XML storing experimental setup
(Input) XML storing format of latex table to be produced
#define INPUT_OPT_SEED
Definition: Parameter.hpp:193
#define GET_STRING_VALUE(node)
LOAD XML Value Macro.
Definition: xml_helper.hpp:83
this class is used to manage the command-line or XML options.
void getOption(const std::string &name, G &variable) const
Returns the value of an option.
Definition: Parameter.hpp:457
constant strings
Some macro used to interface with the XML library.
node_list const & get_children()
Obtain the list of child nodes.
Definition: xml_node.hpp:310
std::string GetCurrentPath()
Definition: fileIO.hpp:123
const std::string branch_name
Definition: Parameter.cpp:97
void PrintGeneralOptionsUsage(std::ostream &os) const
Print the usage of the general common options.
Definition: Parameter.cpp:1105
#define INPUT_OPT_USE_RAW
Definition: Parameter.hpp:231
bool isOption(const std::string &name) const
Tests if an option has been stored.
Definition: Parameter.hpp:548
void PrintOutputOptionsUsage(std::ostream &os) const
Print the usage of the output common options.
Definition: Parameter.cpp:1123
#define PRINT_OUT_MEX(profLevel, curprofLevel, mex)
int argc
The number of input paramters.
Definition: Parameter.hpp:308
void add_debug_class(const std::string &class_name)
Add a class to be debugged.
Definition: Parameter.cpp:361
#define OPT_OUTPUT_TEMPORARY_DIRECTORY
Definition: Parameter.hpp:191
bool ManageDefaultOptions(int next_option, char *optarg_param, bool &exit_success)
Manage default options (common to all tools)
Definition: Parameter.cpp:398
#define INPUT_OPT_WRITE_GCC_XML
Definition: Parameter.hpp:232
int opt_level
Definition: lenet_tvm.py:15
virtual void PrintProgramName(std::ostream &os) const =0
Print the name of the program to be included in the header.
xml_element * add_child_element(const std::string &name)
Add a child element to this node.
Definition: xml_node.cpp:54
void load_xml_configuration_file(const std::string &filename)
Loads an XML configuration file.
Definition: Parameter.cpp:216
MemoryAllocation_Policy
The allocation memory polycy.
xml nodes used in HLS constraints file
#define STR_CST_debug_all
Parameters.
static std::string getCompilerSuffix(CompilerWrapper_CompilerTarget pc)
virtual void PrintHelp(std::ostream &os) const =0
Print the help.
CustomMap< std::string, std::string > panda_parameters
Map between the name of a parameter and the related string-form value.
Definition: Parameter.hpp:317
#define COMPILER_OPTIONS
Definition: Parameter.hpp:136
std::map< enum enum_option, std::string > option_name
Name of the enum options.
Definition: Parameter.hpp:323
#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
Implementation of the wrapper to Gcc for C sources.

Generated on Mon Feb 12 2024 13:02:54 for PandA-2024.02 by doxygen 1.8.13