PandA-2024.02
edge_c_writer.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  */
41 #ifndef EDGE_C_WRITER_HPP
42 #define EDGE_C_WRITER_HPP
43 
44 #include "basic_block.hpp"
45 #include "c_writer.hpp"
46 #include "graph.hpp"
47 #include "refcount.hpp"
48 
49 #include <deque>
50 #include <fstream>
51 #include <iosfwd>
52 #include <list>
53 #include <ostream>
54 #include <set>
55 #include <string>
56 #include <vector>
57 
61 
65 class EdgeCWriter : public CWriter
66 {
67  protected:
69  std::map<vertex, EdgeDescriptor> local_inc;
70 
72  std::set<EdgeDescriptor, ltedge<BBGraph>> dumped_edges;
73 
75  std::map<unsigned int, std::map<unsigned int, unsigned int>> fun_loop_to_index;
76 
78  unsigned int counter;
79 
82 
84  unsigned int fun_id;
85 
90  virtual void print_loop_ending(EdgeDescriptor e);
91 
96  virtual void print_loop_escaping(EdgeDescriptor e);
97 
102  virtual void print_loop_starting(EdgeDescriptor e);
103 
109  virtual void print_edge(EdgeDescriptor e, unsigned int index);
110 
116  virtual void print_end_path(unsigned int fun_id, unsigned int loop_id);
117 
123  virtual void print_loop_switching(EdgeDescriptor e);
124 
132  void writeRoutineInstructions_rec(vertex current_vertex, bool bracket);
133 
142  void writeRoutineInstructions(const unsigned int function_index, const OpVertexSet& instructions,
143  const var_pp_functorConstRef variableFunctor, vertex bb_start = NULL_VERTEX,
145 
146  public:
155  EdgeCWriter(const HLS_managerConstRef _HLSMgr, const InstructionWriterRef instruction_writer,
157  bool verbose = true);
158 
159  virtual ~EdgeCWriter() override;
160 
161  virtual void Initialize() override;
162 
163  virtual void WriteHeader() override;
164 
169  const std::map<unsigned int, std::map<unsigned int, unsigned int>>& CGetFunctionLoopToId() const;
170 };
171 #endif
std::map< vertex, EdgeDescriptor > local_inc
Increment which should be added before the label in a basic block.
virtual void print_loop_escaping(EdgeDescriptor e)
Dump operations requested for record information about a path which exit from a loop.
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.
unsigned int counter
The size of fun_loop_to_index.
const std::map< unsigned int, std::map< unsigned int, unsigned int > > & CGetFunctionLoopToId() const
Returns the map which associates to each loop a unique id.
Class used to write the C code representing a program, this class can&#39;t be directly instantiated sinc...
Definition: c_writer.hpp:91
Class specification of the graph structures.
std::map< unsigned int, std::map< unsigned int, unsigned int > > fun_loop_to_index
Map a pair function - loop to an unique index.
unsigned int fun_id
Index of the current function.
bool verbose
Verbosity means that a comment is printed for each line in the output file.
Definition: c_writer.hpp:116
BBGraphConstRef support_cfg
Special control flow graphs.
virtual void print_loop_starting(EdgeDescriptor e)
Dump initializations of variable for recording a loop path.
A set of operation vertices.
Definition: op_graph.hpp:654
Class use to write the C code with instrumented edges.
const IndentedOutputStreamRef indented_output_stream
Represents the stream we are currently writing to.
Definition: c_writer.hpp:101
virtual void WriteHeader() override
Writes the header of the file.
const ParameterConstRef Param
set of parameters
Definition: c_writer.hpp:119
CONSTREF_FORWARD_DECL(application_manager)
void writeRoutineInstructions_rec(vertex current_vertex, bool bracket)
Write recursively instructions belonging to a basic block of task or of a function.
#define index(x, y)
Definition: Keccak.c:74
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
virtual ~EdgeCWriter() override
EdgeCWriter(const HLS_managerConstRef _HLSMgr, const InstructionWriterRef instruction_writer, const IndentedOutputStreamRef indented_output_stream, const ParameterConstRef Param, bool verbose=true)
Constructor of the class.
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...
Template definition of refcount.
std::set< EdgeDescriptor, ltedge< BBGraph > > dumped_edges
Set of already dumped edges.
virtual void print_edge(EdgeDescriptor e, unsigned int index)
Dump operation requested for instrument an edges.
Class specification of the basic_block structure.
virtual void print_loop_ending(EdgeDescriptor e)
Dump operations requested for record information about a loop path which ends.
virtual void print_loop_switching(EdgeDescriptor e)
Print operation requested for record information about a path which exit from a loop and immediately ...
This file contains the routines necessary to create a C executable program.
Class used to describe a particular graph with operations as nodes.
Definition: op_graph.hpp:783
virtual void Initialize() override
Initialize data structure.
#define NULL_VERTEX
null vertex definition
Definition: graph.hpp:1305
boost::graph_traits< graph >::edge_descriptor EdgeDescriptor
edge definition.
Definition: graph.hpp:1316

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