PandA-2024.02
|
Class use to write the C code with instruented edges for basic blocks profiling. More...
#include <basic_blocks_profiling_c_writer.hpp>
Public Member Functions | |
BasicBlocksProfilingCWriter (const HLS_managerConstRef _HLSMgr, const InstructionWriterRef instruction_writer, const IndentedOutputStreamRef indented_output_stream, const ParameterConstRef Param, bool verbose=true) | |
Constructor of the class. More... | |
~BasicBlocksProfilingCWriter () final | |
void | WriteGlobalDeclarations () final |
Writes the global declarations. More... | |
Public Member Functions inherited from EdgeCWriter | |
EdgeCWriter (const HLS_managerConstRef _HLSMgr, const InstructionWriterRef instruction_writer, const IndentedOutputStreamRef indented_output_stream, const ParameterConstRef Param, bool verbose=true) | |
Constructor of the class. More... | |
virtual | ~EdgeCWriter () override |
virtual void | Initialize () override |
Initialize data structure. More... | |
virtual void | WriteHeader () override |
Writes the header of the file. More... | |
const std::map< unsigned int, std::map< unsigned int, unsigned int > > & | CGetFunctionLoopToId () const |
Returns the map which associates to each loop a unique id. More... | |
Public Member Functions inherited from CWriter | |
virtual | ~CWriter () |
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 | WriteFunctionImplementation (unsigned int function_id) |
Write function implementation. 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 | WriteFunctionDeclaration (const unsigned int funId) |
Writes the declaration of the function whose id in the tree is funId. 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 | DeclareLocalVariables (const CustomSet< unsigned int > &to_be_declared, CustomSet< unsigned int > &already_declared_variables, CustomSet< std::string > &already_declared_types, 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 | DeclareFunctionTypes (const tree_nodeConstRef &tn) |
Declares the types of the parameters of a function. More... | |
virtual void | WriteFile (const std::string &file_name) |
Writes the final C file. More... | |
virtual void | WriteBuiltinWaitCall () |
Writes implementation of __builtin_wait_call. More... | |
Private Member Functions | |
void | print_loop_ending (EdgeDescriptor e) override |
Dump operations requested for record information about a loop path which ends. More... | |
void | print_loop_escaping (EdgeDescriptor e) override |
Dump operations requested for record information about a path which exit from a loop. More... | |
void | print_loop_starting (EdgeDescriptor e) override |
Dump initializations of variable for recording a loop path. More... | |
void | print_edge (EdgeDescriptor e, unsigned int index) override |
Dump operation requested for instrument an edges. More... | |
void | print_loop_switching (EdgeDescriptor e) override |
Print operation requested for record information about a path which exit from a loop and immediately enter in another. More... | |
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... | |
Protected Member Functions inherited from EdgeCWriter | |
virtual void | print_end_path (unsigned int fun_id, unsigned int loop_id) |
Print operations needed to store into symbol table information about last path. More... | |
void | writeRoutineInstructions_rec (vertex current_vertex, bool bracket) |
Write recursively instructions belonging to a basic block of task or of a function. More... | |
void | writeRoutineInstructions (const unsigned int function_index, const OpVertexSet &instructions, const var_pp_functorConstRef variableFunctor, vertex bb_start=NULL_VERTEX, CustomOrderedSet< vertex > bb_end=CustomOrderedSet< vertex >()) override |
Writes the instructions of the current routine, being it a task or a function of the original program. 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 | writePreInstructionInfo (const FunctionBehaviorConstRef, const vertex) |
Write additional information on the given statement vertex, before the statement itself. More... | |
virtual void | writePostInstructionInfo (const FunctionBehaviorConstRef, const vertex) |
Write additional information on the given statement vertex, after the statements itself. 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... | |
virtual void | WriteBBHeader (const unsigned int bb_number, const unsigned int function_index) |
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 inherited from EdgeCWriter | |
std::map< vertex, EdgeDescriptor > | local_inc |
Increment which should be added before the label in a basic block. More... | |
std::set< EdgeDescriptor, ltedge< BBGraph > > | dumped_edges |
Set of already dumped edges. More... | |
std::map< unsigned int, std::map< unsigned int, unsigned int > > | fun_loop_to_index |
Map a pair function - loop to an unique index. More... | |
unsigned int | counter |
The size of fun_loop_to_index. More... | |
BBGraphConstRef | support_cfg |
Special control flow graphs. More... | |
unsigned int | fun_id |
Index of the current function. 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 |
Class use to write the C code with instruented edges for basic blocks profiling.
Definition at line 50 of file basic_blocks_profiling_c_writer.hpp.
BasicBlocksProfilingCWriter::BasicBlocksProfilingCWriter | ( | const HLS_managerConstRef | _HLSMgr, |
const InstructionWriterRef | instruction_writer, | ||
const IndentedOutputStreamRef | indented_output_stream, | ||
const ParameterConstRef | Param, | ||
bool | verbose = true |
||
) |
Constructor of the class.
HLSMgr | is the hls manager |
instruction_writer | is the instruction writer to use to print the single instruction |
indented_output_stream | is the output stream |
Param | is the set of parameters |
verbose | tells if annotations |
Definition at line 56 of file basic_blocks_profiling_c_writer.cpp.
References CWriter::debug_level, GET_CLASS, and ~BasicBlocksProfilingCWriter().
|
finaldefault |
|
overrideprivatevirtual |
Dump operation requested for instrument an edges.
e | is the edge |
index | is the index of the variable to be incremented |
Reimplemented from EdgeCWriter.
Definition at line 82 of file basic_blocks_profiling_c_writer.cpp.
References IndentedOutputStream::Append(), BBGraph::CGetBBNodeInfo(), EdgeCWriter::dumped_edges, EdgeCWriter::fun_id, CWriter::HLSMgr, CWriter::indented_output_stream, STR, EdgeCWriter::support_cfg, and lenet_tvm::target.
Referenced by print_loop_ending(), print_loop_escaping(), print_loop_starting(), and print_loop_switching().
|
overrideprivatevirtual |
Dump operations requested for record information about a loop path which ends.
e | is the feedback or outgoing edge |
Reimplemented from EdgeCWriter.
Definition at line 67 of file basic_blocks_profiling_c_writer.cpp.
References print_edge().
|
overrideprivatevirtual |
Dump operations requested for record information about a path which exit from a loop.
e | is the feedback or outgoing edge |
Reimplemented from EdgeCWriter.
Definition at line 72 of file basic_blocks_profiling_c_writer.cpp.
References print_edge().
|
overrideprivatevirtual |
Dump initializations of variable for recording a loop path.
e | is the incoming edged |
Reimplemented from EdgeCWriter.
Definition at line 77 of file basic_blocks_profiling_c_writer.cpp.
References print_edge().
|
overrideprivatevirtual |
Print operation requested for record information about a path which exit from a loop and immediately enter in another.
e | is the edge |
Reimplemented from EdgeCWriter.
Definition at line 90 of file basic_blocks_profiling_c_writer.cpp.
References print_edge().
|
finalvirtual |
Writes the global declarations.
Writing auxiliary variables used by instruction writer
Writing declarations of global variables
Reimplemented from CWriter.
Definition at line 95 of file basic_blocks_profiling_c_writer.cpp.
References IndentedOutputStream::Append(), tree_manager::CGetTreeNode(), GET_CONST_NODE, GET_NODE, CWriter::HLSMgr, CWriter::indented_output_stream, CWriter::Param, sl, STR, STR_CST_host_profiling_data, CWriter::TM, and CWriter::WriteGlobalDeclarations().