PandA-2024.02
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
DiscrepancyAnalysisCWriter Class Reference

#include <discrepancy_analysis_c_writer.hpp>

Inheritance diagram for DiscrepancyAnalysisCWriter:
Inheritance graph
[legend]
Collaboration diagram for DiscrepancyAnalysisCWriter:
Collaboration graph
[legend]

Public Member Functions

 DiscrepancyAnalysisCWriter (const CBackendInformationConstRef _c_backend_information, const HLS_managerConstRef _HLSMgr, const InstructionWriterRef _instruction_writer, const IndentedOutputStreamRef _indented_output_stream, const ParameterConstRef _parameters, bool _verbose)
 Constructor. More...
 
void DeclareLocalVariables (const CustomSet< unsigned int > &to_be_declared, CustomSet< unsigned int > &already_declared_variables, CustomSet< std::string > &locally_declared_type, const BehavioralHelperConstRef BH, const var_pp_functorConstRef varFunc) override
 Declares the local variable; in case the variable used in the initialization of curVar hasn't been declared yet it get declared. More...
 
void WriteFunctionDeclaration (const unsigned int funId) override
 Writes the declaration of the function whose id in the tree is funId. More...
 
void WriteBuiltinWaitCall () override
 Writes implementation of __builtin_wait_call. More...
 
void WriteMainTestbench () override
 Writes the main() of the testbench C program. More...
 
- Public Member Functions inherited from HLSCWriter
 HLSCWriter (const CBackendInformationConstRef hls_c_backend_information, const HLS_managerConstRef _HLSMgr, const InstructionWriterRef instruction_writer, const IndentedOutputStreamRef indented_output_stream, const ParameterConstRef _parameters, bool verbose=true)
 Constructor of the class. More...
 
virtual ~HLSCWriter ()
 
void WriteFile (const std::string &file_name) override
 Writes the final C file. More...
 
void WriteHeader () override
 Writes the header of the file. More...
 
- Public Member Functions inherited from CWriter
virtual ~CWriter ()
 
virtual void Initialize ()
 Initialize data structure. More...
 
const InstructionWriterRef getInstructionWriter () const
 Returns the instruction writer. More...
 
const CustomSet< unsigned int > GetLocalVariables (const unsigned int function_id) const
 Compute the local variables of a function. More...
 
virtual void StartFunctionBody (const unsigned int function_id)
 Writes the body of the function to the specified stream. More...
 
virtual void WriteFunctionBody (const unsigned int function_id)
 Writes the body of a function. More...
 
virtual void EndFunctionBody (unsigned int funId)
 Writes the code necessary to close a function (this function was a function also present in the original specification) More...
 
virtual void writeRoutineInstructions (const unsigned int function_index, const OpVertexSet &instructions, var_pp_functorConstRef variableFunctor, vertex bb_start=NULL_VERTEX, CustomOrderedSet< vertex > bb_end=CustomOrderedSet< vertex >())
 Writes the instructions of the current routine, being it a task or a function of the original program. More...
 
virtual void writeInclude (const std::string &file_name)
 Writes an include directive. More...
 
virtual void DeclareType (const tree_nodeConstRef &varType, const BehavioralHelperConstRef &behavioral_helper, CustomSet< std::string > &locally_declared_type)
 This method should be called only if the type associated with the variable is a non built_in type and, in case the non built_in type hasn't been declared yet, it declares it; this method is used to declared new types with scope limited to a routine (be it a function of a task) More...
 
virtual void DeclareVariable (const tree_nodeConstRef &curVar, CustomSet< unsigned int > &already_declared_variables, CustomSet< std::string > &locally_declared_type, const BehavioralHelperConstRef &behavioral_helper, const var_pp_functorConstRef &varFunc)
 Declares the local variable; in case the variable used in the intialization of curVar hasn't been declared yet it get declared. More...
 
virtual void declare_cast_types (unsigned int funId, CustomSet< std::string > &locally_declared_types)
 Declare all the types used in conversions. More...
 
virtual void DeclareFunctionTypes (const tree_nodeConstRef &tn)
 Declares the types of the parameters of a function. More...
 

Protected Member Functions

void WriteGlobalDeclarations () override
 Writes the global declarations. More...
 
void WriteExtraInitCode () override
 Write additional initialization code needed by subclasses. More...
 
void WriteExtraCodeBeforeEveryMainCall () override
 
void WriteBBHeader (const unsigned int bb_number, const unsigned int function_index) override
 
void writePreInstructionInfo (const FunctionBehaviorConstRef FB, const vertex statement) override
 Write extra information on the given statement vertex, before the statement itself. More...
 
void writePostInstructionInfo (const FunctionBehaviorConstRef fun_behavior, const vertex) override
 Write extra information on the given statement vertex, after the statement itself. More...
 
void WriteFunctionImplementation (unsigned int function_index) override
 Write function implementation. More...
 
- Protected Member Functions inherited from HLSCWriter
void WriteParamDecl (const BehavioralHelperConstRef behavioral_helper)
 Write declaration of the top function parameters. More...
 
void WriteParamInitialization (const BehavioralHelperConstRef behavioral_helper, const std::map< std::string, std::string > &curr_test_vector)
 Initialize the parameters of the function. More...
 
void WriteTestbenchFunctionCall (const BehavioralHelperConstRef behavioral_helper)
 Writes a call to the top function to be tested, using its parameters. More...
 
void WriteSimulatorInitMemory (const unsigned int function_id)
 Write some print statements used to dump the values used by the HDL to initialize the memory before the simulation. More...
 
void WriteGlobalDeclarations () override
 Writes the global declarations. More...
 
void WriteFunctionImplementation (unsigned int function_index) override
 Write function implementation. More...
 
void WriteBuiltinWaitCall () override
 Writes implementation of __builtin_wait_call. More...
 
- Protected Member Functions inherited from CWriter
void writeRoutineInstructions_rec (vertex current_vertex, bool bracket, const unsigned int function_index)
 Write recursively instructions belonging to a basic block of task or of a function. More...
 
virtual void WriteBodyLoop (const unsigned int function_index, const unsigned int, vertex current_vertex, bool bracket)
 Write the instructions belonging to a body loop. More...
 
void compute_phi_nodes (const FunctionBehaviorConstRef function_behavior, const OpVertexSet &instructions, var_pp_functorConstRef variableFunctor)
 Determines the instructions coming out from phi-node splitting. More...
 
void insert_copies (vertex b, const BBGraphConstRef bb_domGraph, const BBGraphConstRef bb_fcfgGraph, var_pp_functorConstRef variableFunctor, const CustomSet< unsigned int > &phi_instructions, std::map< unsigned int, unsigned int > &created_variables, std::map< unsigned int, std::string > &symbol_table, std::map< unsigned int, std::deque< std::string >> &array_of_stacks)
 Compute the copy assignments needed by the phi nodes destruction Further details can be found in: More...
 
void schedule_copies (vertex b, const BBGraphConstRef bb_domGraph, const BBGraphConstRef bb_fcfgGraph, var_pp_functorConstRef variableFunctor, const CustomSet< unsigned int > &phi_instructions, std::map< unsigned int, unsigned int > &created_variables, std::map< unsigned int, std::string > &symbol_table, std::list< unsigned int > &pushed, std::map< unsigned int, std::deque< std::string >> &array_of_stacks)
 insert copies according the algorithm described in Briggs et. More...
 
unsigned int create_new_identifier (std::map< unsigned int, std::string > &symbol_table)
 create an identifier for the temporaries created by phi node destruction More...
 
void push_stack (std::string symbol_name, unsigned int dest_i, std::list< unsigned int > &pushed, std::map< unsigned int, std::deque< std::string >> &array_of_stacks)
 push on the stack of temporary variables that has to replaced More...
 
void pop_stack (std::list< unsigned int > &pushed, std::map< unsigned int, std::deque< std::string >> &array_of_stacks)
 remove from the stack all the temporaries More...
 
void WriteHashTableImplementation ()
 Write the implementation of a hash table with long long int as key and long long int as value. More...
 
 CWriter (const HLS_managerConstRef _HLSMgr, const InstructionWriterRef instruction_writer, const IndentedOutputStreamRef indented_output_stream, const ParameterConstRef Param, bool verbose=true)
 Constructor of the class. More...
 

Protected Attributes

const DiscrepancyRef Discrepancy
 
- Protected Attributes inherited from HLSCWriter
const CBackendInformationConstRef c_backend_info
 Backend information. More...
 
- Protected Attributes inherited from CWriter
const HLS_managerConstRef HLSMgr
 the hls manager More...
 
const tree_managerConstRef TM
 The tree manager. More...
 
const IndentedOutputStreamRef indented_output_stream
 Represents the stream we are currently writing to. More...
 
CustomSet< std::string > globally_declared_types
 This set contains the list of the non built_in types already declared in the global scope. More...
 
CustomSet< unsigned int > globallyDeclVars
 
const InstructionWriterRef instrWriter
 Contains the class used to write instructions. More...
 
size_t bb_label_counter
 Counter of the invocations of writeRoutineInstructions; this counter allows to print different labels in differnt tasks to avoid problem due to multiple tasks inlineing. More...
 
bool verbose
 Verbosity means that a comment is printed for each line in the output file. More...
 
const ParameterConstRef Param
 set of parameters More...
 
int debug_level
 the debug level More...
 
int output_level
 the output level More...
 
unsigned int fake_max_tree_node_id
 
std::map< unsigned int, std::string > basic_block_prefix
 string to be printed at the beginning of a given basic block More...
 
std::map< unsigned int, std::string > basic_block_tail
 string to be printed at the end of a given basic block More...
 
std::map< vertex, std::map< unsigned int, std::string > > renaming_table
 renaming table used by phi node destruction procedure More...
 
CustomOrderedSet< vertexbb_frontier
 
CustomOrderedSet< vertexbb_analyzed
 
std::map< unsigned int, std::string > basic_blocks_labels
 
CustomOrderedSet< vertexgoto_list
 
var_pp_functorConstRef local_rec_variableFunctor
 
FunctionBehaviorConstRef local_rec_function_behavior
 
CustomOrderedSet< vertexlocal_rec_instructions
 
const dominance< BBGraph > * dominators
 
const dominance< BBGraph > * post_dominators
 
BBGraphConstRef local_rec_bb_fcfgGraph
 
OpGraphConstRef local_rec_cfgGraph
 
BehavioralHelperConstRef local_rec_behavioral_helper
 
std::vector< std::string > additionalIncludes
 
CustomOrderedSet< std::string > writtenIncludes
 

Private Member Functions

void WriteTestbenchHelperFunctions ()
 

Additional Inherited Members

- Static Public Member Functions inherited from CWriter
static CWriterRef CreateCWriter (const CBackendInformationConstRef c_backend_information, const HLS_managerConstRef hls_man, const IndentedOutputStreamRef indented_output_stream, const ParameterConstRef parameters, const bool verbose)
 Factory method. More...
 

Detailed Description

Definition at line 46 of file discrepancy_analysis_c_writer.hpp.

Constructor & Destructor Documentation

◆ DiscrepancyAnalysisCWriter()

DiscrepancyAnalysisCWriter::DiscrepancyAnalysisCWriter ( const CBackendInformationConstRef  _c_backend_information,
const HLS_managerConstRef  _HLSMgr,
const InstructionWriterRef  _instruction_writer,
const IndentedOutputStreamRef  _indented_output_stream,
const ParameterConstRef  _parameters,
bool  _verbose 
)

Constructor.

Definition at line 102 of file discrepancy_analysis_c_writer.cpp.

References CWriter::Param, STR, and THROW_ASSERT.

Member Function Documentation

◆ DeclareLocalVariables()

void DiscrepancyAnalysisCWriter::DeclareLocalVariables ( const CustomSet< unsigned int > &  to_be_declared,
CustomSet< unsigned int > &  already_declared_variables,
CustomSet< std::string > &  locally_declared_type,
const BehavioralHelperConstRef  BH,
const var_pp_functorConstRef  varFunc 
)
overridevirtual

Declares the local variable; in case the variable used in the initialization of curVar hasn't been declared yet it get declared.

Parameters
to_be_declaredis the set of variables which have to be declared
already_decl_variablesis the set of already declared variables
locally_declared_typeis the set of already declared types
helperis the behavioral helper associated with the function
varFuncis the printer functor

Reimplemented from CWriter.

Definition at line 963 of file discrepancy_analysis_c_writer.cpp.

References IndentedOutputStream::Append(), tree_manager::CGetTreeReindex(), compute_n_bytes(), CWriter::DeclareLocalVariables(), BehavioralHelper::get_function_index(), GET_INDEX_CONST_NODE, BehavioralHelper::GetParameters(), CWriter::HLSMgr, CWriter::indented_output_stream, CWriter::Param, BehavioralHelper::PrintVariable(), tree_helper::Size(), STR, THROW_ASSERT, and CWriter::TM.

Here is the call graph for this function:

◆ WriteBBHeader()

void DiscrepancyAnalysisCWriter::WriteBBHeader ( const unsigned int  bb_number,
const unsigned int  function_index 
)
overrideprotectedvirtual

Reimplemented from CWriter.

Definition at line 1031 of file discrepancy_analysis_c_writer.cpp.

References IndentedOutputStream::Append(), CWriter::indented_output_stream, and STR.

Here is the call graph for this function:

◆ WriteBuiltinWaitCall()

void DiscrepancyAnalysisCWriter::WriteBuiltinWaitCall ( )
overridevirtual

Writes implementation of __builtin_wait_call.

Reimplemented from CWriter.

Definition at line 1057 of file discrepancy_analysis_c_writer.cpp.

References CWriter::WriteBuiltinWaitCall().

Here is the call graph for this function:

◆ WriteExtraCodeBeforeEveryMainCall()

void DiscrepancyAnalysisCWriter::WriteExtraCodeBeforeEveryMainCall ( )
overrideprotectedvirtual

Reimplemented from HLSCWriter.

Definition at line 958 of file discrepancy_analysis_c_writer.cpp.

References IndentedOutputStream::Append(), and CWriter::indented_output_stream.

Referenced by WriteMainTestbench().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteExtraInitCode()

void DiscrepancyAnalysisCWriter::WriteExtraInitCode ( )
overrideprotectedvirtual

Write additional initialization code needed by subclasses.

Reimplemented from HLSCWriter.

Definition at line 915 of file discrepancy_analysis_c_writer.cpp.

References IndentedOutputStream::Append(), HLSCWriter::c_backend_info, Discrepancy::c_trace_filename, compute_n_bytes(), GET_INDEX_CONST_NODE, tree_manager::GetFunction(), CWriter::HLSMgr, CWriter::indented_output_stream, tree_helper::IsSystemType(), CWriter::Param, tree_helper::Size(), STR, THROW_ASSERT, and CWriter::TM.

Referenced by WriteMainTestbench().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WriteFunctionDeclaration()

void DiscrepancyAnalysisCWriter::WriteFunctionDeclaration ( const unsigned int  funId)
overridevirtual

Writes the declaration of the function whose id in the tree is funId.

Reimplemented from CWriter.

Definition at line 1037 of file discrepancy_analysis_c_writer.cpp.

References tree_manager::GetTreeNode(), CWriter::HLSMgr, tree_helper::is_extern(), tree_helper::is_static(), THROW_ASSERT, CWriter::TM, and CWriter::WriteFunctionDeclaration().

Here is the call graph for this function:

◆ WriteFunctionImplementation()

void DiscrepancyAnalysisCWriter::WriteFunctionImplementation ( unsigned int  function_index)
overrideprotectedvirtual

Write function implementation.

Parameters
function_idis the index of the function to be written

Reimplemented from CWriter.

Definition at line 1011 of file discrepancy_analysis_c_writer.cpp.

References tree_manager::GetTreeNode(), CWriter::HLSMgr, tree_helper::is_extern(), tree_helper::is_static(), THROW_ASSERT, CWriter::TM, and CWriter::WriteFunctionImplementation().

Here is the call graph for this function:

◆ WriteGlobalDeclarations()

void DiscrepancyAnalysisCWriter::WriteGlobalDeclarations ( )
overrideprotectedvirtual

Writes the global declarations.

Reimplemented from CWriter.

Definition at line 833 of file discrepancy_analysis_c_writer.cpp.

References IndentedOutputStream::Append(), CWriter::indented_output_stream, CWriter::Param, CWriter::WriteGlobalDeclarations(), and WriteTestbenchHelperFunctions().

Here is the call graph for this function:

◆ WriteMainTestbench()

void DiscrepancyAnalysisCWriter::WriteMainTestbench ( )
overridevirtual

◆ writePostInstructionInfo()

void DiscrepancyAnalysisCWriter::writePostInstructionInfo ( const FunctionBehaviorConstRef  fun_behavior,
const vertex  statement 
)
overrideprotectedvirtual

◆ writePreInstructionInfo()

void DiscrepancyAnalysisCWriter::writePreInstructionInfo ( const FunctionBehaviorConstRef  FB,
const vertex  statement 
)
overrideprotectedvirtual

◆ WriteTestbenchHelperFunctions()

void DiscrepancyAnalysisCWriter::WriteTestbenchHelperFunctions ( )
private

Definition at line 116 of file discrepancy_analysis_c_writer.cpp.

References IndentedOutputStream::Append(), and CWriter::indented_output_stream.

Referenced by WriteGlobalDeclarations().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ Discrepancy

const DiscrepancyRef DiscrepancyAnalysisCWriter::Discrepancy
protected

Definition at line 51 of file discrepancy_analysis_c_writer.hpp.


The documentation for this class was generated from the following files:

Generated on Mon Feb 12 2024 13:03:50 for PandA-2024.02 by doxygen 1.8.13