PandA-2024.02
c_backend.hpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
45 #ifndef C_BACKEND_HPP
46 #define C_BACKEND_HPP
47 
48 #include "custom_set.hpp"
49 #include "design_flow_step.hpp"
50 #include "graph.hpp"
51 #include "refcount.hpp"
52 
53 #include <fstream>
54 #include <iosfwd>
55 #include <list>
56 #include <ostream>
57 #include <sstream>
58 #include <string>
59 #include <vector>
60 
66 class OpVertexSet;
71 
75 class CBackend : public DesignFlowStep
76 {
77  protected:
80 
83 
86 
89 
92 
100  void compute_variables(const OpGraphConstRef inGraph, const CustomUnorderedSet<unsigned int>& gblVariables,
101  std::list<unsigned int>& funParams, CustomUnorderedSet<unsigned int>& vars);
102 
109  virtual void AnalyzeInclude(const tree_nodeConstRef& tn, const BehavioralHelperConstRef& BH,
111 
115  virtual void writeIncludes();
116 
120  virtual void WriteGlobalDeclarations();
121 
122  virtual void writeImplementations();
123 
129  void ComputeRelationships(DesignFlowStepSet& relationship,
130  const DesignFlowStep::RelationshipType relationship_type) override;
131 
132  private:
133  // CBackendStepFactory is the only class allowed to construct CBackend
134  friend class CBackendStepFactory;
135 
138 
141 
151  CBackend(const CBackendInformationConstRef c_backend_information,
152  const DesignFlowManagerConstRef design_flow_manager, const application_managerConstRef AppM,
153  const ParameterConstRef _parameters);
154 
155  public:
157 
158  bool HasToBeExecuted() const override;
159 
160  void Initialize() override;
161 
162  DesignFlowStep_Status Exec() override;
163 
164  std::string GetSignature() const final;
165 
166  std::string GetName() const final;
167 
168  DesignFlowStepFactoryConstRef CGetDesignFlowStepFactory() const override;
169 
173  const CWriterRef GetCWriter() const;
174 
179 };
181 using CBackendConstRef = refcount<const CBackend>;
182 #endif
std::string GetName() const final
Return the name of this design step.
Definition: c_backend.cpp:129
const IndentedOutputStreamRef indented_output_stream
The output stream.
Definition: c_backend.hpp:82
Class used to write the C code representing a program, this class can&#39;t be directly instantiated sinc...
Definition: c_writer.hpp:91
RelationshipType
The relationship type.
This class manages the tree structures extracted from the raw file.
std::string GetSignature() const final
Return a unified identifier of this design step.
Definition: c_backend.cpp:119
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.
Definition: c_backend.cpp:534
Class specification of the graph structures.
The base class for design step.
const tree_managerConstRef TM
The tree_manager.
Definition: c_backend.hpp:91
Definition of hash function for EdgeDescriptor.
Definition: graph.hpp:1321
bool HasToBeExecuted() const override
Check if this step has actually to be executed.
Definition: c_backend.cpp:308
A set of operation vertices.
Definition: op_graph.hpp:654
Abstract pure class for the tree structure.
Definition: tree_node.hpp:139
virtual void writeIncludes()
Writes the file header, i.e the comments at the beginning of the file.
Definition: c_backend.cpp:430
CONSTREF_FORWARD_DECL(BehavioralHelper)
Base class for step of design flow.
DesignFlowStepFactoryConstRef CGetDesignFlowStepFactory() const override
Return the factory to create this type of steps.
Definition: c_backend.cpp:114
void ComputeRelationships(DesignFlowStepSet &relationship, const DesignFlowStep::RelationshipType relationship_type) override
Compute the relationships of a step with other steps.
Definition: c_backend.cpp:134
redefinition of set to manage ordered/unordered structures
const Wrefcount< const DesignFlowManager > design_flow_manager
The design flow manager.
Class simply used to drive the backend in order to print C code.
Definition: c_backend.hpp:75
DesignFlowStep_Status
The status of a step.
void Initialize() override
Initialize the step (i.e., like a constructor, but executed just before exec.
Definition: c_backend.cpp:313
const CBackendInformationConstRef c_backend_info
Definition: c_backend.hpp:156
Template definition of refcount.
const CWriterRef GetCWriter() const
Definition: c_backend.cpp:359
virtual void WriteGlobalDeclarations()
Write the global declarations.
Definition: c_backend.cpp:364
const CWriterRef writer
the writer
Definition: c_backend.hpp:85
DesignFlowStep_Status Exec() override
Execute the step.
Definition: c_backend.cpp:330
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.
Definition: c_backend.cpp:496
CustomOrderedSet< unsigned int > functions_to_be_declared
This set usually is equal to the set of functions without a body.
Definition: c_backend.hpp:137
virtual void writeImplementations()
Definition: c_backend.cpp:411
REF_FORWARD_DECL(CWriter)
CustomUnorderedSet< unsigned int > already_visited
The set of already analyzed nodes during search of header to include; it is used to avoid infinite re...
Definition: c_backend.hpp:79
Class to print indented code.
Class used to describe a particular graph with operations as nodes.
Definition: op_graph.hpp:783
Base class to pass information to a c backend.
CustomOrderedSet< unsigned int > functions_to_be_defined
Definition: c_backend.hpp:140
CBackend(const CBackendInformationConstRef c_backend_information, const DesignFlowManagerConstRef design_flow_manager, const application_managerConstRef AppM, const ParameterConstRef _parameters)
Constructor.
Definition: c_backend.cpp:99
static std::string ComputeSignature(const CBackendInformationConstRef type)
Compute the signature for a c backend step.
Definition: c_backend.cpp:124
const application_managerConstRef AppM
the manager of the application
Definition: c_backend.hpp:88

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