PandA-2024.02
|
Auxiliary methods for manipulating string. More...
#include "string_manipulation.hpp"
#include "exceptions.hpp"
#include "panda_types.hpp"
#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <cxxabi.h>
#include <regex>
Go to the source code of this file.
Macros | |
#define | FD_GROUP_U 1 |
#define | FD_GROUP_W 2 |
#define | FD_GROUP_D 3 |
#define | FD_GROUP_SIGN 4 |
#define | AC_GROUP_U 1 |
#define | AC_GROUP_T 2 |
#define | AC_GROUP_W 3 |
#define | AC_GROUP_SIGN 4 |
Functions | |
void | add_escape (std::string &ioString, const std::string &to_be_escaped) |
Header include. More... | |
void | remove_escaped (std::string &ioString) |
Function converting all the escaped characters in the associated character. More... | |
std::string | TrimSpaces (const std::string &value) |
std::string | cxa_demangle (const std::string &input) |
std::string | cxa_rename_mangled (const std::string &signature, const std::string &new_fname) |
std::string | cxa_prefix_mangled (const std::string &signature, const std::string &prefix) |
std::string | capitalize (const std::string &str) |
std::string & | capitalize (std::string &str) |
static const std::regex | fixed_def ("a[cp]_(u)?fixed<\*(\+)\*,\*(\+),?\*(\+)?[^>]*>[^\-]*") |
std::string | ConvertInBinary (const std::string &C_value, unsigned long long precision, const bool real_type, bool unsigned_type) |
Convert a string storing a number in decimal format into a string in binary format. More... | |
static const std::regex | fixp_val ("(\+\?\*)") |
std::string | FixedPointReinterpret (const std::string &FP_vector, const std::string &fp_typename) |
const std::vector< std::string > | SplitString (const std::string &input, const std::string &separators) |
Function which splits a string into tokens. More... | |
std::string | convert_fp_to_string (std::string num, unsigned long long precision) |
convert a real number stored in a string into a string of bits with a given precision More... | |
unsigned long long | convert_fp_to_bits (std::string num, unsigned long long precision) |
convert a real number stored in a string into bits with a given precision More... | |
static const std::regex | ac_type_def ("a[cp]_(u)?(\+)<\*(\+)\*,?\*(\+)?,?\*(\+)?[^>]*>") |
unsigned long long | ac_type_bitwidth (const std::string &intType, bool &is_signed, bool &is_fixed) |
Auxiliary methods for manipulating string.
Definition in file string_manipulation.cpp.
#define AC_GROUP_SIGN 4 |
Definition at line 533 of file string_manipulation.cpp.
Referenced by ac_type_bitwidth().
#define AC_GROUP_T 2 |
Definition at line 531 of file string_manipulation.cpp.
Referenced by ac_type_bitwidth().
#define AC_GROUP_U 1 |
Definition at line 530 of file string_manipulation.cpp.
Referenced by ac_type_bitwidth().
#define AC_GROUP_W 3 |
Definition at line 532 of file string_manipulation.cpp.
Referenced by ac_type_bitwidth().
#define FD_GROUP_D 3 |
Definition at line 166 of file string_manipulation.cpp.
Referenced by ConvertInBinary(), and FixedPointReinterpret().
#define FD_GROUP_SIGN 4 |
Definition at line 167 of file string_manipulation.cpp.
Referenced by ConvertInBinary().
#define FD_GROUP_U 1 |
Definition at line 164 of file string_manipulation.cpp.
Referenced by ConvertInBinary().
#define FD_GROUP_W 2 |
Definition at line 165 of file string_manipulation.cpp.
Referenced by ConvertInBinary(), and FixedPointReinterpret().
unsigned long long ac_type_bitwidth | ( | const std::string & | intType, |
bool & | is_signed, | ||
bool & | is_fixed | ||
) |
Definition at line 535 of file string_manipulation.cpp.
References AC_GROUP_SIGN, AC_GROUP_T, AC_GROUP_U, AC_GROUP_W, and ac_type_def().
Referenced by ConvertInBinary(), and InterfaceInfer::interface_info::update().
|
static |
Referenced by ac_type_bitwidth(), and convert_fp_to_bits().
void add_escape | ( | std::string & | ioString, |
const std::string & | to_be_escaped | ||
) |
Header include.
Function which adds escape to selected characters.
Definition at line 52 of file string_manipulation.cpp.
Referenced by FunctionWriter::operator()(), and Translator::write_to_latex().
std::string capitalize | ( | const std::string & | str | ) |
Definition at line 151 of file string_manipulation.cpp.
References capitalize().
Referenced by capitalize(), and TestbenchGeneration::Exec().
std::string& capitalize | ( | std::string & | str | ) |
Definition at line 157 of file string_manipulation.cpp.
References fixed_def(), and str.
unsigned long long convert_fp_to_bits | ( | std::string | num, |
unsigned long long | precision | ||
) |
convert a real number stored in a string into bits with a given precision
Definition at line 462 of file string_manipulation.cpp.
References ac_type_def(), and STR.
Referenced by NumberToBinaryString(), and soft_float_cg_ext::RecursiveExaminate().
std::string convert_fp_to_string | ( | std::string | num, |
unsigned long long | precision | ||
) |
convert a real number stored in a string into a string of bits with a given precision
Definition at line 384 of file string_manipulation.cpp.
Referenced by BitLatticeManipulator::constructor_bitstring(), ConvertInBinary(), HLS_manager::get_constant_string(), NumberToBinaryString(), and fu_binding::write_init().
std::string ConvertInBinary | ( | const std::string & | C_value, |
unsigned long long | precision, | ||
const bool | real_type, | ||
bool | unsigned_type | ||
) |
Convert a string storing a number in decimal format into a string in binary format.
C_value | is the decimal format |
precision | is the precision of the number |
real_type | is true if the type of the number is real |
unsigned_type | is true if the type of the number is unsigned |
Definition at line 169 of file string_manipulation.cpp.
References ac_type_bitwidth(), convert_fp_to_string(), FD_GROUP_D, FD_GROUP_SIGN, FD_GROUP_U, FD_GROUP_W, fixed_def(), fixp_val(), THROW_ASSERT, and THROW_ERROR.
Referenced by MemoryInitializationCWriter::Process(), and MemoryInitializationWriter::Process().
std::string cxa_demangle | ( | const std::string & | input | ) |
Definition at line 109 of file string_manipulation.cpp.
Referenced by InterfaceInfer::ChasePointerInterfaceRecurse(), InterfaceInfer::Exec(), and tree_manager::GetFunction().
std::string cxa_prefix_mangled | ( | const std::string & | signature, |
const std::string & | prefix | ||
) |
Definition at line 134 of file string_manipulation.cpp.
References distance().
Referenced by SimulationTool::GenerateLibraryBuildScript(), and HLSCWriter::WriteMainTestbench().
std::string cxa_rename_mangled | ( | const std::string & | signature, |
const std::string & | new_fname | ||
) |
Definition at line 116 of file string_manipulation.cpp.
References distance().
|
static |
Referenced by capitalize(), ConvertInBinary(), and FixedPointReinterpret().
std::string FixedPointReinterpret | ( | const std::string & | FP_vector, |
const std::string & | fp_typename | ||
) |
Definition at line 339 of file string_manipulation.cpp.
References FD_GROUP_D, FD_GROUP_W, fixed_def(), fixp_val(), STR, and THROW_ASSERT.
|
static |
Referenced by ConvertInBinary(), and FixedPointReinterpret().
void remove_escaped | ( | std::string & | ioString | ) |
Function converting all the escaped characters in the associated character.
ioString | is the string where the escaped character are changed |
Definition at line 68 of file string_manipulation.cpp.
Referenced by bash_flow_wrapper::generate_synthesis_script(), NanoXploreWrapper::generate_synthesis_script(), QuartusPowerWrapper::generate_synthesis_script(), LatticeWrapper::generate_synthesis_script(), AlteraWrapper::generate_synthesis_script(), and XilinxWrapper::generate_synthesis_script().
const std::vector<std::string> SplitString | ( | const std::string & | input, |
const std::string & | separators | ||
) |
Function which splits a string into tokens.
input | is the string to be split |
separators | is the set of characters to be used to compute the tokens |
Definition at line 366 of file string_manipulation.cpp.
References input.
Referenced by structural_manager::add_port(), FunctionalUnitStep::AnalyzeFu(), xml_child::CGetDescendants(), BambuParameter::CheckParameters(), EucalyptusParameter::CheckParameters(), RTLCharacterization::ComputeCells(), RTLCharacterization::ComputeComponent(), create_tree_manager::createCostTable(), DECODE_FU_LIB(), SimulationTool::DetermineCycles(), BasicBlocksProfiling::Exec(), fun_dominator_allocation::Exec(), FixCharacterization::Exec(), SpiderParameter::Exec(), BambuParameter::Exec(), pragma_manager::ExtractClauses(), FunctionBehavior::FunctionBehavior(), GenerateFuList::GenerateFuList(), allocation::get_compliant_pipelined_unit(), NP_functionality::get_port_list(), CompilerWrapper::GetSystemIncludes(), tree_helper::HasToBeDeclared(), FunctionalUnitStep::Initialize(), FunctionCallOpt::Initialize(), AllocationInformation::InitializeDSPDB(), AllocationInformation::InitializeMuxDB(), HWCallInjection::InternalExec(), Parameter::ManageDefaultOptions(), TestVectorParser::ParseUserString(), tree_helper::PrintType(), Translator::read_column_formats(), PragmaParser::recognize_call_point_hw_pragma(), soft_float_cg_ext::soft_float_cg_ext(), TrimSpaces(), HDL_manager::write_behavioral(), HDL_manager::write_fsm(), operation::xload(), and module::xload().
std::string TrimSpaces | ( | const std::string & | value | ) |
Definition at line 90 of file string_manipulation.cpp.
References SplitString().
Referenced by BambuParameter::Exec().