PandA-2024.02
|
#include <Parameter.hpp>
Public Member Functions | |
Parameter (const std::string &program_name, int argc, char **const argv, int debug_level=0) | |
Constructor. More... | |
Parameter (const Parameter &other) | |
Copy Constructor. More... | |
virtual | ~Parameter () |
Destructor. More... | |
void | load_xml_configuration_file (const std::string &filename) |
Loads an XML configuration file. More... | |
void | write_xml_configuration_file (const std::string &filename) |
Write an XML configuration file with the parameters actually stored. More... | |
virtual int | Exec ()=0 |
Execute parameter parsing. More... | |
virtual void | CheckParameters ()=0 |
Checks the compatibility among the different parameters and determines the implications. More... | |
template<typename G > | |
void | getOption (const std::string &name, G &variable) const |
Returns the value of an option. More... | |
template<typename G > | |
void | getOption (const char *name, G &variable) const |
Returns the value of an option. More... | |
template<typename G > | |
G | getOption (const std::string &name) const |
Returns the value of an option. More... | |
template<typename G > | |
G | getOption (const char *name) const |
Returns the value of an option. More... | |
template<typename G > | |
G | getOption (const enum enum_option name) const |
Returns the value of an option. More... | |
template<typename G > | |
void | setOption (const std::string &name, const G value) |
Sets the value of an option. More... | |
template<typename G > | |
void | setOption (const char *name, const G value) |
Sets the value of an option. More... | |
template<typename G > | |
void | setOption (const enum enum_option name, const G value) |
Sets the value of an option. More... | |
bool | isOption (const std::string &name) const |
Tests if an option has been stored. More... | |
bool | isOption (const char *name) const |
Tests if an option has been stored. More... | |
bool | isOption (const enum enum_option name) const |
Tests if an option has been stored. More... | |
bool | removeOption (const enum enum_option name) |
Remove an option. More... | |
bool | removeOption (const char *name) |
Remove an option. More... | |
bool | removeOption (const std::string &name) |
Remove an option. More... | |
int | get_class_debug_level (const std::string &class_name, int debug_level=-1) const |
Return the debug level for a specific class. More... | |
int | GetFunctionDebugLevel (const std::string &class_name, const std::string &function_name) const |
Return the debug_level of a function. More... | |
void | print (std::ostream &os) const |
void | add_debug_class (const std::string &class_name) |
Add a class to be debugged. More... | |
void | PrintUsage (std::ostream &os) const |
Print the usage of this tool = PrintHeader() + PrintHelp() More... | |
std::string | PrintVersion () const |
This function prints the version of the tool. More... | |
virtual void | PrintFullHeader (std::ostream &os) const |
This function prints the header of the tool = PrintProgramName() + PrintVersion() More... | |
void | PrintBugReport (std::ostream &os) const |
Print the bug report request. More... | |
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. More... | |
template<typename G > | |
G | GetParameter (const std::string &name) const |
Returns the value of a parameter. More... | |
bool | IsParameter (const std::string &name) const |
Return if a parameter has been set. More... | |
const std::vector< std::string > | CGetArgv () const |
Return argv. More... | |
template<> | |
CustomSet< std::string > | getOption (const enum enum_option name) const |
template<> | |
std::list< std::string > | getOption (const enum enum_option name) const |
template<> | |
std::vector< std::string > | getOption (const enum enum_option name) const |
template<> | |
Parameters_FileFormat | getOption (const enum enum_option name) const |
Protected Member Functions | |
void | load_xml_configuration_file_rec (const xml_element *node) |
Loads an XML configuration file (recursive method) More... | |
bool | ManageDefaultOptions (int next_option, char *optarg_param, bool &exit_success) |
Manage default options (common to all tools) More... | |
void | PrintGeneralOptionsUsage (std::ostream &os) const |
Print the usage of the general common options. More... | |
void | PrintOutputOptionsUsage (std::ostream &os) const |
Print the usage of the output common options. More... | |
virtual void | SetDefaults ()=0 |
Sets the default values with respect to the tool. More... | |
void | SetCommonDefaults () |
Sets the default values common to all tools. More... | |
virtual void | PrintProgramName (std::ostream &os) const =0 |
Print the name of the program to be included in the header. More... | |
virtual void | PrintHelp (std::ostream &os) const =0 |
Print the help. More... | |
Protected Attributes | |
int | argc |
The number of input paramters. More... | |
char **const | argv |
The input parameters;. More... | |
OptionMap | Options |
Map between the name of the option and the related string-form value. More... | |
CustomMap< std::string, std::string > | panda_parameters |
Map between the name of a parameter and the related string-form value. More... | |
std::map< enum enum_option, std::string > | enum_options |
Map between an enum option and the related string-form value. More... | |
std::map< enum enum_option, std::string > | option_name |
Name of the enum options. More... | |
CustomUnorderedSet< std::string > | debug_classes |
Classes to be debugged. More... | |
int | debug_level |
debug level More... | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const Parameter &s) |
Friend definition of the << operator. More... | |
Definition at line 304 of file Parameter.hpp.
Parameter::Parameter | ( | const std::string & | program_name, |
int | argc, | ||
char **const | argv, | ||
int | debug_level = 0 |
||
) |
Constructor.
program_name | is the name of the executable |
argc | is the number of arguments |
argv | is the array of arguments passed to program. |
debug_level | is the debug level |
Definition at line 107 of file Parameter.cpp.
References BAMBU_OPTIONS, BOOST_PP_SEQ_FOR_EACH, COMPILER_OPTIONS, EUCALIPTUS_OPTIONS, FRAMEWORK_OPTIONS, OPTION_NAME, option_name, SetCommonDefaults(), setOption(), SPIDER_OPTIONS, SYNTHESIS_OPTIONS, and TREE_PANDA_COMPILER_OPTIONS.
Parameter::Parameter | ( | const Parameter & | other | ) |
|
virtualdefault |
void Parameter::add_debug_class | ( | const std::string & | class_name | ) |
Add a class to be debugged.
Definition at line 361 of file Parameter.cpp.
References debug_classes.
Referenced by ManageDefaultOptions().
const std::vector< std::string > Parameter::CGetArgv | ( | ) | const |
Return argv.
Definition at line 1316 of file Parameter.cpp.
References test_panda::arg, argc, argv, and getOption().
|
pure virtual |
Checks the compatibility among the different parameters and determines the implications.
Output directory is not removed since it can be the current one
Implemented in BambuParameter, EucalyptusParameter, SpiderParameter, and tree_panda_gcc_parameter.
Definition at line 139 of file Parameter.cpp.
References CompilerWrapper::getCompilerSuffix(), CompilerWrapper::hasCompilerCLANGM32(), CompilerWrapper::hasCompilerGCCM32(), CompilerWrapper::hasCompilerM64(), CompilerWrapper::hasCompilerMX32(), isOption(), setOption(), THROW_ERROR, and ~Parameter().
Referenced by tree_panda_gcc_parameter::CheckParameters(), SpiderParameter::CheckParameters(), BambuParameter::CheckParameters(), and EucalyptusParameter::CheckParameters().
|
pure virtual |
Execute parameter parsing.
It has to be specialized
Implemented in BambuParameter, EucalyptusParameter, SpiderParameter, and tree_panda_gcc_parameter.
int Parameter::get_class_debug_level | ( | const std::string & | class_name, |
int | debug_level = -1 |
||
) | const |
Return the debug level for a specific class.
name | is the name the class |
Definition at line 323 of file Parameter.cpp.
References debug_classes, DEBUG_LEVEL_INFINITE, and STR_CST_debug_all.
Referenced by BambuParameter::CheckParameters(), and GetFunctionDebugLevel().
Parameters_FileFormat Parameter::GetFileFormat | ( | const std::filesystem::path & | file, |
bool | check_cml_root_node = false |
||
) | const |
Return the file format given the file name or the extension.
file | is the file name or the extension |
check_cml_root_node | tells xml file has to be analyzed |
Definition at line 938 of file Parameter.cpp.
References debug_level, DEBUG_LEVEL_VERY_PEDANTIC, FF_CSV, FF_TEX, FF_UNKNOWN, FF_VERILOG, FF_VHDL, FF_XML, FF_XML_EXPERIMENTAL_SETUP, FF_XML_TEX_TABLE, fileIO_istream_open(), INDENT_DBG_MEX, line(), test_panda::parser, STOK, STR_XML_constraints_root, STR_XML_experimental_setup_root, STR_XML_latex_table_root, STR_XML_technology_root, STR_XML_technology_target_root, THROW_ASSERT, and TOK_COMPILER_VERSION.
Referenced by SpiderParameter::CheckParameters(), and BambuParameter::Exec().
int Parameter::GetFunctionDebugLevel | ( | const std::string & | class_name, |
const std::string & | function_name | ||
) | const |
Return the debug_level of a function.
class_name | is the name of the class |
function_name | is the name of the function |
Definition at line 342 of file Parameter.cpp.
References debug_classes, DEBUG_LEVEL_INFINITE, and get_class_debug_level().
|
inline |
Returns the value of an option.
name | is the name of the option |
variable | is the variable where the value of the option will be saved |
Definition at line 457 of file Parameter.hpp.
References THROW_ASSERT.
Referenced by CGetArgv(), SpiderParameter::CheckParameters(), BambuParameter::CheckParameters(), getOption(), and GetParameter().
|
inline |
Returns the value of an option.
name | is the name of the option |
variable | is the variable where the value of the option will be saved |
Definition at line 469 of file Parameter.hpp.
|
inline |
Returns the value of an option.
name | is the name of the option |
return | the value of the option |
Definition at line 480 of file Parameter.hpp.
References THROW_ASSERT.
|
inline |
Returns the value of an option.
name | is the name of the option |
return | the value of the option |
Definition at line 492 of file Parameter.hpp.
|
inline |
Returns the value of an option.
name | is the name of the option |
return | the value of the option |
Definition at line 503 of file Parameter.hpp.
References THROW_ASSERT.
CustomSet< std::string > Parameter::getOption | ( | const enum enum_option | name | ) | const |
Definition at line 1299 of file Parameter.cpp.
References STR_CST_string_separator.
std::list< std::string > Parameter::getOption | ( | const enum enum_option | name | ) | const |
Definition at line 1305 of file Parameter.cpp.
References STR_CST_string_separator.
std::vector< std::string > Parameter::getOption | ( | const enum enum_option | name | ) | const |
Definition at line 1311 of file Parameter.cpp.
References STR_CST_string_separator.
Parameters_FileFormat Parameter::getOption | ( | const enum enum_option | name | ) | const |
Definition at line 1343 of file Parameter.cpp.
References enum_options, getOption(), setOption(), and symmetry::value.
|
inline |
Returns the value of a parameter.
name | is the name of the parameter |
return | the value of the parameter |
Definition at line 671 of file Parameter.hpp.
References getOption(), setOption(), THROW_ASSERT, and symmetry::value.
|
inline |
Tests if an option has been stored.
name | is the name of the option |
Definition at line 548 of file Parameter.hpp.
Referenced by BambuParameter::add_bambu_library(), BambuParameter::add_experimental_setup_compiler_options(), tree_panda_gcc_parameter::CheckParameters(), SpiderParameter::CheckParameters(), EucalyptusParameter::CheckParameters(), BambuParameter::CheckParameters(), CheckParameters(), tree_panda_gcc_parameter::Exec(), SpiderParameter::Exec(), BambuParameter::Exec(), ManageDefaultOptions(), and BambuParameter::SetDefaults().
|
inline |
Tests if an option has been stored.
name | is the name of the option |
Definition at line 558 of file Parameter.hpp.
|
inline |
Tests if an option has been stored.
name | is the name of the option |
Definition at line 568 of file Parameter.hpp.
bool Parameter::IsParameter | ( | const std::string & | name | ) | const |
Return if a parameter has been set.
name | is the name of the parameter |
Definition at line 1455 of file Parameter.cpp.
References panda_parameters.
void Parameter::load_xml_configuration_file | ( | const std::string & | filename | ) |
Loads an XML configuration file.
filename | is the configuration file name to be loaded |
general options
Definition at line 216 of file Parameter.cpp.
References CE_XVM, XMLDomParser::Exec(), xml_child::get_children(), XMLDomParser::get_document(), GET_NODE_NAME, GET_STRING_VALUE, load_xml_configuration_file_rec(), Options, test_panda::parser, and symmetry::value.
Referenced by ManageDefaultOptions().
|
protected |
Loads an XML configuration file (recursive method)
node | is the starting node for the analysis |
general options
Definition at line 193 of file Parameter.cpp.
References CE_XVM, xml_child::get_children(), GET_NODE_NAME, GET_STRING_VALUE, Options, and symmetry::value.
Referenced by load_xml_configuration_file().
|
protected |
Manage default options (common to all tools)
next_option | is the index of the option to be analyzed |
optarg_param | is the optional argument of the option |
exit_success | is where the exit value is stored |
If the path is not absolute, make it into absolute
next_option is not a Tool parameter
Definition at line 398 of file Parameter.cpp.
References add_debug_class(), CT_I386_CLANG10, CT_I386_CLANG11, CT_I386_CLANG12, CT_I386_CLANG13, CT_I386_CLANG16, CT_I386_CLANG4, CT_I386_CLANG5, CT_I386_CLANG6, CT_I386_CLANG7, CT_I386_CLANG8, CT_I386_CLANG9, CT_I386_CLANGVVD, CT_I386_GCC49, CT_I386_GCC5, CT_I386_GCC6, CT_I386_GCC7, CT_I386_GCC8, debug_level, error_on_warning, CompilerWrapper::getCompilerVersion(), GetPath(), INPUT_OPT_COMPILER, INPUT_OPT_COMPUTE_SIZEOF, INPUT_OPT_CONFIGURATION_NAME, INPUT_OPT_CUSTOM_OPTIONS, INPUT_OPT_ERROR_ON_WARNING, INPUT_OPT_FIND_MAX_TRANSFORMATIONS, INPUT_OPT_GCC_CONFIG, INPUT_OPT_INCLUDE_SYSDIR, INPUT_OPT_MAX_TRANSFORMATIONS, INPUT_OPT_NO_CLEAN, INPUT_OPT_PANDA_PARAMETER, INPUT_OPT_PARAM, INPUT_OPT_PRINT_DOT, INPUT_OPT_READ_GCC_XML, INPUT_OPT_SEED, INPUT_OPT_STD, INPUT_OPT_USE_RAW, INPUT_OPT_WRITE_GCC_XML, isOption(), load_xml_configuration_file(), O0, O1, O2, O3, O4, O5, Ofast, Og, OPT_BENCHMARK_FAKE_PARAMETERS, OPT_BENCHMARK_NAME, OPT_DEBUG_CLASSES, lenet_tvm::opt_level, OPT_OUTPUT_TEMPORARY_DIRECTORY, OPT_READ_PARAMETERS_XML, OPT_WRITE_PARAMETERS_XML, Os, OUTPUT_LEVEL_NONE, Oz, panda_parameters, test_panda::parameters, PRINT_OUT_MEX, PrintFullHeader(), PrintUsage(), setOption(), SplitString(), STR_CST_string_separator, STR_CST_temporary_directory, STR_OPT_benchmark_fake_parameters, THROW_ASSERT, THROW_ERROR, and unique_path().
Referenced by tree_panda_gcc_parameter::Exec(), SpiderParameter::Exec(), EucalyptusParameter::Exec(), and BambuParameter::Exec().
void Parameter::print | ( | std::ostream & | os | ) | const |
Definition at line 308 of file Parameter.cpp.
References enum_options, option_name, and Options.
void Parameter::PrintBugReport | ( | std::ostream & | os | ) | const |
Print the bug report request.
os | is the stream where the message has to be printed |
Definition at line 1100 of file Parameter.cpp.
|
virtual |
This function prints the header of the tool = PrintProgramName() + PrintVersion()
Definition at line 368 of file Parameter.cpp.
References PrintProgramName(), and PrintVersion().
Referenced by ManageDefaultOptions(), and PrintUsage().
|
protected |
Print the usage of the general common options.
os | is the stream where to print |
Definition at line 1105 of file Parameter.cpp.
Referenced by tree_panda_gcc_parameter::PrintHelp(), SpiderParameter::PrintHelp(), EucalyptusParameter::PrintHelp(), and BambuParameter::PrintHelp().
|
protectedpure virtual |
Print the help.
os | is the stream on which the help has to be printed |
Implemented in BambuParameter, EucalyptusParameter, SpiderParameter, and tree_panda_gcc_parameter.
Referenced by PrintUsage().
|
protected |
Print the usage of the output common options.
os | is the stream |
Definition at line 1123 of file Parameter.cpp.
References STR_CST_temporary_directory.
Referenced by tree_panda_gcc_parameter::PrintHelp(), SpiderParameter::PrintHelp(), and BambuParameter::PrintHelp().
|
protectedpure virtual |
Print the name of the program to be included in the header.
os | is the stream on which the program name has to be printed |
Implemented in BambuParameter, EucalyptusParameter, SpiderParameter, and tree_panda_gcc_parameter.
Referenced by PrintFullHeader().
void Parameter::PrintUsage | ( | std::ostream & | os | ) | const |
Print the usage of this tool = PrintHeader() + PrintHelp()
os | is the stream where the message has to be printed |
Definition at line 392 of file Parameter.cpp.
References PrintFullHeader(), and PrintHelp().
Referenced by tree_panda_gcc_parameter::Exec(), SpiderParameter::Exec(), EucalyptusParameter::Exec(), BambuParameter::Exec(), and ManageDefaultOptions().
std::string Parameter::PrintVersion | ( | ) | const |
This function prints the version of the tool.
Definition at line 387 of file Parameter.cpp.
Referenced by PrintFullHeader().
|
inline |
Remove an option.
name | is the name of the option |
Definition at line 578 of file Parameter.hpp.
Referenced by BambuParameter::CheckParameters(), and EucalyptusParameter::CheckParameters().
|
inline |
Remove an option.
name | is the name of the option |
Definition at line 593 of file Parameter.hpp.
|
inline |
Remove an option.
name | is the name of the option |
Definition at line 603 of file Parameter.hpp.
References lenet_tvm::file, and print().
|
protected |
Sets the default values common to all tools.
Definition at line 281 of file Parameter.cpp.
References branch_name, GetCurrentPath(), max, revision_hash, setOption(), STR_CST_temporary_directory, and STR_OPT_benchmark_fake_parameters.
Referenced by Parameter().
|
protectedpure virtual |
Sets the default values with respect to the tool.
Implemented in BambuParameter, tree_panda_gcc_parameter, SpiderParameter, and EucalyptusParameter.
|
inline |
Sets the value of an option.
name | is the name of the option |
value | is the value of the option to be saved |
Definition at line 516 of file Parameter.hpp.
References STR.
Referenced by BambuParameter::add_bambu_library(), BambuParameter::add_experimental_setup_compiler_options(), tree_panda_gcc_parameter::CheckParameters(), SpiderParameter::CheckParameters(), BambuParameter::CheckParameters(), EucalyptusParameter::CheckParameters(), CheckParameters(), tree_panda_gcc_parameter::Exec(), SpiderParameter::Exec(), EucalyptusParameter::Exec(), BambuParameter::Exec(), getOption(), GetParameter(), ManageDefaultOptions(), Parameter(), SetCommonDefaults(), EucalyptusParameter::SetDefaults(), SpiderParameter::SetDefaults(), tree_panda_gcc_parameter::SetDefaults(), and BambuParameter::SetDefaults().
|
inline |
Sets the value of an option.
name | is the name of the option |
value | is the value of the option to be saved |
Definition at line 527 of file Parameter.hpp.
References STR.
|
inline |
Sets the value of an option.
name | is the name of the option |
value | is the value of the option to be saved |
Definition at line 538 of file Parameter.hpp.
References STR.
void Parameter::write_xml_configuration_file | ( | const std::string & | filename | ) |
Write an XML configuration file with the parameters actually stored.
filename | is the configuration file name where parameters have to be written |
Definition at line 266 of file Parameter.cpp.
References xml_child::add_child_element(), xml_document::create_root_node(), Options, test_panda::parameters, xml_document::write_to_file_formatted(), and WRITE_XNVM2.
Referenced by tree_panda_gcc_parameter::Exec(), and BambuParameter::Exec().
|
friend |
Friend definition of the << operator.
Definition at line 445 of file Parameter.hpp.
|
protected |
The number of input paramters.
Definition at line 308 of file Parameter.hpp.
Referenced by CGetArgv(), tree_panda_gcc_parameter::Exec(), SpiderParameter::Exec(), EucalyptusParameter::Exec(), and BambuParameter::Exec().
|
protected |
The input parameters;.
Definition at line 311 of file Parameter.hpp.
Referenced by CGetArgv(), tree_panda_gcc_parameter::Exec(), SpiderParameter::Exec(), EucalyptusParameter::Exec(), and BambuParameter::Exec().
|
protected |
Classes to be debugged.
Definition at line 326 of file Parameter.hpp.
Referenced by add_debug_class(), get_class_debug_level(), and GetFunctionDebugLevel().
|
protected |
debug level
Definition at line 329 of file Parameter.hpp.
Referenced by SpiderParameter::CheckParameters(), GetFileFormat(), and ManageDefaultOptions().
|
protected |
Map between an enum option and the related string-form value.
Definition at line 320 of file Parameter.hpp.
Referenced by getOption(), and print().
|
protected |
Name of the enum options.
Definition at line 323 of file Parameter.hpp.
Referenced by Parameter(), and print().
|
protected |
Map between the name of the option and the related string-form value.
Definition at line 314 of file Parameter.hpp.
Referenced by load_xml_configuration_file(), load_xml_configuration_file_rec(), print(), and write_xml_configuration_file().
|
protected |
Map between the name of a parameter and the related string-form value.
Definition at line 317 of file Parameter.hpp.
Referenced by IsParameter(), ManageDefaultOptions(), and BambuParameter::SetDefaults().