OpenASIP  2.0
DataDependenceEdge.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file DataDependenceEdge.hh
26  *
27  * Declaration of data dependence edge class
28  *
29  * @author Heikki Kultala 2006-2008 (heikki.kultala-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_DATA_DEPENDENCE_EDGE_HH
34 #define TTA_DATA_DEPENDENCE_EDGE_HH
35 
36 #include "TCEString.hh"
37 #include "GraphEdge.hh"
38 
39 class MoveNode;
40 class ObjectState;
42 
43 class DataDependenceEdge : public GraphEdge {
44 public:
47  DEP_RAW = 1,
48  DEP_WAR = 2,
49  DEP_WAW = 3,
51 
52  enum EdgeReason {
58 
60  EdgeReason edgereason, DependenceType deptype,
62  bool guard = false, bool certainAlias = false,
63  bool tailPseudo = false, bool headPseudo = false,
64  int loop = 0);
65 
67  EdgeReason edgereason, DependenceType deptype,
68  bool guard = false, bool certainAlias = false,
69  bool tailPseudo = false, bool headPseudo = false,
70  int loop = 0);
71 
73  DataDependenceEdge(const DataDependenceEdge& other, bool invertLoop);
74 
75  virtual ~DataDependenceEdge() {
76  delete[] data_;
77  data_ = NULL;
78  }
79 
80  TCEString toString() const;
81  TCEString toString(MoveNode& tail) const;
82 
83  // For xml dumping
85  const MoveNode& tail,
86  const MoveNode& head);
87 
89  return static_cast<DependenceType>(dependenceType_);
90  }
92  return static_cast<EdgeReason>(edgeReason_);
93  }
94 
95  bool isFalseDep() const {
96  return edgeReason_ != EDGE_OPERATION &&
98  }
99 
100  bool guardUse() const {
101  return edgeProperties_ & EPF_GUARD;
102  }
103  bool certainAlias() const {
105  }
106  /** returns whether the tail of the dependence does not directly
107  write/read the data but instead is a control flow move which may
108  cause it to be read/written */
109  bool tailPseudo() const {
111  }
112  /** returns whether the head of the dependence does not directly write/read
113  the data but instead is a control flow move which may cause it to be
114  read/written */
115  bool headPseudo() const {
117  }
118  bool isBackEdge() const {
119  return loopEdge_ != 0;
120  }
121  int loopDepth() const {
122  return loopEdge_;
123  }
124 
125  bool isGPREdge() const {
126  return edgeReason() == EDGE_REGISTER;
127  }
128 
129  bool isRegisterOrRA() const {
130  return edgeReason() == EDGE_REGISTER ||
131  edgeReason() == EDGE_RA;
132  }
133 
134  bool isWAW() const {
135  return dependenceType_ == DEP_WAW;
136  }
137 
138  bool isRAW() const {
139  return dependenceType_ == DEP_RAW;
140  }
141 
142  const TCEString data() const {
143  if (data_ == NULL) {
144  return TCEString("");
145  } else {
146  return TCEString(data_);
147  }
148  }
149  bool operator ==(const DataDependenceEdge& other) const;
150 
151  static void printStats(std::ostream& out);
152 
153  // statistic counters for different types of edges created
154  static int regAntidepCount_;
155 
156  void setData(const TCEString& newData);
157 
158 private:
159  TCEString depTypeSt() const;
160  TCEString edgeReasonSt() const;
161  TCEString guardSt() const;
162  TCEString pseudoSt() const;
163  TCEString latencySt(MoveNode& node) const;
164 
165  // note: the size of this class must be highly optimized as there
166  // will be *lots* of edges in big basic blocks
167 
168  // the flags stored in edgeProperties_
170  EPF_GUARD = 1 << 0,
172  EPF_TAIL_PSEUDO = 1 << 2,
174  };
175 
176  unsigned char dependenceType_; // DependenceType
177  unsigned char edgeReason_; // EdgeReason
178  unsigned char edgeProperties_;
179  unsigned char loopEdge_;
180  // register or mem alias info.
181  char* data_;
182 };
183 
184 #endif
DataDependenceEdge::edgeReasonSt
TCEString edgeReasonSt() const
Definition: DataDependenceEdge.cc:235
DataDependenceEdge::latencySt
TCEString latencySt(MoveNode &node) const
Definition: DataDependenceEdge.cc:294
DataDependenceEdge::DEP_TRIGGER
@ DEP_TRIGGER
Definition: DataDependenceEdge.hh:50
DataDependenceEdge::isBackEdge
bool isBackEdge() const
Definition: DataDependenceEdge.hh:118
GraphEdge.hh
DataDependenceEdge::pseudoSt
TCEString pseudoSt() const
Definition: DataDependenceEdge.cc:284
DataDependenceEdge::setData
void setData(const TCEString &newData)
Definition: DataDependenceEdge.cc:331
DataDependenceEdge::isWAW
bool isWAW() const
Definition: DataDependenceEdge.hh:134
DataDependenceEdge::isFalseDep
bool isFalseDep() const
Definition: DataDependenceEdge.hh:95
ObjectState
Definition: ObjectState.hh:59
MoveNode
Definition: MoveNode.hh:65
DataDependenceEdge::EDGE_REGISTER
@ EDGE_REGISTER
Definition: DataDependenceEdge.hh:53
DataDependenceEdge::DependenceType
DependenceType
Definition: DataDependenceEdge.hh:45
DataDependenceEdge::dependenceType
DependenceType dependenceType() const
Definition: DataDependenceEdge.hh:88
DataDependenceEdge::tailPseudo
bool tailPseudo() const
Definition: DataDependenceEdge.hh:109
DataDependenceEdge::guardSt
TCEString guardSt() const
Definition: DataDependenceEdge.cc:276
TCEString.hh
DataDependenceEdge::edgeProperties_
unsigned char edgeProperties_
Definition: DataDependenceEdge.hh:178
DataDependenceEdge::DataDependenceEdge
DataDependenceEdge(EdgeReason edgereason, DependenceType deptype, TCEString data, bool guard=false, bool certainAlias=false, bool tailPseudo=false, bool headPseudo=false, int loop=0)
Definition: DataDependenceEdge.cc:65
DataDependenceEdge::DEP_UNKNOWN
@ DEP_UNKNOWN
Definition: DataDependenceEdge.hh:46
DataDependenceEdge::isRAW
bool isRAW() const
Definition: DataDependenceEdge.hh:138
DataDependenceEdge::loopDepth
int loopDepth() const
Definition: DataDependenceEdge.hh:121
DataDependenceEdge::EPF_CERTAIN_ALIAS
@ EPF_CERTAIN_ALIAS
Definition: DataDependenceEdge.hh:171
DataDependenceEdge::DEP_RAW
@ DEP_RAW
Definition: DataDependenceEdge.hh:47
DataDependenceEdge::loopEdge_
unsigned char loopEdge_
Definition: DataDependenceEdge.hh:179
DataDependenceEdge::EDGE_FUSTATE
@ EDGE_FUSTATE
Definition: DataDependenceEdge.hh:55
DataDependenceEdge::EDGE_OPERATION
@ EDGE_OPERATION
Definition: DataDependenceEdge.hh:56
DataDependenceEdge::isRegisterOrRA
bool isRegisterOrRA() const
Definition: DataDependenceEdge.hh:129
DataDependenceEdge::EdgePropertyFlags
EdgePropertyFlags
Definition: DataDependenceEdge.hh:169
DataDependenceEdge::toString
TCEString toString() const
Definition: DataDependenceEdge.cc:201
DataDependenceEdge::EPF_GUARD
@ EPF_GUARD
Definition: DataDependenceEdge.hh:170
DataDependenceEdge::certainAlias
bool certainAlias() const
Definition: DataDependenceEdge.hh:103
DataDependenceEdge::~DataDependenceEdge
virtual ~DataDependenceEdge()
Definition: DataDependenceEdge.hh:75
DataDependenceEdge::data
const TCEString data() const
Definition: DataDependenceEdge.hh:142
DataDependenceEdge::EPF_HEAD_PSEUDO
@ EPF_HEAD_PSEUDO
Definition: DataDependenceEdge.hh:173
DataDependenceEdge::DEP_WAW
@ DEP_WAW
Definition: DataDependenceEdge.hh:49
DataDependenceEdge::guardUse
bool guardUse() const
Definition: DataDependenceEdge.hh:100
DataDependenceEdge::dependenceType_
unsigned char dependenceType_
Definition: DataDependenceEdge.hh:176
DataDependenceEdge::operator==
bool operator==(const DataDependenceEdge &other) const
Definition: DataDependenceEdge.cc:319
DataDependenceEdge::EDGE_MEMORY
@ EDGE_MEMORY
Definition: DataDependenceEdge.hh:54
GraphEdge
Definition: GraphEdge.hh:52
TCEString
Definition: TCEString.hh:53
DataDependenceGraph
Definition: DataDependenceGraph.hh:67
DataDependenceEdge::printStats
static void printStats(std::ostream &out)
Definition: DataDependenceEdge.cc:191
DataDependenceEdge::saveState
ObjectState * saveState(const MoveNode &tail, const MoveNode &head)
Definition: DataDependenceEdge.cc:345
DataDependenceEdge
Definition: DataDependenceEdge.hh:43
DataDependenceEdge::headPseudo
bool headPseudo() const
Definition: DataDependenceEdge.hh:115
DataDependenceEdge::DEP_WAR
@ DEP_WAR
Definition: DataDependenceEdge.hh:48
DataDependenceEdge::isGPREdge
bool isGPREdge() const
Definition: DataDependenceEdge.hh:125
DataDependenceEdge::EDGE_RA
@ EDGE_RA
Definition: DataDependenceEdge.hh:57
DataDependenceEdge::depTypeSt
TCEString depTypeSt() const
Definition: DataDependenceEdge.cc:258
DataDependenceEdge::data_
char * data_
Definition: DataDependenceEdge.hh:181
DataDependenceEdge::EdgeReason
EdgeReason
Definition: DataDependenceEdge.hh:52
DataDependenceEdge::EPF_TAIL_PSEUDO
@ EPF_TAIL_PSEUDO
Definition: DataDependenceEdge.hh:172
DataDependenceEdge::edgeReason
EdgeReason edgeReason() const
Definition: DataDependenceEdge.hh:91
DataDependenceEdge::edgeReason_
unsigned char edgeReason_
Definition: DataDependenceEdge.hh:177
DataDependenceEdge::regAntidepCount_
static int regAntidepCount_
Definition: DataDependenceEdge.hh:154