OpenASIP 2.2
Loading...
Searching...
No Matches
ProgramDependenceEdge.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 ProgramDependenceEdge.cc
26 *
27 * Implementation of prototype of graph-based program representation:
28 * declaration of the program dependence edge.
29 *
30 * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
31 * @note rating: red
32 */
33
35#include "Exception.hh"
36
37/**
38 * Constructor, makes new Program Dependence Edge without reference
39 * to original Control Dependence Edge in CDG. It is artificial edge.
40 */
42 : cEdge_(NULL), dEdge_(NULL), type_(type), fixed_(false) {
43}
44
45/**
46 * Constructor, makes new Program Dependence Edge with reference to
47 * original Control Dependence Edge in CDG.
48 * @param cEdge Control Dependence Edge
49 */
52 : cEdge_(&cEdge), dEdge_(NULL), type_(PDG_EDGE_CONTROL), fixed_(false) {
53 if (cEdge.isLoopCloseEdge()) {
55 } else {
57 }
58}
59
60/**
61 * Constructor, makes new Program Dependence Edge with reference to
62 * original Data Dependence Edge in DDG.
63 * @param dEdge Data Dependence Edge
64 */
66 DataDependenceEdge& dEdge)
67 : cEdge_(NULL), dEdge_(&dEdge), type_(PDG_EDGE_DATA), fixed_(false) {
68}
69
70/**
71 * Empty destructor.
72 */
75
76/**
77 * Returns the edge description as a string.
78 * @return string describing the edge payload
79 */
83 return "PDG_ARTIFICIAL";
84 }
85 if (isLoopCloseEdge()) {
86 return "LoopClose";
87 }
88 if (isDataDependence()) {
89 return dEdge_->toString();
90 }
91 if (isControlDependence()) {
92 return cEdge_->toString();
93 }
94 return "Error!";
95}
96/**
97 * Returns the edge description as a string in .dot format.
98 * @return string describing the edge payload in .dot format
99 */
103 return TCEString("label=\"") + toString() + "\",color=green";
104 }
105 if (isLoopCloseEdge()) {
106 return TCEString("label=\"") + toString() + "\",color=cyan";
107 }
108
109 if (isControlDependence()) {
110 if (cEdge_->isTrueEdge()) {
111 return TCEString("label=\"") + toString() + "\",color=blue";
112 }
113 if (cEdge_->isFalseEdge()) {
114 return TCEString("label=\"") + toString() + "\",color=red";
115 }
116 return TCEString("label=\"") + toString() + "\"";
117 }
118 return TCEString("label=\"") + toString() + "\",style=dashed";
119}
120
121/**
122 * Tests if edge is control dependence type.
123 * @return true if edge is control dependence
124 */
125bool
128 return true;
129 }
130 return type_ == PDG_EDGE_CONTROL && cEdge_ != NULL ;
131}
132/**
133 * Tests if edge is data dependence type.
134 * @return true if edge is data dependence
135 */
136bool
138 return type_ == PDG_EDGE_DATA && dEdge_ != NULL;
139}
140
141/**
142 * Tests if edge is artificial control dependence type.
143 * Artificial edges are added during PDG synchronization.
144 * @return true if edge is artificial control dependence
145 */
146bool
150
151/**
152 * Tests if edge is loop close edge from artificial close node to
153 * loop entry node
154 * @return true if edge is loop close edge
155 */
156bool
160
161/**
162 * Returns reference to control dependence edge of CDG.
163 * @return control dependence edge of underlying CDG
164 */
167 if (cEdge_ != NULL) {
168 return *cEdge_;
169 } else {
170 throw InvalidData(__FILE__, __LINE__, __func__,
171 "Not a control dependence edge!");
172 }
173}
174/**
175 * Returns reference to data dependence edge of CDG.
176 * @return data dependence edge of underlying DDG
177 */
#define __func__
find Finds info of the inner loops in the false
TCEString toString() const
DataDependenceEdge & dataDependenceEdge()
ProgramDependenceEdge(ControlDependenceEdge &cEdge)
@ PDG_EDGE_CONTROL_ARTIFICIAL
Loop close edge from close node to loop entry.
@ PDG_EDGE_DATA
Indicates Control Dependence Edge from CDG.
@ PDG_EDGE_LOOP_CLOSE
Indicates Data Dependence Edge from DDG.
ControlDependenceEdge & controlDependenceEdge()
ControlDependenceEdge * cEdge_
DataDependenceEdge * dEdge_