OpenASIP  2.0
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!!! More...
 
- 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.

59  {
63  };

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 }

◆ ~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 }

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

◆ 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 }

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:
ControlFlowEdge::CFLOW_EDGE_LOOP_BREAK
@ CFLOW_EDGE_LOOP_BREAK
Definition: ControlFlowEdge.hh:56
TTAProgram::Move::isTriggering
bool isTriggering() const
Definition: Move.cc:284
ControlFlowEdge::isJumpEdge
bool isJumpEdge() const
Definition: ControlFlowEdge.cc:148
TTAProgram::MoveGuard::isInverted
bool isInverted() const
Definition: MoveGuard.cc:76
ControlFlowEdge::edgeType
CFGEdgeType edgeType()
Definition: ControlFlowEdge.hh:84
TTAProgram::Move::isUnconditional
bool isUnconditional() const
Definition: Move.cc:154
TTAProgram::Move::destination
Terminal & destination() const
Definition: Move.cc:323
TTAProgram::Terminal::hintOperation
virtual Operation & hintOperation() const
Definition: Terminal.cc:341
ControlFlowEdge::isBackEdge
bool isBackEdge() const
Definition: ControlFlowEdge.cc:179
NullOperation::instance
static NullOperation & instance()
Operation::name
virtual TCEString name() const
Definition: Operation.cc:93
ControlFlowEdge::isNormalEdge
bool isNormalEdge() const
Definition: ControlFlowEdge.cc:108
ControlFlowEdge::isTrueEdge
bool isTrueEdge() const
Definition: ControlFlowEdge.cc:119
ControlFlowEdge::CFLOW_EDGE_NORMAL
@ CFLOW_EDGE_NORMAL
Definition: ControlFlowEdge.hh:53
TTAProgram::Terminal::operation
virtual Operation & operation() const
Definition: Terminal.cc:319
ControlFlowEdge::isLoopBreakEdge
bool isLoopBreakEdge() const
Definition: ControlFlowEdge.cc:169
TTAProgram::Move::guard
MoveGuard & guard() const
Definition: Move.cc:345
ControlFlowEdge::backEdge_
bool backEdge_
Definition: ControlFlowEdge.hh:96
ControlFlowEdge::CFLOW_EDGE_FAKE
@ CFLOW_EDGE_FAKE
Definition: ControlFlowEdge.hh:57
ControlFlowEdge::isFallThroughEdge
bool isFallThroughEdge() const
Definition: ControlFlowEdge.cc:158
Operation
Definition: Operation.hh:59
ControlFlowEdge::edgePredicate
CFGEdgePredicate edgePredicate() const
Definition: ControlFlowEdge.hh:83
ControlFlowEdge::isCallPassEdge
bool isCallPassEdge() const
Definition: ControlFlowEdge.cc:138
TCEString
Definition: TCEString.hh:53
ControlFlowEdge::CFLOW_EDGE_FALSE
@ CFLOW_EDGE_FALSE
Definition: ControlFlowEdge.hh:55
ControlFlowEdge::edgePredicate_
CFGEdgePredicate edgePredicate_
Definition: ControlFlowEdge.hh:94
TTAProgram::MoveGuard
Definition: MoveGuard.hh:47
ControlFlowEdge::CFLOW_EDGE_FALLTHROUGH
@ CFLOW_EDGE_FALLTHROUGH
Definition: ControlFlowEdge.hh:62
ControlFlowEdge::CFLOW_EDGE_TRUE
@ CFLOW_EDGE_TRUE
Definition: ControlFlowEdge.hh:54
ControlFlowEdge::CFLOW_EDGE_CALL
@ CFLOW_EDGE_CALL
Definition: ControlFlowEdge.hh:61
ControlFlowEdge::isFalseEdge
bool isFalseEdge() const
Definition: ControlFlowEdge.cc:129
ControlFlowEdge::CFLOW_EDGE_JUMP
@ CFLOW_EDGE_JUMP
Definition: ControlFlowEdge.hh:60
ControlFlowEdge::edgeType_
CFGEdgeType edgeType_
Definition: ControlFlowEdge.hh:95