OpenASIP 2.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ControlFlowEdge Class Reference

#include <ControlFlowEdge.hh>

Inheritance diagram for ControlFlowEdge:
Inheritance graph
Collaboration diagram for ControlFlowEdge:
Collaboration graph

Public Types

enum  CFGEdgePredicate {
  CFLOW_EDGE_NORMAL , CFLOW_EDGE_TRUE , CFLOW_EDGE_FALSE , CFLOW_EDGE_LOOP_BREAK ,
  CFLOW_EDGE_FAKE
}
 
enum  CFGEdgeType { CFLOW_EDGE_JUMP , CFLOW_EDGE_CALL , CFLOW_EDGE_FALLTHROUGH }
 

Public Member Functions

 ControlFlowEdge (CFGEdgePredicate edgePredicate=CFLOW_EDGE_NORMAL, CFGEdgeType edgeType=CFLOW_EDGE_JUMP)
 
virtual ~ControlFlowEdge ()
 
bool isControlFlowEdge () const
 
bool isNormalEdge () const
 
bool isTrueEdge () const
 
bool isFalseEdge () const
 
bool isCallPassEdge () const
 
bool isJumpEdge () const
 
bool isFallThroughEdge () const
 
bool isLoopBreakEdge () const
 
bool isBackEdge () const
 
TCEString toString () const
 
void setPredicate (CFGEdgePredicate pred)
 
CFGEdgePredicate edgePredicate () const
 
CFGEdgeType edgeType ()
 
void setBackEdge ()
 Add property to edge to mark is as back edge - loop edge DO NOT USE unless you know what you are doing!!!
 
- Public Member Functions inherited from GraphEdge
 GraphEdge ()
 
 GraphEdge (const GraphEdge &edge)
 
virtual GraphEdgeclone () const
 
virtual ~GraphEdge ()
 
virtual int edgeID () const
 
virtual TCEString dotString () const
 
int weight () const
 
void setWeight (int w)
 

Static Public Member Functions

static ControlFlowEdge::CFGEdgePredicate edgePredicateFromMove (const TTAProgram::Move &move)
 

Private Attributes

CFGEdgePredicate edgePredicate_
 
CFGEdgeType edgeType_
 
bool backEdge_
 

Detailed Description

Edge of the control flow graph (control flow edge). Each edge implies a possible change of execution flow from the source basic block to the target basic block.

Definition at line 50 of file ControlFlowEdge.hh.

Member Enumeration Documentation

◆ CFGEdgePredicate

Enumerator
CFLOW_EDGE_NORMAL 
CFLOW_EDGE_TRUE 
CFLOW_EDGE_FALSE 
CFLOW_EDGE_LOOP_BREAK 
CFLOW_EDGE_FAKE 

Definition at line 52 of file ControlFlowEdge.hh.

◆ CFGEdgeType

Enumerator
CFLOW_EDGE_JUMP 
CFLOW_EDGE_CALL 
CFLOW_EDGE_FALLTHROUGH 

Definition at line 59 of file ControlFlowEdge.hh.

Constructor & Destructor Documentation

◆ ControlFlowEdge()

ControlFlowEdge::ControlFlowEdge ( CFGEdgePredicate  edgePredicate = CFLOW_EDGE_NORMAL,
CFGEdgeType  edgeType = CFLOW_EDGE_JUMP 
)

Constructor creates Control Flow Edge of given type

Parameters
edgePredicateThe truth value of edge (or normal)
edgeTypeDefine if edge represents jump, if false the it is call

Definition at line 47 of file ControlFlowEdge.cc.

49 :
51}
CFGEdgeType edgeType()
CFGEdgeType edgeType_
CFGEdgePredicate edgePredicate_
CFGEdgePredicate edgePredicate() const

◆ ~ControlFlowEdge()

ControlFlowEdge::~ControlFlowEdge ( )
virtual

Destructor

Definition at line 56 of file ControlFlowEdge.cc.

56{ }

Member Function Documentation

◆ edgePredicate()

CFGEdgePredicate ControlFlowEdge::edgePredicate ( ) const
inline

◆ edgePredicateFromMove()

ControlFlowEdge::CFGEdgePredicate ControlFlowEdge::edgePredicateFromMove ( const TTAProgram::Move move)
static

Creates an edge predicate based on the guard of a move

Definition at line 187 of file ControlFlowEdge.cc.

187 {
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}
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

References CFLOW_EDGE_FALSE, CFLOW_EDGE_NORMAL, CFLOW_EDGE_TRUE, TTAProgram::Move::destination(), TTAProgram::Move::guard(), TTAProgram::Terminal::hintOperation(), NullOperation::instance(), TTAProgram::MoveGuard::isInverted(), TTAProgram::Move::isTriggering(), TTAProgram::Move::isUnconditional(), Operation::name(), and TTAProgram::Terminal::operation().

Referenced by ControlFlowGraph::findJumpAddress().

Here is the call graph for this function:

◆ edgeType()

CFGEdgeType ControlFlowEdge::edgeType ( )
inline

Definition at line 84 of file ControlFlowEdge.hh.

84{ return edgeType_; }

References edgeType_.

Referenced by SimpleIfConverter::detectDiamond(), and CopyingDelaySlotFiller::updateFTBBAndCfg().

◆ isBackEdge()

bool ControlFlowEdge::isBackEdge ( ) const
virtual

◆ isCallPassEdge()

bool ControlFlowEdge::isCallPassEdge ( ) const

Returns true if edge represents control flow over the call in code.

Returns
True if edge is split in basic block when call happened.

Definition at line 138 of file ControlFlowEdge.cc.

138 {
139 return edgeType_ == CFLOW_EDGE_CALL;
140}

References CFLOW_EDGE_CALL, and edgeType_.

Referenced by CopyingDelaySlotFiller::bbnScheduled(), SimpleIfConverter::detectDiamond(), SimpleIfConverter::detectTriangleViaFt(), CopyingDelaySlotFiller::fillDelaySlots(), CopyingDelaySlotFiller::finishBB(), ControlFlowGraph::optimizeBBOrdering(), and toString().

◆ isControlFlowEdge()

bool ControlFlowEdge::isControlFlowEdge ( ) const

Returns true if object represents ControlFlowEdge.

Returns
True if object is control flow edge

Definition at line 99 of file ControlFlowEdge.cc.

99 {
100 return true;
101}

◆ isFallThroughEdge()

bool ControlFlowEdge::isFallThroughEdge ( ) const

Returns true if the edge is representing fall through.

Returns
True if the edge represents fall through.

Definition at line 158 of file ControlFlowEdge.cc.

158 {
160}

References CFLOW_EDGE_FALLTHROUGH, and edgeType_.

Referenced by LoopPrologAndEpilogBuilder::addEpilogIntoCfg(), CopyingDelaySlotFiller::fillDelaySlots(), Peel2BBLoops::testIf2BBLoop(), and toString().

◆ isFalseEdge()

bool ControlFlowEdge::isFalseEdge ( ) const

Returns true if edge represents conditional control flow that is taken if condition evaluates to false.

Returns
True if edge represents False path

Definition at line 129 of file ControlFlowEdge.cc.

129 {
131}

References CFLOW_EDGE_FALSE, and edgePredicate_.

Referenced by PreOptimizer::cfgAllowsJumpReversal(), ControlFlowGraph::reverseGuardOnOutEdges(), and toString().

◆ isJumpEdge()

bool ControlFlowEdge::isJumpEdge ( ) const

Returns true if the edge is representing jump.

Returns
True if the edge represents jump.

Definition at line 148 of file ControlFlowEdge.cc.

148 {
149 return edgeType_ == CFLOW_EDGE_JUMP;
150}

References CFLOW_EDGE_JUMP, and edgeType_.

Referenced by LoopPrologAndEpilogBuilder::addPrologIntoCfg(), CopyingDelaySlotFiller::areAllJumpPredsFilled(), CopyingDelaySlotFiller::areAllJumpPredsScheduled(), ControlFlowGraph::isSingleBBLoop(), ControlFlowGraph::jumpSuccessor(), and toString().

◆ isLoopBreakEdge()

bool ControlFlowEdge::isLoopBreakEdge ( ) const

Returns true if edge was added to break infinite loop for control dependence computation.

Returns
True if edge was added to break infinite loop

Definition at line 169 of file ControlFlowEdge.cc.

169 {
171}

References CFLOW_EDGE_LOOP_BREAK, and edgePredicate_.

Referenced by toString().

◆ isNormalEdge()

bool ControlFlowEdge::isNormalEdge ( ) const

Returns true if the edge is representing unconditional jump

Returns
True if jump is not guarded

Definition at line 108 of file ControlFlowEdge.cc.

108 {
110}

References CFLOW_EDGE_NORMAL, and edgePredicate_.

Referenced by ControlFlowGraph::hasMultipleUnconditionalSuccessors(), ControlFlowGraph::mergeNodes(), and toString().

◆ isTrueEdge()

bool ControlFlowEdge::isTrueEdge ( ) const

Returns true if edge represents conditional control flow that is taken if condition evaluates to true.

Returns
True if edge represents True path

Definition at line 119 of file ControlFlowEdge.cc.

119 {
121}

References CFLOW_EDGE_TRUE, and edgePredicate_.

Referenced by PreOptimizer::cfgAllowsJumpReversal(), ControlFlowGraph::reverseGuardOnOutEdges(), SimpleIfConverter::successors(), and toString().

◆ setBackEdge()

void ControlFlowEdge::setBackEdge ( )
inline

Add property to edge to mark is as back edge - loop edge DO NOT USE unless you know what you are doing!!!

Definition at line 88 of file ControlFlowEdge.hh.

88{ backEdge_ = true;}

References backEdge_.

Referenced by SimpleIfConverter::updateCfg().

◆ setPredicate()

void ControlFlowEdge::setPredicate ( CFGEdgePredicate  pred)
inline

Definition at line 81 of file ControlFlowEdge.hh.

81{ edgePredicate_ = pred; }

References edgePredicate_.

Referenced by ControlFlowGraph::mergeNodes(), and ControlFlowGraph::reverseGuardOnOutEdges().

◆ toString()

TCEString ControlFlowEdge::toString ( ) const
virtual

Returns type as a string. Helper for graph output to dot file.

Returns
String representing type of edge.

Reimplemented from GraphEdge.

Definition at line 64 of file ControlFlowEdge.cc.

64 {
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}
bool isBackEdge() const
bool isNormalEdge() const
bool isFalseEdge() const
bool isFallThroughEdge() const
bool isLoopBreakEdge() const
bool isJumpEdge() const
bool isCallPassEdge() const
bool isTrueEdge() const

References isBackEdge(), isCallPassEdge(), isFallThroughEdge(), isFalseEdge(), isJumpEdge(), isLoopBreakEdge(), isNormalEdge(), and isTrueEdge().

Referenced by ControlFlowGraph::reverseGuardOnOutEdges().

Here is the call graph for this function:

Member Data Documentation

◆ backEdge_

bool ControlFlowEdge::backEdge_
private

Definition at line 96 of file ControlFlowEdge.hh.

Referenced by isBackEdge(), and setBackEdge().

◆ edgePredicate_

CFGEdgePredicate ControlFlowEdge::edgePredicate_
private

◆ edgeType_

CFGEdgeType ControlFlowEdge::edgeType_
private

Definition at line 95 of file ControlFlowEdge.hh.

Referenced by edgeType(), isCallPassEdge(), isFallThroughEdge(), and isJumpEdge().


The documentation for this class was generated from the following files: