PandA-2024.02
Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends
CBackend Class Reference

Class simply used to drive the backend in order to print C code. More...

#include <c_backend.hpp>

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

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 DesignFlowManagerdesign_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...
 

Detailed Description

Class simply used to drive the backend in order to print C code.

Definition at line 75 of file c_backend.hpp.

Constructor & Destructor Documentation

◆ CBackend()

CBackend::CBackend ( const CBackendInformationConstRef  c_backend_information,
const DesignFlowManagerConstRef  design_flow_manager,
const application_managerConstRef  AppM,
const ParameterConstRef  _parameters 
)
private

Constructor.

Parameters
typeis the type of c backend to be created
c_backend_informationis the information about the backend to be created
design_flow_manageris the design flow graph manager
AppMis the manager of the application
file_nameis the file to be created
Paramis the set of input parameters

Definition at line 99 of file c_backend.cpp.

References DesignFlowStep::debug_level, GET_CLASS, and DesignFlowStep::parameters.

Member Function Documentation

◆ AnalyzeInclude()

void CBackend::AnalyzeInclude ( const tree_nodeConstRef tn,
const BehavioralHelperConstRef BH,
CustomOrderedSet< std::string > &  includes 
)
protectedvirtual

Analyze a variable or a type to identify the includes to be added.

Parameters
tnis the variable or the type
BHis the behavioral helper
includesis 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().

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

◆ CGetDesignFlowStepFactory()

DesignFlowStepFactoryConstRef CBackend::CGetDesignFlowStepFactory ( ) const
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().

Here is the call graph for this function:

◆ compute_variables()

void CBackend::compute_variables ( const OpGraphConstRef  inGraph,
const CustomUnorderedSet< unsigned int > &  gblVariables,
std::list< unsigned int > &  funParams,
CustomUnorderedSet< unsigned int > &  vars 
)
protected

Computes the variables which have to be declared for a function.

Parameters
inGraphis the data flow graph of the function
gblVariablesis the set containing the node ids of the global variables
funParamsis the list of function parameters
computed_variablesis the set where the computed variables will be stored

Definition at line 534 of file c_backend.cpp.

References OpGraph::CGetOpNodeInfo().

Here is the call graph for this function:

◆ ComputeRelationships()

void CBackend::ComputeRelationships ( DesignFlowStepSet relationship,
const DesignFlowStep::RelationshipType  relationship_type 
)
overrideprotectedvirtual

Compute the relationships of a step with other steps.

Parameters
dependenciesis where relationships will be stored
relationship_typeis 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.

Here is the call graph for this function:

◆ ComputeSignature()

std::string CBackend::ComputeSignature ( const CBackendInformationConstRef  type)
static

Compute the signature for a c backend step.

Definition at line 124 of file c_backend.cpp.

Referenced by GetSignature().

Here is the caller graph for this function:

◆ Exec()

DesignFlowStep_Status CBackend::Exec ( )
overridevirtual

◆ GetCWriter()

const CWriterRef CBackend::GetCWriter ( ) const
Returns
the associated c writer

Definition at line 359 of file c_backend.cpp.

References writer.

◆ GetName()

std::string CBackend::GetName ( ) const
finalvirtual

Return the name of this design step.

Returns
the name of the pass (for debug purpose)

Implements DesignFlowStep.

Definition at line 129 of file c_backend.cpp.

References GetSignature().

Here is the call graph for this function:

◆ GetSignature()

std::string CBackend::GetSignature ( ) const
finalvirtual

Return a unified identifier of this design step.

Returns
the signature of the design step

Implements DesignFlowStep.

Definition at line 119 of file c_backend.cpp.

References c_backend_info, and ComputeSignature().

Referenced by GetName().

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

◆ HasToBeExecuted()

bool CBackend::HasToBeExecuted ( ) const
overridevirtual

Check if this step has actually to be executed.

Returns
true if the step has to be executed

Implements DesignFlowStep.

Definition at line 308 of file c_backend.cpp.

◆ Initialize()

void CBackend::Initialize ( )
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.

◆ WriteGlobalDeclarations()

void CBackend::WriteGlobalDeclarations ( )
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().

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

◆ writeImplementations()

void CBackend::writeImplementations ( )
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().

Here is the caller graph for this function:

◆ writeIncludes()

void CBackend::writeIncludes ( )
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().

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

Friends And Related Function Documentation

◆ CBackendStepFactory

friend class CBackendStepFactory
friend

Definition at line 134 of file c_backend.hpp.

Field Documentation

◆ already_visited

CustomUnorderedSet<unsigned int> CBackend::already_visited
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().

◆ AppM

const application_managerConstRef CBackend::AppM
protected

the manager of the application

Definition at line 88 of file c_backend.hpp.

Referenced by ComputeRelationships(), Initialize(), WriteGlobalDeclarations(), writeImplementations(), and writeIncludes().

◆ c_backend_info

const CBackendInformationConstRef CBackend::c_backend_info

Definition at line 156 of file c_backend.hpp.

Referenced by ComputeRelationships(), Exec(), GetSignature(), and Initialize().

◆ functions_to_be_declared

CustomOrderedSet<unsigned int> CBackend::functions_to_be_declared
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().

◆ functions_to_be_defined

CustomOrderedSet<unsigned int> CBackend::functions_to_be_defined
private

◆ indented_output_stream

const IndentedOutputStreamRef CBackend::indented_output_stream
protected

The output stream.

Definition at line 82 of file c_backend.hpp.

Referenced by Exec(), and WriteGlobalDeclarations().

◆ TM

const tree_managerConstRef CBackend::TM
protected

The tree_manager.

Definition at line 91 of file c_backend.hpp.

Referenced by WriteGlobalDeclarations(), and writeIncludes().

◆ writer

const CWriterRef CBackend::writer
protected

the writer

Definition at line 85 of file c_backend.hpp.

Referenced by Exec(), GetCWriter(), Initialize(), WriteGlobalDeclarations(), writeImplementations(), and writeIncludes().


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

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