OpenASIP  2.0
MoveNode.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 MoveNode.hh
26  *
27  * Declaration of MoveNode class.
28  *
29  * MoveNodes are the minimum independent unit of information in a
30  * minimally-ordered program representation. Typically, but not necessarily,
31  * the nodes in a program representation are linked together by dependences
32  * and thus form a graph.
33  *
34  * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
35  * @author Ari Metsähalme 2006 (ari.metsahalme-no.spam-tut.fi)
36  * @author Pekka Jääskeläinen 2010, 2011
37  * @note rating: red
38  */
39 
40 #ifndef TTA_MOVE_NODE_HH
41 #define TTA_MOVE_NODE_HH
42 
43 #include <vector>
44 #include <string>
45 #include <memory>
46 #include "Exception.hh"
47 #include "GraphNode.hh"
48 
49 // dummy classes until real implementations are written
50 class Scope{} ;
51 // Implementation in header file that includes this header file
53 typedef std::shared_ptr<ProgramOperation> ProgramOperationPtr;
54 
55 namespace TTAProgram{
56  class Move;
57  class Immediate;
58 }
59 
60 /**
61  * Node of the program representation.
62  *
63  * A MoveNode represents one move of a TTA program.
64  */
65 class MoveNode : public GraphNode {
66 public:
67 
68  explicit MoveNode(std::shared_ptr<TTAProgram::Move> newMove);
69  explicit MoveNode(std::shared_ptr<TTAProgram::Immediate> imm);
70  virtual ~MoveNode();
71 
72  MoveNode* copy();
73 
74  bool isSourceOperation() const;
75  bool isGuardOperation() const;
76  inline bool isDestinationOperation() const;
77  inline unsigned int destinationOperationCount() const;
78 
79  bool isOperationMove() const;
80 
81  bool isSourceVariable() const;
82  bool isSourceConstant() const;
83  bool isSourceRA() const;
84  bool isSourceImmediateRegister() const;
85  bool isDestinationVariable() const;
86  bool isBypass() const;
87 
88  bool isRegisterMove() const;
89  bool inSameOperation(const MoveNode& other) const;
90 
91  bool isPlaced() const;
92  bool isAssigned() const;
93  bool isScheduled() const;
94  void setCycle(const int newcycle);
95  void unsetCycle();
96  int cycle() const;
97 
98  int earliestResultReadCycle() const;
99  int latestTriggerWriteCycle() const;
100  int guardLatency() const;
101 
102  Scope& scope();
105  ProgramOperation& destinationOperation(unsigned int index = 0) const;
108  ProgramOperationPtr destinationOperationPtr(unsigned int index = 0) const;
109 
110  std::shared_ptr<TTAProgram::Move> movePtr();
111  std::shared_ptr<const TTAProgram::Move> movePtr() const;
112  std::shared_ptr<TTAProgram::Immediate> immediatePtr();
113  std::shared_ptr<const TTAProgram::Immediate> immediatePtr() const;
114 
116  const TTAProgram::Move& move() const;
118  const TTAProgram::Immediate& immediate() const;
119 
123 
126  void unsetSourceOperation();
127  void unsetGuardOperation();
128 
129  void finalize();
130  bool isFinalized() const;
131 
132  void setIsInFrontier(bool inFrontier = true);
133  bool isInFrontier() const;
134  bool isLastUnscheduledMoveOfDstOp() const;
135 
136  // to allow printing of graph
137  int type();
138  std::string toString() const;
139  std::string dotString() const;
140 
141  // is move or entry node?
142  inline bool isMove() const;
143  inline bool isImmediate() const { return immediate_ != nullptr; }
144  bool isSourceReg(const std::string& reg) const;
145 
146  /// Node can be entry node
147  MoveNode();
148 private:
149  /// Copying forbidden. Use copy() for a deep copy.
150  MoveNode(const MoveNode&);
151  /// Assignment forbidden
152  MoveNode& operator=(const MoveNode&);
153 
154  /// Pointer to Move this node represents, Node itself do not change move
155  const std::shared_ptr<TTAProgram::Move> move_;
156 
157  /// Pointer to Immediate this node represents, Node itself do not change move
158  const std::shared_ptr<TTAProgram::Immediate> immediate_;
159 
160  std::vector<ProgramOperationPtr> dstOps_;
161 
163 
165 
166  /// Cycle in which the node is placed. Each cycle uniquely identifies an
167  /// instruction slot within the current scheduling scope.
168  int cycle_;
169 
170  /// True when the node placed (is given a cycle in program).
171  bool placed_;
172 
173  /// The movenode cannot be unscheduled anymore, fixed in place.
175 
176  /// This is in scheduling frontier(used in Bubblefish scheduler)
178 };
179 
180 #include "MoveNode.icc"
181 
182 #endif
MoveNode::isLastUnscheduledMoveOfDstOp
bool isLastUnscheduledMoveOfDstOp() const
Definition: MoveNode.cc:817
MoveNode::scope
Scope & scope()
Definition: MoveNode.cc:436
TTAProgram
Definition: Estimator.hh:65
MoveNode::dotString
std::string dotString() const
Definition: MoveNode.cc:602
MoveNode::placed_
bool placed_
True when the node placed (is given a cycle in program).
Definition: MoveNode.hh:171
MoveNode::isDestinationVariable
bool isDestinationVariable() const
Definition: MoveNode.cc:264
MoveNode::toString
std::string toString() const
Definition: MoveNode.cc:576
MoveNode::guardOperationPtr
ProgramOperationPtr guardOperationPtr() const
Definition: MoveNode.cc:484
Exception.hh
MoveNode::finalized_
bool finalized_
The movenode cannot be unscheduled anymore, fixed in place.
Definition: MoveNode.hh:174
MoveNode::isDestinationOperation
bool isDestinationOperation() const
MoveNode::movePtr
std::shared_ptr< TTAProgram::Move > movePtr()
MoveNode::isFinalized
bool isFinalized() const
MoveNode.icc
GraphNode.hh
MoveNode::clearDestinationOperation
void clearDestinationOperation()
Definition: MoveNode.cc:730
MoveNode::isSourceReg
bool isSourceReg(const std::string &reg) const
Definition: MoveNode.cc:798
ProgramOperation
Definition: ProgramOperation.hh:70
MoveNode
Definition: MoveNode.hh:65
MoveNode::isSourceConstant
bool isSourceConstant() const
Definition: MoveNode.cc:238
MoveNode::finalize
void finalize()
Scope
Definition: MoveNode.hh:50
MoveNode::unsetCycle
void unsetCycle()
Definition: MoveNode.cc:519
MoveNode::isSourceRA
bool isSourceRA() const
Definition: MoveNode.cc:210
ProgramOperationPtr
std::shared_ptr< ProgramOperation > ProgramOperationPtr
Definition: MoveNode.hh:52
MoveNode::isSourceImmediateRegister
bool isSourceImmediateRegister() const
Definition: MoveNode.cc:223
MoveNode::MoveNode
MoveNode()
Node can be entry node.
Definition: MoveNode.cc:99
MoveNode::operator=
MoveNode & operator=(const MoveNode &)
Assignment forbidden.
MoveNode::isPlaced
bool isPlaced() const
Definition: MoveNode.cc:352
MoveNode::srcOp_
ProgramOperationPtr srcOp_
Definition: MoveNode.hh:162
MoveNode::setSourceOperationPtr
void setSourceOperationPtr(ProgramOperationPtr po)
Definition: MoveNode.cc:541
MoveNode::sourceOperation
ProgramOperation & sourceOperation() const
Definition: MoveNode.cc:453
MoveNode::isImmediate
bool isImmediate() const
Definition: MoveNode.hh:143
MoveNode::isMove
bool isMove() const
MoveNode::isBypass
bool isBypass() const
Definition: MoveNode.cc:280
MoveNode::isGuardOperation
bool isGuardOperation() const
Definition: MoveNode.cc:181
TTAProgram::Immediate
Definition: Immediate.hh:54
MoveNode::earliestResultReadCycle
int earliestResultReadCycle() const
Definition: MoveNode.cc:652
MoveNode::cycle
int cycle() const
Definition: MoveNode.cc:421
MoveNode::guardLatency
int guardLatency() const
Definition: MoveNode.cc:779
MoveNode::addDestinationOperationPtr
void addDestinationOperationPtr(ProgramOperationPtr po)
Definition: MoveNode.cc:533
MoveNode::guardOp_
ProgramOperationPtr guardOp_
Definition: MoveNode.hh:164
MoveNode::latestTriggerWriteCycle
int latestTriggerWriteCycle() const
Definition: MoveNode.cc:698
MoveNode::isSourceOperation
bool isSourceOperation() const
Definition: MoveNode.cc:168
MoveNode::unsetSourceOperation
void unsetSourceOperation()
Definition: MoveNode.cc:760
TTAProgram::Move
Definition: Move.hh:55
MoveNode::cycle_
int cycle_
Cycle in which the node is placed. Each cycle uniquely identifies an instruction slot within the curr...
Definition: MoveNode.hh:168
MoveNode::unsetGuardOperation
void unsetGuardOperation()
Definition: MoveNode.cc:771
MoveNode::destinationOperationCount
unsigned int destinationOperationCount() const
MoveNode::dstOps_
std::vector< ProgramOperationPtr > dstOps_
Definition: MoveNode.hh:160
MoveNode::immediatePtr
std::shared_ptr< TTAProgram::Immediate > immediatePtr()
Definition: MoveNode.cc:846
MoveNode::move_
const std::shared_ptr< TTAProgram::Move > move_
Pointer to Move this node represents, Node itself do not change move.
Definition: MoveNode.hh:155
MoveNode::isSourceVariable
bool isSourceVariable() const
Definition: MoveNode.cc:196
MoveNode::destinationOperation
ProgramOperation & destinationOperation(unsigned int index=0) const
MoveNode::destinationOperationPtr
ProgramOperationPtr destinationOperationPtr(unsigned int index=0) const
MoveNode::move
TTAProgram::Move & move()
MoveNode::setCycle
void setCycle(const int newcycle)
Definition: MoveNode.cc:503
MoveNode::~MoveNode
virtual ~MoveNode()
Definition: MoveNode.cc:110
MoveNode::isInFrontier
bool isInFrontier() const
MoveNode::removeDestinationOperation
void removeDestinationOperation(const ProgramOperation *po)
Definition: MoveNode.cc:741
MoveNode::isRegisterMove
bool isRegisterMove() const
Definition: MoveNode.cc:294
MoveNode::inSameOperation
bool inSameOperation(const MoveNode &other) const
Definition: MoveNode.cc:306
MoveNode::setGuardOperationPtr
void setGuardOperationPtr(ProgramOperationPtr po)
Definition: MoveNode.cc:550
MoveNode::isOperationMove
bool isOperationMove() const
Definition: MoveNode.cc:253
MoveNode::sourceOperationPtr
ProgramOperationPtr sourceOperationPtr() const
Definition: MoveNode.cc:458
MoveNode::isScheduled
bool isScheduled() const
Definition: MoveNode.cc:409
GraphNode
Definition: GraphNode.hh:42
MoveNode::isAssigned
bool isAssigned() const
Definition: MoveNode.cc:367
MoveNode::setIsInFrontier
void setIsInFrontier(bool inFrontier=true)
MoveNode::immediate
TTAProgram::Immediate & immediate()
Definition: MoveNode.cc:838
MoveNode::copy
MoveNode * copy()
Definition: MoveNode.cc:135
MoveNode::immediate_
const std::shared_ptr< TTAProgram::Immediate > immediate_
Pointer to Immediate this node represents, Node itself do not change move.
Definition: MoveNode.hh:158
MoveNode::isInFrontier_
bool isInFrontier_
This is in scheduling frontier(used in Bubblefish scheduler)
Definition: MoveNode.hh:177
MoveNode::type
int type()
Definition: MoveNode.cc:563
MoveNode::guardOperation
ProgramOperation & guardOperation() const
Definition: MoveNode.cc:479