PandA-2024.02
tree_basic_block.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  */
44 #ifndef TREE_BASIC_BLOCK_HPP
45 #define TREE_BASIC_BLOCK_HPP
46 
47 #include "custom_set.hpp"
48 #include "refcount.hpp"
49 #include <cstddef> // for size_t
50 #include <list>
51 #include <vector>
52 
61 class tree_node_visitor;
62 class gimple_assign;
63 
65 
67 #define GETID(field) field##_ID
68 
72 #define BB_ENTRY 0
73 
77 #define BB_EXIT 1
78 
84 struct bloc
85 {
86  private:
87  friend class use_counting;
88 
91 
93  std::list<tree_nodeRef> list_of_phi;
94 
96  std::list<tree_nodeRef> list_of_stmt;
97 
99  size_t removed_phi;
100 
103 
104  void update_new_stmt(const application_managerRef& AppM, const tree_nodeRef& new_stmt);
105  void manageCallGraph(const application_managerRef& AppM, const tree_nodeRef& statement);
106  bool check_function_call(const tree_nodeRef& statement, gimple_assign* ga, unsigned int& called_function_id);
107 
108  public:
110  std::vector<unsigned int> list_of_pred;
111 
113  std::vector<unsigned int> list_of_succ;
114 
116  const unsigned int number;
117 
119  unsigned int loop_id;
120 
123 
126 
128  // std::map<unsigned int, unsigned int> live_out_phi_defs;
129 
131  unsigned int hpl;
132 
135  unsigned int true_edge;
136 
139  unsigned int false_edge;
140 
143 
147  explicit bloc(unsigned int _number);
148 
152  virtual ~bloc();
153 
158  void add_pred(const unsigned int& a)
159  {
160  list_of_pred.push_back(a);
161  }
162 
167  void add_succ(const unsigned int& a)
168  {
169  list_of_succ.push_back(a);
170  }
175  void AddPhi(const tree_nodeRef phi);
176 
181  void PushFront(const tree_nodeRef statement, const application_managerRef AppM);
182 
187  void PushBack(const tree_nodeRef statement, const application_managerRef AppM);
188 
195  void Replace(const tree_nodeRef old_stmt, const tree_nodeRef new_stmt, const bool move_virtuals,
196  const application_managerRef AppM);
197 
203  void PushBefore(const tree_nodeRef new_stmt, const tree_nodeRef existing_stmt, const application_managerRef AppM);
204 
210  void PushAfter(const tree_nodeRef new_stmt, const tree_nodeRef existing_stmt, const application_managerRef AppM);
211 
215  void ReorderLUTs();
216 
221  void RemoveStmt(const tree_nodeRef statement, const application_managerRef AppM);
222 
227  void RemovePhi(const tree_nodeRef phi);
228 
232  void SetSSAUsesComputed();
233 
237  const std::list<tree_nodeRef>& CGetPhiList() const;
238 
242  const std::list<tree_nodeRef>& CGetStmtList() const;
243 
247  size_t CGetNumberRemovedPhi() const;
248 
250  static const unsigned int ENTRY_BLOCK_ID;
251 
253  static const unsigned int EXIT_BLOCK_ID;
254 
259  virtual void visit(tree_node_visitor* const v) const;
260 
262  enum
263  {
264  GETID(list_of_phi) = 0,
265  GETID(list_of_stmt)
266  };
267 };
268 
269 #endif
void PushBack(const tree_nodeRef statement, const application_managerRef AppM)
Add a statement as last non controlling statement.
virtual void visit(tree_node_visitor *const v) const
virtual function used to traverse the tree_node data structure.
This struct specifies the field bloc (basic block).
void PushBefore(const tree_nodeRef new_stmt, const tree_nodeRef existing_stmt, const application_managerRef AppM)
Add a statement before a specified one.
const unsigned int number
number is the index of the basic block.
Class managing the schedule of the operations.
Definition: schedule.hpp:118
std::vector< unsigned int > list_of_succ
list_of_succ is the list of successors.
void update_new_stmt(const application_managerRef &AppM, const tree_nodeRef &new_stmt)
void Replace(const tree_nodeRef old_stmt, const tree_nodeRef new_stmt, const bool move_virtuals, const application_managerRef AppM)
Replace a statement with another one.
void PushFront(const tree_nodeRef statement, const application_managerRef AppM)
Add a statement in front of list of statements.
static const unsigned int EXIT_BLOCK_ID
constant identifying the exit basic block
bool updated_ssa_uses
consistency of ssa uses
const std::list< tree_nodeRef > & CGetPhiList() const
Return the list of phi.
void RemoveStmt(const tree_nodeRef statement, const application_managerRef AppM)
Remove a statement.
void manageCallGraph(const application_managerRef &AppM, const tree_nodeRef &statement)
void RemovePhi(const tree_nodeRef phi)
Remove a phi.
Abstract pure class for the tree structure.
Definition: tree_node.hpp:139
unsigned int loop_id
loop identifier coming from GCC
const std::list< tree_nodeRef > & CGetStmtList() const
Return the list of stmt.
This struct specifies the gimple_assign node (GCC 4.3 tree node).
Definition: tree_node.hpp:3015
CustomOrderedSet< unsigned int > live_out
Live_Out of the basic block.
void ReorderLUTs()
ReorderLUTs reorders the LUT statements to fix the def-use relations.
void add_pred(const unsigned int &a)
Add a value to list of pred.
unsigned int hpl
store the relation between the phi defs inserted in the live_out set and phi uses ...
redefinition of set to manage ordered/unordered structures
Template definition of refcount.
REF_FORWARD_DECL(bloc)
CustomOrderedSet< unsigned int > live_in
Live_In of the basic block.
void AddPhi(const tree_nodeRef phi)
Add a value to list of phi node.
const application_managerRef AppM
The application manager.
static const unsigned int ENTRY_BLOCK_ID
constant identifying the entry basic block
bool check_function_call(const tree_nodeRef &statement, gimple_assign *ga, unsigned int &called_function_id)
void add_succ(const unsigned int &a)
Add a value to list of succ.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
virtual ~bloc()
Destructor.
unsigned int true_edge
in case the last statement is a gimple_cond associated with an if statement this member contains the ...
std::vector< unsigned int > list_of_pred
list_of_pred is the list of predecessors.
std::list< tree_nodeRef > list_of_phi
list_of_phi is a list of eventual phi node presents in the basic block.
size_t removed_phi
Number of removed phi.
ScheduleRef schedule
The reference to the schedule.
CustomUnorderedSet< unsigned int > already_visited
Already visited tree node (used to avoid infinite recursion)
bloc(unsigned int _number)
constructor
std::list< tree_nodeRef > list_of_stmt
list_of_stmt is the list of statements stored in the basic block.
Superclass include.
void SetSSAUsesComputed()
Set that uses of ssa have been computed.
unsigned int false_edge
in case the last statement is a gimple_cond associated with an if statement this member contains the ...
size_t CGetNumberRemovedPhi() const
Return the number of removed phi.
void PushAfter(const tree_nodeRef new_stmt, const tree_nodeRef existing_stmt, const application_managerRef AppM)
Add a statement after a specified one.

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