OpenASIP  2.0
Public Types | Public Member Functions | Private Attributes | List of all members
ControlDependenceNode Class Reference

#include <ControlDependenceNode.hh>

Inheritance diagram for ControlDependenceNode:
Inheritance graph
Collaboration diagram for ControlDependenceNode:
Collaboration graph

Public Types

enum  NodeType {
  CDEP_NODE_REGION, CDEP_NODE_PREDICATE, CDEP_NODE_BB, CDEP_NODE_LOOPENTRY,
  CDEP_NODE_LOOPCLOSE
}
 
typedef std::set< ControlDependenceNode * > NodesInfo
 Storage type for other nodes of same graph needed to define some non graph relations. Duplicit type compared to NodeSet, but that is defined in Graph class. More...
 

Public Member Functions

 ControlDependenceNode (const NodeType type=CDEP_NODE_BB, BasicBlockNode *bblock=NULL)
 
virtual ~ControlDependenceNode ()
 
bool isControlDependenceNode () const
 
bool isRegionNode () const
 
bool isPredicateNode () const
 
bool isBBNode () const
 
bool isEntryNode () const
 
bool isExitNode () const
 
bool isLoopEntryNode () const
 
bool isLoopEntryNode (int component) const
 
bool isLoopCloseNode () const
 
void setLoopEntryNode (int component)
 
void setComponent (int component)
 
int component () const
 
void setLastNode ()
 LastNode marks node that must be ordered last compared to it's sibling nodes - Close node of loop. More...
 
bool isLastNode () const
 
int instructionCount () const
 
TTAProgram::Instructioninstruction (int index) const
 
BasicBlockNodebasicBlockNode () const
 
NodeType type () const
 
std::string toString () const
 
void addToRegion (ControlDependenceNode &node)
 
const NodesInforegion ()
 
void addToEEC (ControlDependenceNode &node)
 
const NodesInfoeec ()
 
void addToPseudoPredicateEEC (ControlDependenceNode &node)
 
const NodesInfopseudoPredicateEEC ()
 
void printRelations () const
 
- Public Member Functions inherited from GraphNode
 GraphNode (int nodeID)
 
 GraphNode ()
 
virtual ~GraphNode ()
 
virtual GraphNodeclone () const
 
int nodeID () const
 
virtual std::string dotString () const
 

Private Attributes

NodeType type_
 
BasicBlockNodecode_
 
NodesInfo region_
 Stores "region" information for computing serialization information. More...
 
NodesInfo eec_
 Stores "eec" information for computing serialization information. More...
 
NodesInfo pseudoPredicateEEC_
 Stores "shadow" eec information for predicate basic blocks which can be then copied into PDG for nodes of basic blocks that are not actuall predicate node. More...
 
int component_
 Number of strong component the node belongs to, if any. More...
 
bool lastNode_
 Indicated that the node should be scheduled last from it's siblings Case when node is predicate or region, has close node in it's subgraph and ancestor which is loop entry node. More...
 

Detailed Description

Node of the control dependence graph. Each node represents one basic block or region node.

A basic block is defined as an ordered sequence of adjacent instructions in which only the first can be target of jump and ony the last one (save jump delay slots) can contain jumps.

Note
Instructions that contain function calls are control flow bariers also. For now they split basic blocks into two, with special type of edge connecting them.

Definition at line 61 of file ControlDependenceNode.hh.

Member Typedef Documentation

◆ NodesInfo

Storage type for other nodes of same graph needed to define some non graph relations. Duplicit type compared to NodeSet, but that is defined in Graph class.

Definition at line 73 of file ControlDependenceNode.hh.

Member Enumeration Documentation

◆ NodeType

Enumerator
CDEP_NODE_REGION 
CDEP_NODE_PREDICATE 
CDEP_NODE_BB 
CDEP_NODE_LOOPENTRY 
CDEP_NODE_LOOPCLOSE 

Definition at line 63 of file ControlDependenceNode.hh.

63  {
64  CDEP_NODE_REGION, // Region nodes of CDG
65  CDEP_NODE_PREDICATE, // Predicate nodes of CDG
66  CDEP_NODE_BB, // Basic block nodes containing code snippets
67  CDEP_NODE_LOOPENTRY, // Region that is loop entry node
68  CDEP_NODE_LOOPCLOSE // Region that is loop entry node
69  };

Constructor & Destructor Documentation

◆ ControlDependenceNode()

ControlDependenceNode::ControlDependenceNode ( const NodeType  type = CDEP_NODE_BB,
BasicBlockNode bblock = NULL 
)
inline

Definition at line 74 of file ControlDependenceNode.hh.

76  :
77  type_(type), code_(bblock), component_(-1), lastNode_(false) {}

◆ ~ControlDependenceNode()

ControlDependenceNode::~ControlDependenceNode ( )
virtual

Destructor.

Definition at line 44 of file ControlDependenceNode.cc.

44  {
45  region_.clear();
46  eec_.clear();
47  pseudoPredicateEEC_.clear();
48 }

References eec_, pseudoPredicateEEC_, and region_.

Member Function Documentation

◆ addToEEC()

void ControlDependenceNode::addToEEC ( ControlDependenceNode node)

Add CDG node to "eec" set for computing serialization information

Parameters
nodeControl Dependence Node to add to the set

Definition at line 232 of file ControlDependenceNode.cc.

232  {
233  eec_.insert(&node);
234 }

References eec_.

Referenced by ControlDependenceGraph::computeEECInfo().

◆ addToPseudoPredicateEEC()

void ControlDependenceNode::addToPseudoPredicateEEC ( ControlDependenceNode node)

Add CDG node to "pseduo eec" set for computing serialization information case node is predicate basic block. Only actuall predicate move will have predicate eec, rest of moves of basic block needs regular 'leaf' eec computation

Parameters
nodeControl Dependence Node to add to the set

Definition at line 257 of file ControlDependenceNode.cc.

257  {
258  pseudoPredicateEEC_.insert(&node);
259 }

References pseudoPredicateEEC_.

Referenced by ControlDependenceGraph::computeEECInfo().

◆ addToRegion()

void ControlDependenceNode::addToRegion ( ControlDependenceNode node)

Add CDG node to "region" set for computing serialization information

Parameters
nodeControl Dependence Node to add to the set

Definition at line 212 of file ControlDependenceNode.cc.

212  {
213  region_.insert(&node);
214 }

References region_.

Referenced by ControlDependenceGraph::computeRegionInfo().

◆ basicBlockNode()

BasicBlockNode * ControlDependenceNode::basicBlockNode ( ) const

Returns a basic block refered by the control dependence node

Returns
the Basic block

Definition at line 116 of file ControlDependenceNode.cc.

116  {
117  if (isBBNode() || isPredicateNode()) {
118  return code_;
119  }
120  std::string msg = "Trying to read from non basic block node!";
121  throw InvalidData(__FILE__, __LINE__, __func__, msg);
122  return NULL;
123 }

References __func__, code_, isBBNode(), and isPredicateNode().

Referenced by ProgramDependenceGraph::ProgramDependenceGraph().

Here is the call graph for this function:

◆ component()

int ControlDependenceNode::component ( ) const
inline

◆ eec()

const ControlDependenceNode::NodesInfo & ControlDependenceNode::eec ( )

Returns the "eec" set for given node

Returns
the "eec" set for given node

Definition at line 243 of file ControlDependenceNode.cc.

243  {
244  return eec_;
245 }

References eec_.

Referenced by ControlDependenceGraph::computeEECInfo(), and ProgramDependenceGraph::copyRegionEECComponent().

◆ instruction()

TTAProgram::Instruction & ControlDependenceNode::instruction ( int  index) const

Returns instruction at given index in basic block.

Parameters
indexIndex of instruction in basic block
Returns
The instruction at given index

Definition at line 56 of file ControlDependenceNode.cc.

56  {
57  if (!isBBNode()) {
58  std::string msg =
59  "Trying to read from non basic block node" + toString() + "!";
60  throw InvalidData(__FILE__, __LINE__, __func__, msg);
61  }
62  return code_->basicBlock().instructionAtIndex(index);
63 }

References __func__, BasicBlockNode::basicBlock(), code_, TTAProgram::CodeSnippet::instructionAtIndex(), isBBNode(), and toString().

Here is the call graph for this function:

◆ instructionCount()

int ControlDependenceNode::instructionCount ( ) const

Returns number of instructions in basic block

Returns
number of instructions

Definition at line 130 of file ControlDependenceNode.cc.

130  {
131  if (isBBNode()) {
132  return code_->basicBlock().instructionCount();
133  }
134  std::string msg = "Trying to read from non basic block node!";
135  throw InvalidData(__FILE__, __LINE__, __func__, msg);
136  return 0;
137 }

References __func__, BasicBlockNode::basicBlock(), code_, TTAProgram::CodeSnippet::instructionCount(), and isBBNode().

Here is the call graph for this function:

◆ isBBNode()

bool ControlDependenceNode::isBBNode ( ) const

Predicate nodes are BB which ends with conditional jump in CFG

Definition at line 155 of file ControlDependenceNode.cc.

155  {
156  /// Predicate nodes are BB which ends with conditional jump in CFG
157  return (type_ == CDEP_NODE_BB) || isPredicateNode();
158 }

References CDEP_NODE_BB, isPredicateNode(), and type_.

Referenced by basicBlockNode(), ControlDependenceGraph::eliminateMultipleOutputs(), instruction(), instructionCount(), and toString().

Here is the call graph for this function:

◆ isControlDependenceNode()

bool ControlDependenceNode::isControlDependenceNode ( ) const

Definition at line 140 of file ControlDependenceNode.cc.

140  {
141  return true;
142 }

◆ isEntryNode()

bool ControlDependenceNode::isEntryNode ( ) const

Definition at line 161 of file ControlDependenceNode.cc.

161  {
162  return type_ == CDEP_NODE_BB && code_->isEntryBB();
163 }

References CDEP_NODE_BB, code_, BasicBlockNode::isEntryBB(), and type_.

Referenced by ControlDependenceGraph::entryNode(), ProgramDependenceGraph::ProgramDependenceGraph(), setLoopEntryNode(), and toString().

Here is the call graph for this function:

◆ isExitNode()

bool ControlDependenceNode::isExitNode ( ) const

Definition at line 166 of file ControlDependenceNode.cc.

166  {
167  return type_ == CDEP_NODE_BB && code_->isExitBB();
168 }

References CDEP_NODE_BB, code_, BasicBlockNode::isExitBB(), and type_.

Referenced by toString().

Here is the call graph for this function:

◆ isLastNode()

bool ControlDependenceNode::isLastNode ( ) const
inline

◆ isLoopCloseNode()

bool ControlDependenceNode::isLoopCloseNode ( ) const

◆ isLoopEntryNode() [1/2]

bool ControlDependenceNode::isLoopEntryNode ( ) const

◆ isLoopEntryNode() [2/2]

bool ControlDependenceNode::isLoopEntryNode ( int  component) const

Definition at line 176 of file ControlDependenceNode.cc.

176  {
178 }

References CDEP_NODE_LOOPENTRY, component(), component_, and type_.

Here is the call graph for this function:

◆ isPredicateNode()

bool ControlDependenceNode::isPredicateNode ( ) const

◆ isRegionNode()

bool ControlDependenceNode::isRegionNode ( ) const

◆ printRelations()

void ControlDependenceNode::printRelations ( ) const

Definition at line 273 of file ControlDependenceNode.cc.

273  {
274  Application::logStream() << "Relations: ";
275  for (NodesInfo::const_iterator iter = region_.begin();
276  iter != region_.end();
277  iter ++) {
278  Application::logStream() << (*iter)->toString() << ", ";
279  }
280  Application::logStream() << std::endl;
281  Application::logStream() << "EEC: ";
282  for (NodesInfo::const_iterator iter = eec_.begin();
283  iter != eec_.end();
284  iter ++) {
285  Application::logStream() << (*iter)->toString() << ", ";
286  }
287  Application::logStream() << std::endl;
288 
289 }

References eec_, Application::logStream(), and region_.

Here is the call graph for this function:

◆ pseudoPredicateEEC()

const ControlDependenceNode::NodesInfo & ControlDependenceNode::pseudoPredicateEEC ( )

Returns the "pseudo eec" set for given node, applicable for predicate nodes

Returns
the "eec" set for given node

Definition at line 268 of file ControlDependenceNode.cc.

268  {
269  return pseudoPredicateEEC_;
270 }

References pseudoPredicateEEC_.

Referenced by ProgramDependenceGraph::copyRegionEECComponent().

◆ region()

const ControlDependenceNode::NodesInfo & ControlDependenceNode::region ( )

Returns the "region" set for given node

Returns
the "region" set for given node

Definition at line 222 of file ControlDependenceNode.cc.

222  {
223  return region_;
224 }

References region_.

Referenced by ControlDependenceGraph::computeEECInfo(), ControlDependenceGraph::computeRegionInfo(), and ProgramDependenceGraph::copyRegionEECComponent().

◆ setComponent()

void ControlDependenceNode::setComponent ( int  component)
inline

Definition at line 90 of file ControlDependenceNode.hh.

References component(), and component_.

Here is the call graph for this function:

◆ setLastNode()

void ControlDependenceNode::setLastNode ( )
inline

LastNode marks node that must be ordered last compared to it's sibling nodes - Close node of loop.

Definition at line 94 of file ControlDependenceNode.hh.

94 { lastNode_ = true; }

References lastNode_.

◆ setLoopEntryNode()

void ControlDependenceNode::setLoopEntryNode ( int  component)

In case node was previously in other component as regular region, mark it as loop entry of current component

Definition at line 186 of file ControlDependenceNode.cc.

186  {
187  if (!isRegionNode() && !isEntryNode()) {
188  TCEString msg = "Loop entry node \'" + toString();
189  msg += "\' is not a Region node!";
190  throw InvalidData(
191  __FILE__, __LINE__, __func__, msg);
192  } else {
194  }
195  /// In case node was previously in other component as regular
196  /// region, mark it as loop entry of current component
197  if (component_ != component) {
199  }
200 }

References __func__, CDEP_NODE_LOOPENTRY, component(), component_, isEntryNode(), isRegionNode(), toString(), and type_.

Here is the call graph for this function:

◆ toString()

std::string ControlDependenceNode::toString ( ) const
virtual

Returns the type of basic block as string.

Note
Used in writting graph to .dot file.
Returns
The type of basic block

Reimplemented from GraphNode.

Definition at line 72 of file ControlDependenceNode.cc.

72  {
73  TCEString result = "";
74  if (isRegionNode()) {
75  result += "Region " + Conversion::toString(nodeID());
76  if (isLastNode()) {
77  result += "_LAST";
78  }
79  return result;
80  }
81  if (isLoopEntryNode()) {
82  result += "Loop Entry " + Conversion::toString(nodeID());
83  return result;
84  }
85  if (isEntryNode()) {
86  result += "Entry";
87  return result;
88  }
89  if (isLoopCloseNode()) {
90  result += "Close " + Conversion::toString(nodeID());
91  return result;
92  }
93 
94  if (isExitNode()) {
95  result += "Exit";
96  return result;
97  }
98  if (isPredicateNode()) {
99  result += "Predicate(" + code_->toString() +")";
100  if (isLastNode()) {
101  result += "_LAST";
102  }
103  return result;
104  }
105  if (isBBNode()) {
106  return code_->toString();
107  }
108  return result;
109 }

References code_, isBBNode(), isEntryNode(), isExitNode(), isLastNode(), isLoopCloseNode(), isLoopEntryNode(), isPredicateNode(), isRegionNode(), GraphNode::nodeID(), Conversion::toString(), and BasicBlockNode::toString().

Referenced by ControlDependenceGraph::computeEECInfo(), ControlDependenceGraph::entryNode(), instruction(), ControlDependenceGraph::regionHelper(), setLoopEntryNode(), and ProgramDependenceNode::toString().

Here is the call graph for this function:

◆ type()

ControlDependenceNode::NodeType ControlDependenceNode::type ( ) const

Definition at line 202 of file ControlDependenceNode.cc.

202  {
203  return type_;
204 }

References type_.

Member Data Documentation

◆ code_

BasicBlockNode* ControlDependenceNode::code_
private

◆ component_

int ControlDependenceNode::component_
private

Number of strong component the node belongs to, if any.

Definition at line 126 of file ControlDependenceNode.hh.

Referenced by component(), isLoopEntryNode(), setComponent(), and setLoopEntryNode().

◆ eec_

NodesInfo ControlDependenceNode::eec_
private

Stores "eec" information for computing serialization information.

Definition at line 120 of file ControlDependenceNode.hh.

Referenced by addToEEC(), eec(), printRelations(), and ~ControlDependenceNode().

◆ lastNode_

bool ControlDependenceNode::lastNode_
private

Indicated that the node should be scheduled last from it's siblings Case when node is predicate or region, has close node in it's subgraph and ancestor which is loop entry node.

Definition at line 130 of file ControlDependenceNode.hh.

Referenced by isLastNode(), and setLastNode().

◆ pseudoPredicateEEC_

NodesInfo ControlDependenceNode::pseudoPredicateEEC_
private

Stores "shadow" eec information for predicate basic blocks which can be then copied into PDG for nodes of basic blocks that are not actuall predicate node.

Definition at line 124 of file ControlDependenceNode.hh.

Referenced by addToPseudoPredicateEEC(), pseudoPredicateEEC(), and ~ControlDependenceNode().

◆ region_

NodesInfo ControlDependenceNode::region_
private

Stores "region" information for computing serialization information.

Definition at line 118 of file ControlDependenceNode.hh.

Referenced by addToRegion(), printRelations(), region(), and ~ControlDependenceNode().

◆ type_

NodeType ControlDependenceNode::type_
private

The documentation for this class was generated from the following files:
ControlDependenceNode::isRegionNode
bool isRegionNode() const
Definition: ControlDependenceNode.cc:145
BasicBlockNode::isExitBB
bool isExitBB() const
Definition: BasicBlockNode.cc:257
ControlDependenceNode::lastNode_
bool lastNode_
Indicated that the node should be scheduled last from it's siblings Case when node is predicate or re...
Definition: ControlDependenceNode.hh:130
ControlDependenceNode::isEntryNode
bool isEntryNode() const
Definition: ControlDependenceNode.cc:161
GraphNode::nodeID
int nodeID() const
ControlDependenceNode::toString
std::string toString() const
Definition: ControlDependenceNode.cc:72
Application::logStream
static std::ostream & logStream()
Definition: Application.cc:155
Conversion::toString
static std::string toString(const T &source)
ControlDependenceNode::type
NodeType type() const
Definition: ControlDependenceNode.cc:202
BasicBlockNode::basicBlock
TTAProgram::BasicBlock & basicBlock()
Definition: BasicBlockNode.cc:126
ControlDependenceNode::pseudoPredicateEEC_
NodesInfo pseudoPredicateEEC_
Stores "shadow" eec information for predicate basic blocks which can be then copied into PDG for node...
Definition: ControlDependenceNode.hh:124
InvalidData
Definition: Exception.hh:149
ControlDependenceNode::region_
NodesInfo region_
Stores "region" information for computing serialization information.
Definition: ControlDependenceNode.hh:118
TTAProgram::CodeSnippet::instructionCount
virtual int instructionCount() const
Definition: CodeSnippet.cc:205
__func__
#define __func__
Definition: Application.hh:67
BasicBlockNode::isEntryBB
bool isEntryBB() const
Definition: BasicBlockNode.cc:248
ControlDependenceNode::CDEP_NODE_LOOPENTRY
@ CDEP_NODE_LOOPENTRY
Definition: ControlDependenceNode.hh:67
ControlDependenceNode::CDEP_NODE_PREDICATE
@ CDEP_NODE_PREDICATE
Definition: ControlDependenceNode.hh:65
ControlDependenceNode::component_
int component_
Number of strong component the node belongs to, if any.
Definition: ControlDependenceNode.hh:126
ControlDependenceNode::CDEP_NODE_REGION
@ CDEP_NODE_REGION
Definition: ControlDependenceNode.hh:64
ControlDependenceNode::isPredicateNode
bool isPredicateNode() const
Definition: ControlDependenceNode.cc:150
ControlDependenceNode::isLastNode
bool isLastNode() const
Definition: ControlDependenceNode.hh:95
ControlDependenceNode::component
int component() const
Definition: ControlDependenceNode.hh:91
ControlDependenceNode::type_
NodeType type_
Definition: ControlDependenceNode.hh:115
ControlDependenceNode::CDEP_NODE_LOOPCLOSE
@ CDEP_NODE_LOOPCLOSE
Definition: ControlDependenceNode.hh:68
TCEString
Definition: TCEString.hh:53
ControlDependenceNode::isLoopCloseNode
bool isLoopCloseNode() const
Definition: ControlDependenceNode.cc:181
TTAProgram::CodeSnippet::instructionAtIndex
virtual Instruction & instructionAtIndex(int index) const
Definition: CodeSnippet.cc:285
ControlDependenceNode::isExitNode
bool isExitNode() const
Definition: ControlDependenceNode.cc:166
ControlDependenceNode::isBBNode
bool isBBNode() const
Definition: ControlDependenceNode.cc:155
ControlDependenceNode::eec_
NodesInfo eec_
Stores "eec" information for computing serialization information.
Definition: ControlDependenceNode.hh:120
ControlDependenceNode::isLoopEntryNode
bool isLoopEntryNode() const
Definition: ControlDependenceNode.cc:171
ControlDependenceNode::code_
BasicBlockNode * code_
Definition: ControlDependenceNode.hh:116
BasicBlockNode::toString
std::string toString() const
Definition: BasicBlockNode.cc:185
ControlDependenceNode::CDEP_NODE_BB
@ CDEP_NODE_BB
Definition: ControlDependenceNode.hh:66