OpenASIP  2.0
ControlDependenceNode.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 ControlDependenceNode.hh
26  *
27  * Prototype control dependence graph of TTA program representation:
28  * declaration of graph node (basic block or region node).
29  *
30  * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_CONTROL_DEPENDENCE_NODE_HH
35 #define TTA_CONTROL_DEPENDENCE_NODE_HH
36 
37 #include <string>
38 #include <set>
39 
40 #include "TCEString.hh"
41 #include "GraphNode.hh"
42 #include "CodeSnippet.hh"
43 #include "BasicBlockNode.hh"
44 
45 namespace TTAProgram {
46 class Instruction;
47 class CodeSnippet;
48 }
49 /**
50  * Node of the control dependence graph. Each node represents one basic block
51  * or region node.
52  *
53  * A basic block is defined as an ordered sequence of adjacent instructions
54  * in which only the first can be target of jump and ony the last one (save
55  * jump delay slots) can contain jumps.
56  *
57  * @note Instructions that contain function calls are control flow bariers
58  * also. For now they split basic blocks into two, with special type of edge
59  * connecting them.
60  */
62 public:
63  enum NodeType {
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  };
70  /// Storage type for other nodes of same graph needed to define
71  /// some non graph relations.
72  /// Duplicit type compared to NodeSet, but that is defined in Graph class
73  typedef std::set<ControlDependenceNode*> NodesInfo;
75  const NodeType type = CDEP_NODE_BB,
76  BasicBlockNode* bblock = NULL) :
77  type_(type), code_(bblock), component_(-1), lastNode_(false) {}
78  virtual ~ControlDependenceNode();
79 
80  bool isControlDependenceNode() const;
81  bool isRegionNode() const;
82  bool isPredicateNode() const;
83  bool isBBNode() const;
84  bool isEntryNode() const;
85  bool isExitNode() const;
86  bool isLoopEntryNode() const;
87  bool isLoopEntryNode(int component) const;
88  bool isLoopCloseNode() const;
89  void setLoopEntryNode(int component);
91  int component() const { return component_;}
92  /// LastNode marks node that must be ordered last compared to it's
93  /// sibling nodes - Close node of loop
94  void setLastNode() { lastNode_ = true; }
95  bool isLastNode() const { return lastNode_;}
96  int instructionCount() const;
97  TTAProgram::Instruction& instruction(int index) const;
99 
100  NodeType type() const;
101  std::string toString() const;
102 
104  const NodesInfo& region();
105 
106  void addToEEC(ControlDependenceNode& node);
107  const NodesInfo& eec();
108 
110  const NodesInfo& pseudoPredicateEEC();
111 
112  void printRelations() const;
113 
114 private:
117  /// Stores "region" information for computing serialization information
119  /// Stores "eec" information for computing serialization information
121  /// Stores "shadow" eec information for predicate basic blocks
122  /// which can be then copied into PDG for nodes of basic blocks
123  /// that are not actuall predicate node
125  /// Number of strong component the node belongs to, if any
127  /// Indicated that the node should be scheduled last from it's siblings
128  /// Case when node is predicate or region, has close node in it's subgraph
129  /// and ancestor which is loop entry node
130  bool lastNode_;
131 };
132 
133 #endif
TTAProgram
Definition: Estimator.hh:65
ControlDependenceNode::isRegionNode
bool isRegionNode() const
Definition: ControlDependenceNode.cc:145
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::basicBlockNode
BasicBlockNode * basicBlockNode() const
Definition: ControlDependenceNode.cc:116
ControlDependenceNode::setComponent
void setComponent(int component)
Definition: ControlDependenceNode.hh:90
ControlDependenceNode::eec
const NodesInfo & eec()
Definition: ControlDependenceNode.cc:243
ControlDependenceNode::isEntryNode
bool isEntryNode() const
Definition: ControlDependenceNode.cc:161
TTAProgram::Instruction
Definition: Instruction.hh:57
BasicBlockNode.hh
GraphNode.hh
ControlDependenceNode::toString
std::string toString() const
Definition: ControlDependenceNode.cc:72
ControlDependenceNode::addToPseudoPredicateEEC
void addToPseudoPredicateEEC(ControlDependenceNode &node)
Definition: ControlDependenceNode.cc:257
ControlDependenceNode::NodesInfo
std::set< ControlDependenceNode * > NodesInfo
Storage type for other nodes of same graph needed to define some non graph relations....
Definition: ControlDependenceNode.hh:73
ControlDependenceNode::instruction
TTAProgram::Instruction & instruction(int index) const
Definition: ControlDependenceNode.cc:56
ControlDependenceNode::type
NodeType type() const
Definition: ControlDependenceNode.cc:202
TCEString.hh
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
ControlDependenceNode::printRelations
void printRelations() const
Definition: ControlDependenceNode.cc:273
ControlDependenceNode::region_
NodesInfo region_
Stores "region" information for computing serialization information.
Definition: ControlDependenceNode.hh:118
ControlDependenceNode::region
const NodesInfo & region()
Definition: ControlDependenceNode.cc:222
BasicBlockNode
Definition: BasicBlockNode.hh:64
ControlDependenceNode::CDEP_NODE_LOOPENTRY
@ CDEP_NODE_LOOPENTRY
Definition: ControlDependenceNode.hh:67
ControlDependenceNode::setLoopEntryNode
void setLoopEntryNode(int component)
Definition: ControlDependenceNode.cc:186
CodeSnippet.hh
ControlDependenceNode::CDEP_NODE_PREDICATE
@ CDEP_NODE_PREDICATE
Definition: ControlDependenceNode.hh:65
ControlDependenceNode::ControlDependenceNode
ControlDependenceNode(const NodeType type=CDEP_NODE_BB, BasicBlockNode *bblock=NULL)
Definition: ControlDependenceNode.hh:74
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::addToRegion
void addToRegion(ControlDependenceNode &node)
Definition: ControlDependenceNode.cc:212
ControlDependenceNode::addToEEC
void addToEEC(ControlDependenceNode &node)
Definition: ControlDependenceNode.cc:232
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
ControlDependenceNode::~ControlDependenceNode
virtual ~ControlDependenceNode()
Definition: ControlDependenceNode.cc:44
false
find Finds info of the inner loops in the false
Definition: InnerLoopFinder.cc:81
ControlDependenceNode::instructionCount
int instructionCount() const
Definition: ControlDependenceNode.cc:130
ControlDependenceNode::setLastNode
void setLastNode()
LastNode marks node that must be ordered last compared to it's sibling nodes - Close node of loop.
Definition: ControlDependenceNode.hh:94
ControlDependenceNode::isLoopCloseNode
bool isLoopCloseNode() const
Definition: ControlDependenceNode.cc:181
ControlDependenceNode::pseudoPredicateEEC
const NodesInfo & pseudoPredicateEEC()
Definition: ControlDependenceNode.cc:268
ControlDependenceNode::isExitNode
bool isExitNode() const
Definition: ControlDependenceNode.cc:166
ControlDependenceNode::isControlDependenceNode
bool isControlDependenceNode() const
Definition: ControlDependenceNode.cc:140
GraphNode
Definition: GraphNode.hh:42
ControlDependenceNode::isBBNode
bool isBBNode() const
Definition: ControlDependenceNode.cc:155
ControlDependenceNode
Definition: ControlDependenceNode.hh:61
ControlDependenceNode::eec_
NodesInfo eec_
Stores "eec" information for computing serialization information.
Definition: ControlDependenceNode.hh:120
ControlDependenceNode::NodeType
NodeType
Definition: ControlDependenceNode.hh:63
ControlDependenceNode::isLoopEntryNode
bool isLoopEntryNode() const
Definition: ControlDependenceNode.cc:171
ControlDependenceNode::code_
BasicBlockNode * code_
Definition: ControlDependenceNode.hh:116
ControlDependenceNode::CDEP_NODE_BB
@ CDEP_NODE_BB
Definition: ControlDependenceNode.hh:66