PandA-2024.02
|
Class simply used to drive the backend in order to print C code. More...
#include <c_backend.hpp>
Public Member Functions | |
bool | HasToBeExecuted () const override |
Check if this step has actually to be executed. More... | |
void | Initialize () override |
Initialize the step (i.e., like a constructor, but executed just before exec. More... | |
DesignFlowStep_Status | Exec () override |
Execute the step. More... | |
std::string | GetSignature () const final |
Return a unified identifier of this design step. More... | |
std::string | GetName () const final |
Return the name of this design step. More... | |
DesignFlowStepFactoryConstRef | CGetDesignFlowStepFactory () const override |
Return the factory to create this type of steps. More... | |
const CWriterRef | GetCWriter () const |
Public Member Functions inherited from DesignFlowStep | |
DesignFlowStep (const DesignFlowManagerConstRef design_flow_manager, const ParameterConstRef parameters) | |
Constructor. More... | |
virtual | ~DesignFlowStep () |
Destructor. More... | |
DesignFlowStep_Status | GetStatus () const |
Return the status of this design step. More... | |
virtual void | WriteDot (std::ostream &out) const |
Write the label for a dot graph. More... | |
bool | IsComposed () const |
Returns if this step is composed. More... | |
int | CGetDebugLevel () const |
Return the debug level of the step. More... | |
virtual void | PrintInitialIR () const |
Dump the initial intermediate representation. More... | |
virtual void | PrintFinalIR () const |
Dump the final intermediate representation. More... | |
Static Public Member Functions | |
static std::string | ComputeSignature (const CBackendInformationConstRef type) |
Compute the signature for a c backend step. More... | |
Data Fields | |
const CBackendInformationConstRef | c_backend_info |
Protected Member Functions | |
void | compute_variables (const OpGraphConstRef inGraph, const CustomUnorderedSet< unsigned int > &gblVariables, std::list< unsigned int > &funParams, CustomUnorderedSet< unsigned int > &vars) |
Computes the variables which have to be declared for a function. More... | |
virtual void | AnalyzeInclude (const tree_nodeConstRef &tn, const BehavioralHelperConstRef &BH, CustomOrderedSet< std::string > &includes) |
Analyze a variable or a type to identify the includes to be added. More... | |
virtual void | writeIncludes () |
Writes the file header, i.e the comments at the beginning of the file. More... | |
virtual void | WriteGlobalDeclarations () |
Write the global declarations. More... | |
virtual void | writeImplementations () |
void | ComputeRelationships (DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override |
Compute the relationships of a step with other steps. More... | |
Protected Attributes | |
CustomUnorderedSet< unsigned int > | already_visited |
The set of already analyzed nodes during search of header to include; it is used to avoid infinite recursion. More... | |
const IndentedOutputStreamRef | indented_output_stream |
The output stream. More... | |
const CWriterRef | writer |
the writer More... | |
const application_managerConstRef | AppM |
the manager of the application More... | |
const tree_managerConstRef | TM |
The tree_manager. More... | |
Protected Attributes inherited from DesignFlowStep | |
bool | composed |
True if this step represents a composition of design flow steps (e.g., a flow); must be set by specialized constructors. More... | |
const Wrefcount< const DesignFlowManager > | design_flow_manager |
The design flow manager. More... | |
const ParameterConstRef | parameters |
Set of input parameters. More... | |
int | debug_level |
The debug level. More... | |
const int | output_level |
The output level. More... | |
Private Member Functions | |
CBackend (const CBackendInformationConstRef c_backend_information, const DesignFlowManagerConstRef design_flow_manager, const application_managerConstRef AppM, const ParameterConstRef _parameters) | |
Constructor. More... | |
Private Attributes | |
CustomOrderedSet< unsigned int > | functions_to_be_declared |
This set usually is equal to the set of functions without a body. More... | |
CustomOrderedSet< unsigned int > | functions_to_be_defined |
Friends | |
class | CBackendStepFactory |
Additional Inherited Members | |
Public Types inherited from DesignFlowStep | |
enum | RelationshipType { DEPENDENCE_RELATIONSHIP, INVALIDATION_RELATIONSHIP, PRECEDENCE_RELATIONSHIP } |
The relationship type. More... | |
Class simply used to drive the backend in order to print C code.
Definition at line 75 of file c_backend.hpp.
|
private |
Constructor.
type | is the type of c backend to be created |
c_backend_information | is the information about the backend to be created |
design_flow_manager | is the design flow graph manager |
AppM | is the manager of the application |
file_name | is the file to be created |
Param | is the set of input parameters |
Definition at line 99 of file c_backend.cpp.
References DesignFlowStep::debug_level, GET_CLASS, and DesignFlowStep::parameters.
|
protectedvirtual |
Analyze a variable or a type to identify the includes to be added.
tn | is the variable or the type |
BH | is the behavioral helper |
includes | is where include has to be inseted |
Definition at line 496 of file c_backend.cpp.
References already_visited, tree_helper::CGetType(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, tree_helper::GetSourcePath(), tree_helper::GetTypesToBeDeclaredAfter(), tree_helper::GetTypesToBeDeclaredBefore(), INDENT_DBG_MEX, tree_node::index, tree_helper::IsFunctionDeclaration(), tree_helper::IsInLibbambu(), DesignFlowStep::parameters, STR, and test_panda::type.
Referenced by writeIncludes().
|
overridevirtual |
Return the factory to create this type of steps.
Implements DesignFlowStep.
Definition at line 114 of file c_backend.cpp.
References DesignFlowStep::design_flow_manager, and Wrefcount< T >::lock().
|
protected |
Computes the variables which have to be declared for a function.
inGraph | is the data flow graph of the function |
gblVariables | is the set containing the node ids of the global variables |
funParams | is the list of function parameters |
computed_variables | is the set where the computed variables will be stored |
Definition at line 534 of file c_backend.cpp.
References OpGraph::CGetOpNodeInfo().
|
overrideprotectedvirtual |
Compute the relationships of a step with other steps.
dependencies | is where relationships will be stored |
relationship_type | is the type of relationship to be computed |
Implements DesignFlowStep.
Definition at line 134 of file c_backend.cpp.
References AppM, c_backend_info, ApplicationFrontendFlowStep::ComputeSignature(), HLSFunctionStep::ComputeSignature(), FrontendFlowStep::CreateSteps(), DesignFlowStep::DEPENDENCE_RELATIONSHIP, DesignFlowStep::design_flow_manager, GET_INDEX_CONST_NODE, HLS_SYNTHESIS_FLOW, DesignFlowStep::INVALIDATION_RELATIONSHIP, Wrefcount< T >::lock(), DesignFlowStep::parameters, DesignFlowStep::PRECEDENCE_RELATIONSHIP, TEST_VECTOR_PARSER, THROW_ASSERT, and THROW_UNREACHABLE.
|
static |
Compute the signature for a c backend step.
Definition at line 124 of file c_backend.cpp.
Referenced by GetSignature().
|
overridevirtual |
Execute the step.
Implements DesignFlowStep.
Definition at line 330 of file c_backend.cpp.
References IndentedOutputStream::Append(), c_backend_info, DesignFlowStep::debug_level, DEBUG_LEVEL_PEDANTIC, TimeStamp::GetCurrentTimeStamp(), INDENT_DBG_MEX, indented_output_stream, DesignFlowStep::parameters, SUCCESS, WriteGlobalDeclarations(), writeImplementations(), writeIncludes(), and writer.
const CWriterRef CBackend::GetCWriter | ( | ) | const |
|
finalvirtual |
Return the name of this design step.
Implements DesignFlowStep.
Definition at line 129 of file c_backend.cpp.
References GetSignature().
|
finalvirtual |
Return a unified identifier of this design step.
Implements DesignFlowStep.
Definition at line 119 of file c_backend.cpp.
References c_backend_info, and ComputeSignature().
Referenced by GetName().
|
overridevirtual |
Check if this step has actually to be executed.
Implements DesignFlowStep.
Definition at line 308 of file c_backend.cpp.
|
overridevirtual |
Initialize the step (i.e., like a constructor, but executed just before exec.
Reimplemented from DesignFlowStep.
Definition at line 313 of file c_backend.cpp.
References already_visited, AppM, c_backend_info, functions_to_be_declared, functions_to_be_defined, and writer.
|
protectedvirtual |
Write the global declarations.
Definition at line 364 of file c_backend.cpp.
References IndentedOutputStream::Append(), AppM, DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, functions_to_be_declared, functions_to_be_defined, INDENT_DBG_MEX, indented_output_stream, DesignFlowStep::parameters, starts_with(), TM, and writer.
Referenced by Exec().
|
protectedvirtual |
Definition at line 411 of file c_backend.cpp.
References AppM, DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, functions_to_be_defined, INDENT_DBG_MEX, and writer.
Referenced by Exec().
|
protectedvirtual |
Writes the file header, i.e the comments at the beginning of the file.
Definition at line 430 of file c_backend.cpp.
References AnalyzeInclude(), AppM, tree_helper::CGetType(), DesignFlowStep::debug_level, DEBUG_LEVEL_VERY_PEDANTIC, FunctionBehavior::DFG, functions_to_be_defined, INDENT_DBG_MEX, STR, TM, test_panda::type, and writer.
Referenced by Exec().
|
friend |
Definition at line 134 of file c_backend.hpp.
|
protected |
The set of already analyzed nodes during search of header to include; it is used to avoid infinite recursion.
Definition at line 79 of file c_backend.hpp.
Referenced by AnalyzeInclude(), and Initialize().
|
protected |
the manager of the application
Definition at line 88 of file c_backend.hpp.
Referenced by ComputeRelationships(), Initialize(), WriteGlobalDeclarations(), writeImplementations(), and writeIncludes().
const CBackendInformationConstRef CBackend::c_backend_info |
Definition at line 156 of file c_backend.hpp.
Referenced by ComputeRelationships(), Exec(), GetSignature(), and Initialize().
|
private |
This set usually is equal to the set of functions without a body.
Definition at line 137 of file c_backend.hpp.
Referenced by Initialize(), and WriteGlobalDeclarations().
|
private |
Definition at line 140 of file c_backend.hpp.
Referenced by Initialize(), WriteGlobalDeclarations(), writeImplementations(), and writeIncludes().
|
protected |
The output stream.
Definition at line 82 of file c_backend.hpp.
Referenced by Exec(), and WriteGlobalDeclarations().
|
protected |
The tree_manager.
Definition at line 91 of file c_backend.hpp.
Referenced by WriteGlobalDeclarations(), and writeIncludes().
|
protected |
the writer
Definition at line 85 of file c_backend.hpp.
Referenced by Exec(), GetCWriter(), Initialize(), WriteGlobalDeclarations(), writeImplementations(), and writeIncludes().