OpenASIP  2.0
ProgramDependenceNode.hh
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 ProgramDependenceNode.hh
26  *
27  * Declaration of prototype of graph-based program representation:
28  * declaration of the program dependence node.
29  *
30  * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
31  * @note rating: red
32  */
33 #ifndef TTA_PROGRAM_DEPENDENCE_NODE_HH
34 #define TTA_PROGRAM_DEPENDENCE_NODE_HH
35 
36 #include "ControlDependenceNode.hh"
37 
38 class MoveNode;
39 class BasicBlockNode;
40 
41 /**
42 */
44 public:
45  enum NodeType {
46  PDG_NODE_REGION, // Region nodes of PDG
47  PDG_NODE_PREDICATE, // Predicate nodes of PDG
48  PDG_NODE_MOVE, // Single statements nodes
49  PDG_NODE_LOOPENTRY, // Region that is loop entry node
50  PDG_NODE_LOOPCLOSE // Region that is loop entry node
51  };
52 
56  NodeType type = PDG_NODE_REGION);
58  MoveNode& mNode,
59  NodeType type = PDG_NODE_MOVE);
60  virtual ~ProgramDependenceNode();
61 
62  // Stores information about region and eec
63  // Duplicates NodeSet which is available only in Graph :(
64  typedef std::set<ProgramDependenceNode*> NodesInfo;
65  bool isRegionNode() const { return type_ == PDG_NODE_REGION;}
66  bool isPredicateMoveNode() const { return type_ == PDG_NODE_PREDICATE;}
67  bool isMoveNode() const { return type_ == PDG_NODE_MOVE;}
68  bool isLoopEntryNode() const { return type_ == PDG_NODE_LOOPENTRY;}
69  bool isLoopEntryNode(int component) const {
71  bool isLoopCloseNode() const { return type_ == PDG_NODE_LOOPCLOSE;}
72  bool isLastNode() const { return lastNode_;}
73  void setLoopEntryNode(int component);
75  void setLastNode() { lastNode_ = true; }
76  int component() const { return component_;}
77 
78  MoveNode& moveNode();
79  const MoveNode& moveNode() const;
81  const ControlDependenceNode& cdgNode() const;
82  std::string dotString() const;
83  std::string toString() const;
84  const NodesInfo& region();
85  const NodesInfo& eec();
86  void printRelations() const;
88  void setNewFirstBB(BasicBlockNode* newBB) { newFirstBB_ = newBB;}
89  std::vector<BasicBlockNode*> leafBlocks() { return leafBlocks_;}
90  void addLeafBlock(BasicBlockNode* newLeaf) {
91  leafBlocks_.push_back(newLeaf); }
92  void addLeafBlocks(std::vector<BasicBlockNode*> newLeafs) {
93  leafBlocks_.insert(leafBlocks_.end(), newLeafs.begin(), newLeafs.end());
94  }
95 
96 protected:
97  friend class ProgramDependenceGraph;
98  void setPredicateMoveNode();
101 private:
105  /// Stores "region" information for computing serialization information
107  /// Stores "eec" information for computing serialization information
109  /// Number of strong component the node belongs to.
110  /// Node can be part of several strong components so this value
111  /// have practical meaning only for loop close nodes - close just one
112  /// loop, and loop entry nodes - marks a component in which node is
113  /// loop entry. Still can be regular region of larger loop
114  /// Full list of nodes that belongs to actual components is available
115  /// in strongComponents_ vector in PDG
117  /// First basic block of a subgraph of a region
119  /// Vector of basic blocks of a subgraph that do not have outgoing
120  /// edged and will need to get connected
121  std::vector<BasicBlockNode*> leafBlocks_;
122  /// Indicates that node must be scheduled last between it's siblings
123  /// because it's subgraph contains close node and it's parent is entry
124  bool lastNode_;
125 };
126 
127 #endif
ProgramDependenceNode::isRegionNode
bool isRegionNode() const
Definition: ProgramDependenceNode.hh:65
ProgramDependenceNode::isPredicateMoveNode
bool isPredicateMoveNode() const
Definition: ProgramDependenceNode.hh:66
ProgramDependenceNode::toString
std::string toString() const
Definition: ProgramDependenceNode.cc:93
ProgramDependenceNode::PDG_NODE_PREDICATE
@ PDG_NODE_PREDICATE
Definition: ProgramDependenceNode.hh:47
ProgramDependenceNode::type_
NodeType type_
Definition: ProgramDependenceNode.hh:104
ProgramDependenceNode::addLeafBlocks
void addLeafBlocks(std::vector< BasicBlockNode * > newLeafs)
Definition: ProgramDependenceNode.hh:92
BoostGraph< ProgramDependenceNode, ProgramDependenceEdge >::node
Node & node(const int index) const
ProgramDependenceNode::isLoopEntryNode
bool isLoopEntryNode() const
Definition: ProgramDependenceNode.hh:68
ProgramDependenceNode::dotString
std::string dotString() const
Definition: ProgramDependenceNode.cc:140
ProgramDependenceNode::~ProgramDependenceNode
virtual ~ProgramDependenceNode()
Definition: ProgramDependenceNode.cc:83
ProgramDependenceNode::PDG_NODE_REGION
@ PDG_NODE_REGION
Definition: ProgramDependenceNode.hh:46
ProgramDependenceNode::setLoopEntryNode
void setLoopEntryNode(int component)
Definition: ProgramDependenceNode.cc:292
ProgramDependenceNode::PDG_NODE_LOOPENTRY
@ PDG_NODE_LOOPENTRY
Definition: ProgramDependenceNode.hh:49
ProgramDependenceNode::leafBlocks
std::vector< BasicBlockNode * > leafBlocks()
Definition: ProgramDependenceNode.hh:89
MoveNode
Definition: MoveNode.hh:65
ProgramDependenceNode::setNewFirstBB
void setNewFirstBB(BasicBlockNode *newBB)
Definition: ProgramDependenceNode.hh:88
ProgramDependenceNode::ProgramDependenceNode
ProgramDependenceNode(NodeType type=PDG_NODE_REGION)
Definition: ProgramDependenceNode.cc:45
ProgramDependenceNode::eec
const NodesInfo & eec()
Definition: ProgramDependenceNode.cc:281
ProgramDependenceNode::moveNode
MoveNode & moveNode()
Definition: ProgramDependenceNode.cc:182
ProgramDependenceNode::NodesInfo
std::set< ProgramDependenceNode * > NodesInfo
Definition: ProgramDependenceNode.hh:64
ProgramDependenceNode::region
const NodesInfo & region()
Definition: ProgramDependenceNode.cc:260
ProgramDependenceNode::printRelations
void printRelations() const
Definition: ProgramDependenceNode.cc:297
ProgramDependenceNode::leafBlocks_
std::vector< BasicBlockNode * > leafBlocks_
Vector of basic blocks of a subgraph that do not have outgoing edged and will need to get connected.
Definition: ProgramDependenceNode.hh:121
ProgramDependenceNode::component
int component() const
Definition: ProgramDependenceNode.hh:76
ProgramDependenceNode::component_
int component_
Number of strong component the node belongs to. Node can be part of several strong components so this...
Definition: ProgramDependenceNode.hh:116
ProgramDependenceNode::cdgNode
ControlDependenceNode & cdgNode()
Definition: ProgramDependenceNode.cc:214
ProgramDependenceNode::region_
NodesInfo region_
Stores "region" information for computing serialization information.
Definition: ProgramDependenceNode.hh:106
BasicBlockNode
Definition: BasicBlockNode.hh:64
ProgramDependenceNode::addLeafBlock
void addLeafBlock(BasicBlockNode *newLeaf)
Definition: ProgramDependenceNode.hh:90
ProgramDependenceNode::addToEEC
void addToEEC(ProgramDependenceNode &node)
Definition: ProgramDependenceNode.cc:270
ProgramDependenceGraph
Definition: ProgramDependenceGraph.hh:51
ProgramDependenceNode::isMoveNode
bool isMoveNode() const
Definition: ProgramDependenceNode.hh:67
ProgramDependenceNode::cdgNode_
ControlDependenceNode * cdgNode_
Definition: ProgramDependenceNode.hh:103
ControlDependenceNode.hh
ProgramDependenceNode::PDG_NODE_LOOPCLOSE
@ PDG_NODE_LOOPCLOSE
Definition: ProgramDependenceNode.hh:50
ProgramDependenceNode::newFirstBB
BasicBlockNode * newFirstBB()
Definition: ProgramDependenceNode.hh:87
ProgramDependenceNode::setPredicateMoveNode
void setPredicateMoveNode()
Definition: ProgramDependenceNode.cc:168
ProgramDependenceNode::isLastNode
bool isLastNode() const
Definition: ProgramDependenceNode.hh:72
ProgramDependenceNode::setLastNode
void setLastNode()
Definition: ProgramDependenceNode.hh:75
ProgramDependenceNode::addToRegion
void addToRegion(ProgramDependenceNode &node)
Definition: ProgramDependenceNode.cc:250
ProgramDependenceNode::isLoopCloseNode
bool isLoopCloseNode() const
Definition: ProgramDependenceNode.hh:71
ProgramDependenceNode
Definition: ProgramDependenceNode.hh:43
ProgramDependenceNode::newFirstBB_
BasicBlockNode * newFirstBB_
First basic block of a subgraph of a region.
Definition: ProgramDependenceNode.hh:118
ProgramDependenceNode::mNode_
MoveNode * mNode_
Definition: ProgramDependenceNode.hh:102
ProgramDependenceNode::isLoopEntryNode
bool isLoopEntryNode(int component) const
Definition: ProgramDependenceNode.hh:69
GraphNode
Definition: GraphNode.hh:42
ControlDependenceNode
Definition: ControlDependenceNode.hh:61
ProgramDependenceNode::setComponent
void setComponent(int component)
Definition: ProgramDependenceNode.hh:74
ProgramDependenceNode::eec_
NodesInfo eec_
Stores "eec" information for computing serialization information.
Definition: ProgramDependenceNode.hh:108
ProgramDependenceNode::NodeType
NodeType
Definition: ProgramDependenceNode.hh:45
ProgramDependenceNode::lastNode_
bool lastNode_
Indicates that node must be scheduled last between it's siblings because it's subgraph contains close...
Definition: ProgramDependenceNode.hh:124
ProgramDependenceNode::PDG_NODE_MOVE
@ PDG_NODE_MOVE
Definition: ProgramDependenceNode.hh:48