OpenASIP 2.2
Loading...
Searching...
No Matches
ProgramDependenceNode.cc
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 ProgramDependenceNode.cc
26 *
27 * Implementation of prototype of graph-based program representation:
28 * declaration of the program dependence node.
29 *
30 * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
31 * @note rating: red
32 */
33
35#include "Move.hh"
36#include "MoveNode.hh"
37#include "Conversion.hh"
38#include "Application.hh"
39
40/**
41 * Constructor creating Program Dependence Node which is empty.
42 * Does not have related CDG node. For example Loop Close node.
43 * @param type Type of the node
44 */
46 NodeType type)
47 : GraphNode(), type_(type), component_(-1), newFirstBB_(NULL),
48 lastNode_(false) {
49 mNode_ = NULL;
50 cdgNode_ = NULL;
51}
52
53/**
54 * Constructor creating Program Dependence Node from Control Dependence
55 * region node.
56 * @param cdgNode node of CDG
57 * @param type Type of the node
58 */
60 ControlDependenceNode& cdgNode,
61 NodeType type)
62 : GraphNode(), cdgNode_(&cdgNode), type_(type), component_(-1),
63 newFirstBB_(NULL), lastNode_(false) {
64 mNode_ = NULL;
65}
66
67/**
68 * Constructor creating Program Dependence Node from Data Dependence node.
69 * @param mNode MoveNode of DDG
70 * @param type Type of the node
71 */
73 MoveNode& mNode,
74 NodeType type)
75 : GraphNode(), mNode_(&mNode), type_(type), component_(-1),
76 newFirstBB_(NULL), lastNode_(false) {
77 cdgNode_ = NULL;
78}
79
80/**
81 * Empty destructor.
82 */
87
88/**
89 * Returns content of a node as a string.
90 * @return string representing content of a node
91 */
92std::string
94 TCEString result;
95 if (isRegionNode()) {
96 if (cdgNode_ != NULL) {
97 result += cdgNode_->toString() + ": " +
99 } else {
100 /// Node added during strong components detection
101 /// to collect edges pointing to loop entry from outside the loop.
102 /// Do not have cdg equivalent if analysis was done directly on pdg
103 result += "Collect_" + Conversion::toString(nodeID());
104 }
105 }
106 if (isLoopEntryNode()) {
107 /// Loop entry is region node converted during detection of loops
108 /// Exists in CDG even if loop detection was done on PDG
109 result += "LoopEntry_" + Conversion::toString(nodeID()) +
110 ": " + cdgNode_->toString();
111 }
112 if (isLoopCloseNode()) {
113 /// Node added during strong components detection
114 /// to collect edges pointing to loop entry from inside the loop.
115 /// Do not have cdg equivalent if analysis was done directly on pdg
116 if (cdgNode_ != NULL) {
117 result += "LoopClose_" + Conversion::toString(nodeID()) +
118 ": " + cdgNode_->toString();
119 } else {
120 result += "LoopClose_" + Conversion::toString(nodeID());
121 }
122 }
123 if (isPredicateMoveNode()) {
124 result += "Predicate: " + mNode_->toString() + ": " +
126 }
127 if (isLastNode()) {
128 result += "_LAST";
129 }
130 if (mNode_ != NULL && !isPredicateMoveNode()) {
131 result+= mNode_->toString() + ": " + Conversion::toString(nodeID());
132 }
133 return result;
134}
135/**
136 * Returns content of a node as a string in .dot format.
137 * @return string representing content of a node in .dot format
138 */
139std::string
141 if (isPredicateMoveNode()) {
142 return TCEString("label=\"") +
143 toString() + "\",shape=box,color=green";
144 }
145 if (isRegionNode()) {
146 return TCEString("label=\"")
147 + toString() + "\",shape=box,color=blue";
148 }
149 if (isMoveNode() && moveNode().isMove() && moveNode().move().isCall()) {
150 return TCEString("label=\"")
151 + toString() + "\",shape=box,color=red";
152 }
153 if (isLoopEntryNode()) {
154 return TCEString("label=\"")
155 + toString() + "\",shape=box,color=red";
156 }
157 if (isLoopCloseNode()) {
158 return TCEString("label=\"")
159 + toString() + "\",shape=box,color=yellow";
160 }
161
162 return TCEString("label=\"") + toString() + "\"";
163}
164/**
165 * Sets node to be predicate node
166 */
167void
170 TCEString msg = "Trying to create predicate move from Region in ";
171 msg += toString() + "!";
172 throw InvalidData(__FILE__, __LINE__, __func__, msg);
173 }
175}
176
177/**
178 * Returns MoveNode corresponding to given node in DDG.
179 * @return MoveNode corresponding to given node in DDG
180 */
184 && mNode_ != NULL) {
185 return *mNode_;
186 } else {
187 TCEString msg = "MoveNode type does not contain move in ";
188 msg += toString() + "!";
189 throw InvalidData(__FILE__, __LINE__, __func__, msg);
190 }
191}
192
193/**
194 * Returns MoveNode corresponding to given node in DDG as constant.
195 * @return MoveNode corresponding to given node in DDG as constant
196 */
197const MoveNode&
200 && mNode_ != NULL) {
201 return *mNode_;
202 } else {
203 TCEString msg = "MoveNode type does not contain move in ";
204 msg += toString() + "!";
205 throw InvalidData(__FILE__, __LINE__, __func__, msg);
206 }
207}
208
209/**
210 * Returns CDGNode corresponding to given node in CDG.
211 * @return CDGNode corresponding to given node in CDG
212 */
215 if ((type_ == PDG_NODE_REGION
218 && cdgNode_ != NULL) {
219 return *cdgNode_;
220 } else {
221 TCEString msg = "ControlNode type does not contain CDGNode in ";
222 msg += toString() + "!";
223 throw InvalidData(__FILE__, __LINE__, __func__, msg);
224 }
225}
226/**
227 * Returns CDGNode corresponding to given node in CDG as constant.
228 * @return CDGNode corresponding to given node in CDG as constant
229 */
232 if ((type_ == PDG_NODE_REGION
235 && cdgNode_ != NULL) {
236 return *cdgNode_;
237 } else {
238 TCEString msg = "ControlNode type does not contain CDGNode in ";
239 msg += toString() + "!";
240 throw InvalidData(__FILE__, __LINE__, __func__, msg);
241 }
242}
243
244/**
245 * Add node to "region" set for computing serialization information
246 *
247 * @param node Node to add to the set
248 */
249void
253
254/**
255 * Returns the "region" set for given node
256 *
257 * @return the "region" set for given node
258 */
263/**
264 * Add node to "eec" set for computing serialization information
265 *
266 * @param node Node to add to the set
267 */
268
269void
273
274/**
275 * Returns the "eec" set for given node
276 *
277 * @return the "eec" set for given node
278 */
279
282 return eec_;
283}
284
285/**
286 * Sets the node to be loop entry node of a given component (loop)
287 *
288 * @param component Component of which the node is loop entry node
289 *
290 */
291void
296void
298 Application::logStream() << "Relations: ";
299 for (NodesInfo::const_iterator iter = region_.begin();
300 iter != region_.end();
301 iter ++) {
302 Application::logStream() << (*iter)->toString() << ", ";
303 }
304 Application::logStream() << std::endl;
305 Application::logStream() << "EEC: ";
306 for (NodesInfo::const_iterator iter = eec_.begin();
307 iter != eec_.end();
308 iter ++) {
309 Application::logStream() << (*iter)->toString() << ", ";
310 }
311 Application::logStream() << std::endl;
312
313}
#define __func__
find Finds info of the inner loops in the false
static std::ostream & logStream()
std::string toString() const
static std::string toString(const T &source)
int nodeID() const
std::string toString() const
Definition MoveNode.cc:576
void addToEEC(ProgramDependenceNode &node)
std::string dotString() const
int component_
Number of strong component the node belongs to. Node can be part of several strong components so this...
void addToRegion(ProgramDependenceNode &node)
ProgramDependenceNode(NodeType type=PDG_NODE_REGION)
std::set< ProgramDependenceNode * > NodesInfo
NodesInfo eec_
Stores "eec" information for computing serialization information.
void setLoopEntryNode(int component)
ControlDependenceNode & cdgNode()
std::string toString() const
NodesInfo region_
Stores "region" information for computing serialization information.
ControlDependenceNode * cdgNode_