PandA-2024.02
|
Functor used to write initialization of the memory writer. More...
#include <memory_initialization_writer_base.hpp>
Public Member Functions | |
MemoryInitializationWriterBase (const tree_managerConstRef TM, const BehavioralHelperConstRef behavioral_helper, const unsigned long int reserved_mem_bytes, const tree_nodeConstRef function_parameter, const TestbenchGeneration_MemoryType testbench_generation_memory_type, const ParameterConstRef parameters) | |
Constructor. More... | |
void | CheckEnd () override |
Check that all the necessary information was present in the initialization string. More... | |
void | GoDown () override |
Start the initialization of a new aggregated data structure. More... | |
void | GoNext () override |
Consume an element of an aggregated data structure. More... | |
void | GoUp () override |
Ends the initialization of the current aggregated data structure. More... | |
Public Member Functions inherited from CInitializationParserFunctor | |
CInitializationParserFunctor () | |
Constructor. More... | |
virtual | ~CInitializationParserFunctor () |
Destructor. More... | |
virtual void | Process (const std::string &content)=0 |
Process an element. More... | |
virtual void | ActivateFileInit (const std::string &filename)=0 |
In case the test_v has a size over a threshold write the tests on a file. More... | |
virtual void | FinalizeFileInit ()=0 |
Copy and close the file. More... | |
Protected Member Functions | |
const std::string | PrintStatus () const |
Print the current status. More... | |
Protected Attributes | |
const tree_managerConstRef | TM |
The tree manager. More... | |
const BehavioralHelperConstRef | behavioral_helper |
The behavioral helper. More... | |
const unsigned long int | reserved_mem_bytes |
The number of bytes to be written. More... | |
unsigned long int | written_bytes |
The number of bytes currently written. More... | |
std::vector< std::pair< const tree_nodeConstRef, size_t > > | status |
The stack representing the current status of the parser; the content is the last dumped element. More... | |
const tree_nodeConstRef | function_parameter |
The variable/parameter being printed. More... | |
const TestbenchGeneration_MemoryType | testbench_generation_memory_type |
The type of initialization being written. More... | |
Protected Attributes inherited from CInitializationParserFunctor | |
int | debug_level |
The debug level. More... | |
bool | write_in_a_file |
the data will be written in a data copied by the caller More... | |
std::string | file_variable |
variable used to write in a variable More... | |
Functor used to write initialization of the memory writer.
Definition at line 65 of file memory_initialization_writer_base.hpp.
MemoryInitializationWriterBase::MemoryInitializationWriterBase | ( | const tree_managerConstRef | _TM, |
const BehavioralHelperConstRef | _behavioral_helper, | ||
const unsigned long int | _reserved_mem_bytes, | ||
const tree_nodeConstRef | _function_parameter, | ||
const TestbenchGeneration_MemoryType | _testbench_generation_memory_type, | ||
const ParameterConstRef | parameters | ||
) |
Constructor.
Header include.
TM | is the tree manager |
behavioral_helper | is the behavioral helper |
reserved_mem_bytes | is the number of bytes to be written |
function_parameter | is the function parameter whose initialization is being printed |
testbench_generation_memory_type | is the type of initialization being printed |
parameters | is the set of input parameters |
. include HLS/simulation include STD include STL include tree includes utility include
Definition at line 68 of file memory_initialization_writer_base.cpp.
References tree_helper::CGetType(), function_parameter, and status.
|
overridevirtual |
Check that all the necessary information was present in the initialization string.
First of all we have to check that there is just one element in the stack
Implements CInitializationParserFunctor.
Definition at line 83 of file memory_initialization_writer_base.cpp.
References PrintStatus(), reserved_mem_bytes, status, STR, THROW_ERROR, and written_bytes.
|
overridevirtual |
Start the initialization of a new aggregated data structure.
Implements CInitializationParserFunctor.
Definition at line 192 of file memory_initialization_writer_base.cpp.
References tree_helper::CGetElements(), tree_helper::CGetFieldTypes(), tree_helper::CGetPointedType(), CInitializationParserFunctor::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, GET_CONST_NODE, INDENT_DBG_MEX, tree_helper::IsArrayType(), tree_helper::IsPointerType(), tree_helper::IsStructType(), tree_helper::IsUnionType(), PrintStatus(), status, STR, THROW_ASSERT, and THROW_ERROR.
|
overridevirtual |
Consume an element of an aggregated data structure.
We have read a field of record, move to the next field, if any
Check if there is at least another field
Implements CInitializationParserFunctor.
Definition at line 219 of file memory_initialization_writer_base.cpp.
References tree_helper::CGetFieldTypes(), CInitializationParserFunctor::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, GET_CONST_NODE, INDENT_DBG_MEX, tree_helper::IsArrayEquivType(), tree_helper::IsPointerType(), tree_helper::IsStructType(), PrintStatus(), status, and THROW_ASSERT.
|
overridevirtual |
Ends the initialization of the current aggregated data structure.
Second, according to the type let's how many elements have to have been processed
parameters cannot have this type, but global variables can
Actually the expected size is unknown
Actual size depends on the pointed type
Implements CInitializationParserFunctor.
Definition at line 96 of file memory_initialization_writer_base.cpp.
References CASE_BINARY_EXPRESSION, CASE_CPP_NODES, CASE_CST_NODES, CASE_DECL_NODES, CASE_FAKE_NODES, CASE_GIMPLE_NODES, CASE_PRAGMA_NODES, CASE_QUATERNARY_EXPRESSION, CASE_TERNARY_EXPRESSION, CASE_UNARY_EXPRESSION, tree_helper::CGetFieldTypes(), CInitializationParserFunctor::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, GET_CONST_NODE, tree_helper::GetArrayDimensions(), INDENT_DBG_MEX, NODE_NOT_YET_SUPPORTED_EC, PrintStatus(), status, STR, THROW_ASSERT, THROW_ERROR, and THROW_ERROR_CODE.
|
protected |
Print the current status.
Definition at line 250 of file memory_initialization_writer_base.cpp.
References GET_CONST_NODE, level, status, and STR.
Referenced by CheckEnd(), GoDown(), GoNext(), and GoUp().
|
protected |
The behavioral helper.
Definition at line 72 of file memory_initialization_writer_base.hpp.
Referenced by MemoryInitializationCWriter::Process(), and MemoryInitializationWriter::Process().
|
protected |
The variable/parameter being printed.
Definition at line 88 of file memory_initialization_writer_base.hpp.
Referenced by MemoryInitializationWriterBase(), MemoryInitializationCWriter::Process(), and MemoryInitializationWriter::Process().
|
protected |
The number of bytes to be written.
Definition at line 75 of file memory_initialization_writer_base.hpp.
Referenced by CheckEnd().
|
protected |
The stack representing the current status of the parser; the content is the last dumped element.
First element of the pair is the tree node describing the type, the second element of the pair is the number of the field (for struct/union) or of the element (for array) Second element is the number of seen elements (index of the last element + 1) Note that storing last element dumped is equivalent to store next element to be dumped, but this approach make easier check of closes parenthesis
Definition at line 85 of file memory_initialization_writer_base.hpp.
Referenced by CheckEnd(), GoDown(), GoNext(), GoUp(), MemoryInitializationWriterBase(), PrintStatus(), MemoryInitializationCWriter::Process(), and MemoryInitializationWriter::Process().
|
protected |
The type of initialization being written.
Definition at line 91 of file memory_initialization_writer_base.hpp.
Referenced by MemoryInitializationCWriter::Process(), and MemoryInitializationWriter::Process().
|
protected |
The tree manager.
Definition at line 69 of file memory_initialization_writer_base.hpp.
|
protected |
The number of bytes currently written.
Definition at line 78 of file memory_initialization_writer_base.hpp.
Referenced by CheckEnd(), MemoryInitializationCWriter::Process(), and MemoryInitializationWriter::Process().