![]() |
PandA-2024.02
|
#include <discrepancy_analysis_c_writer.hpp>


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< vertex > | bb_frontier |
| CustomOrderedSet< vertex > | bb_analyzed |
| std::map< unsigned int, std::string > | basic_blocks_labels |
| CustomOrderedSet< vertex > | goto_list |
| var_pp_functorConstRef | local_rec_variableFunctor |
| FunctionBehaviorConstRef | local_rec_function_behavior |
| CustomOrderedSet< vertex > | local_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... | |
Definition at line 46 of file discrepancy_analysis_c_writer.hpp.
| 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.
|
overridevirtual |
Declares the local variable; in case the variable used in the initialization of curVar hasn't been declared yet it get declared.
| to_be_declared | is the set of variables which have to be declared |
| already_decl_variables | is the set of already declared variables |
| locally_declared_type | is the set of already declared types |
| helper | is the behavioral helper associated with the function |
| varFunc | is 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.

|
overrideprotectedvirtual |
Reimplemented from CWriter.
Definition at line 1031 of file discrepancy_analysis_c_writer.cpp.
References IndentedOutputStream::Append(), CWriter::indented_output_stream, and STR.

|
overridevirtual |
Writes implementation of __builtin_wait_call.
Reimplemented from CWriter.
Definition at line 1057 of file discrepancy_analysis_c_writer.cpp.
References CWriter::WriteBuiltinWaitCall().

|
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().


|
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().


|
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().

|
overrideprotectedvirtual |
Write function implementation.
| function_id | is 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().

|
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().

|
overridevirtual |
Writes the main() of the testbench C program.
Reimplemented from HLSCWriter.
Definition at line 265 of file discrepancy_analysis_c_writer.cpp.
References IndentedOutputStream::Append(), CWriter::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, GET_INDEX_CONST_NODE, tree_manager::GetFunction(), tree_helper::GetFunctionReturnType(), CWriter::HLSMgr, INDENT_DBG_MEX, CWriter::indented_output_stream, tree_helper::IsVectorType(), CWriter::Param, tree_helper::PrintType(), RETURN_PORT_NAME, STR, THROW_ASSERT, THROW_ERROR, CWriter::TM, WriteExtraCodeBeforeEveryMainCall(), WriteExtraInitCode(), HLSCWriter::WriteParamDecl(), HLSCWriter::WriteParamInitialization(), and HLSCWriter::WriteTestbenchFunctionCall().

|
overrideprotectedvirtual |
Write extra information on the given statement vertex, after the statement itself.
check if we need to add a check for floating operation correctness
Reimplemented from CWriter.
Definition at line 383 of file discrepancy_analysis_c_writer.cpp.
References Discrepancy::address_ssa, IndentedOutputStream::Append(), FunctionBehavior::CGetBehavioralHelper(), tree_helper::CGetElements(), FunctionBehavior::CGetOpGraph(), OpGraph::CGetOpNodeInfo(), tree_manager::CGetTreeNode(), tree_helper::CGetType(), DOUBLE_TYPE, ENTRY_ID, EXIT_ID, F_SIGN, F_TYPE_IN, F_TYPE_OUT, FunctionBehavior::FCFG, FLOAT_TYPE, GET_CONST_NODE, time_info::get_cycles(), BehavioralHelper::get_function_index(), BehavioralHelper::get_function_name(), GET_INDEX_NODE, tree_node::get_kind(), operation::get_name(), GET_NODE, CWriter::HLSMgr, CWriter::indented_output_stream, tree_node::index, INT_TYPE, operation::is_bounded(), is_large_integer(), tree_helper::IsComplexType(), tree_helper::IsRealType(), tree_helper::IsStructType(), tree_helper::IsUnionType(), tree_helper::IsVectorType(), Discrepancy::n_checked_operations, tree_helper::NormalizeTypename(), CWriter::Param, BehavioralHelper::PrintVariable(), tree_helper::Size(), Discrepancy::ssa_to_skip, Discrepancy::ssa_to_skip_if_address, STR, THROW_ASSERT, THROW_ERROR, operation::time_m, CWriter::TM, and UINT_TYPE.

|
overrideprotectedvirtual |
Write extra information on the given statement vertex, before the statement itself.
Reimplemented from CWriter.
Definition at line 322 of file discrepancy_analysis_c_writer.cpp.
References IndentedOutputStream::Append(), BUILTIN_WAIT_CALL, FunctionBehavior::CGetOpGraph(), OpGraph::CGetOpNodeInfo(), tree_manager::CGetTreeNode(), ENTRY_ID, EXIT_ID, FunctionBehavior::FCFG, BehavioralHelper::function_has_to_be_printed(), tree_node::get_kind(), GET_NODE, BehavioralHelper::has_implementation(), CWriter::HLSMgr, CWriter::indented_output_stream, STR, THROW_ASSERT, and CWriter::TM.

|
private |
Definition at line 116 of file discrepancy_analysis_c_writer.cpp.
References IndentedOutputStream::Append(), and CWriter::indented_output_stream.
Referenced by WriteGlobalDeclarations().


|
protected |
Definition at line 51 of file discrepancy_analysis_c_writer.hpp.
1.8.13