OpenASIP 2.2
Loading...
Searching...
No Matches
ControlFlowEdge.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 ControlFlowEdge.cc
26 *
27 * Prototype of graph-based program representation: implementation of graph
28 * edge.
29 *
30 * @author Andrea Cilio 2005 (cilio-no.spam-cs.tut.fi)
31 * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
32 * @note rating: red
33 */
34
35#include "ControlFlowEdge.hh"
36#include "Move.hh"
37#include "MoveGuard.hh"
38#include "Operation.hh"
39#include "Terminal.hh"
40
41/**
42 * Constructor creates Control Flow Edge of given type
43 *
44 * @param edgePredicate The truth value of edge (or normal)
45 * @param edgeType Define if edge represents jump, if false the it is call
46 */
48 CFGEdgePredicate edgePredicate,
49 CFGEdgeType edgeType) :
50 edgePredicate_(edgePredicate), edgeType_(edgeType), backEdge_(false) {
51}
52
53/**
54 * Destructor
55 */
57
58/**
59 * Returns type as a string. Helper for graph output to dot file.
60 *
61 * @return String representing type of edge.
62 */
65 TCEString result = "";
66 if (isJumpEdge()) {
67 result += "Jump_";
68 }
69 if (isFallThroughEdge()) {
70 result += "FallThrough_";
71 }
72 if (isCallPassEdge()) {
73 result += "CallPass_";
74 }
75 if (isBackEdge()) {
76 result += "BackEdge_";
77 }
78 if (isNormalEdge()) {
79 result += "normal";
80 }
81 if (isTrueEdge()) {
82 result += "true";
83 }
84 if (isFalseEdge()) {
85 result += "false";
86 }
87 if (isLoopBreakEdge()) {
88 result += "break";
89 }
90 return result;
91}
92
93/**
94 * Returns true if object represents ControlFlowEdge.
95 *
96 * @return True if object is control flow edge
97 */
98bool
100 return true;
101}
102/**
103 * Returns true if the edge is representing unconditional jump
104 *
105 * @return True if jump is not guarded
106 */
107bool
111
112/**
113 * Returns true if edge represents conditional control flow that is
114 * taken if condition evaluates to true.
115 *
116 * @return True if edge represents True path
117 */
118bool
122/**
123 * Returns true if edge represents conditional control flow that is
124 * taken if condition evaluates to false.
125 *
126 * @return True if edge represents False path
127 */
128bool
132/**
133 * Returns true if edge represents control flow over the call in code.
134 *
135 * @return True if edge is split in basic block when call happened.
136 */
137bool
141
142/**
143 * Returns true if the edge is representing jump.
144 *
145 * @return True if the edge represents jump.
146 */
147bool
151
152/**
153 * Returns true if the edge is representing fall through.
154 *
155 * @return True if the edge represents fall through.
156 */
157bool
161
162/**
163 * Returns true if edge was added to break infinite
164 * loop for control dependence computation.
165 *
166 * @return True if edge was added to break infinite loop
167 */
168bool
172
173/**
174 * Returns true if edge is loop back edge
175 *
176 * @return True if edge is loop back edge
177 */
178bool
180 return backEdge_;
181}
182
183/**
184 * Creates an edge predicate based on the guard of a move
185 */
188 if (move.isUnconditional()) {
189 if (move.isTriggering()) {
190 Operation& o = move.destination().operation();
191 if (o.name() == "BNZ" || o.name() == "IRFJUMPNZ" ||
192 o.name() == "BNZ1" || o.name() == "IRFJUMPNZ1") {
194 }
195 if (o.name() == "BZ" || o.name() == "IRFJUMPZ" ||
196 o.name() == "BZ1" || o.name() == "IRFJUMPZ1") {
198 }
199 } else {
200 Operation& o = move.destination().hintOperation();
201 if (&o != &NullOperation::instance()) {
202 if (o.name() == "BNZ" || o.name() == "IRFJUMPNZ" ||
203 o.name() == "BNZ1" || o.name() == "IRFJUMPNZ1") {
205 }
206 if (o.name() == "BZ" || o.name() == "IRFJUMPZ" ||
207 o.name() == "BZ1" || o.name() == "IRFJUMPZ1") {
209 }
210 }
211 }
213 }
214 TTAProgram::MoveGuard& mg = move.guard();
215 return mg.isInverted() ?
218}
find Finds info of the inner loops in the false
ControlFlowEdge(CFGEdgePredicate edgePredicate=CFLOW_EDGE_NORMAL, CFGEdgeType edgeType=CFLOW_EDGE_JUMP)
TCEString toString() const
virtual ~ControlFlowEdge()
bool isBackEdge() const
bool isNormalEdge() const
static ControlFlowEdge::CFGEdgePredicate edgePredicateFromMove(const TTAProgram::Move &move)
bool isFalseEdge() const
bool isFallThroughEdge() const
bool isLoopBreakEdge() const
bool isControlFlowEdge() const
bool isJumpEdge() const
bool isCallPassEdge() const
bool isTrueEdge() const
CFGEdgeType edgeType_
CFGEdgePredicate edgePredicate_
static NullOperation & instance()
virtual TCEString name() const
Definition Operation.cc:93
bool isInverted() const
Definition MoveGuard.cc:76
MoveGuard & guard() const
Definition Move.cc:345
bool isUnconditional() const
Definition Move.cc:154
bool isTriggering() const
Definition Move.cc:284
Terminal & destination() const
Definition Move.cc:323
virtual Operation & hintOperation() const
Definition Terminal.cc:341
virtual Operation & operation() const
Definition Terminal.cc:319