2 Copyright (c) 2002-2009 Tampere University.
4 This file is part of TTA-Based Codesign Environment (TCE).
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:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
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.
27 * Inline method implementation of MoveNode class.
29 * Nodes 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.
34 * @author Heikki Kultala 2009 (hkultala-no.spam-cs.tut.fi)
38 #include "Conversion.hh"
41 * Tells whether the destination of the node (move) belongs to an operation.
43 * @return True if the destination of the node is an operation input.
46 MoveNode::isDestinationOperation() const {
50 return dstOps_.size() != 0;
54 * Tells how many operations this movenode is an operand to(operand sharing)
58 MoveNode::destinationOperationCount() const {
62 return dstOps_.size();
66 * Access Move inside MoveNode, casting constantness away
68 * @return reference to Move inside MoveNode
70 inline TTAProgram::Move&
73 throw NotAvailable(__FILE__,__LINE__,__func__,
74 "Move of MoveNode is NULL");
76 return const_cast<TTAProgram::Move&> (*move_);
80 * Access Move inside MoveNode, const version.
82 * @return reference to Move inside MoveNode
84 inline const TTAProgram::Move&
85 MoveNode::move() const {
87 throw NotAvailable(__FILE__,__LINE__,__func__,
88 "Move of MoveNode is NULL");
94 * Access Move inside MoveNode, casting constantness away
96 * @return reference to Move inside MoveNode
98 inline std::shared_ptr<TTAProgram::Move>
101 throw NotAvailable(__FILE__,__LINE__,__func__,
102 "Move of MoveNode is NULL");
108 * Access Move inside MoveNode, const version.
110 * @return reference to Move inside MoveNode
112 inline std::shared_ptr<const TTAProgram::Move>
113 MoveNode::movePtr() const {
115 throw NotAvailable(__FILE__,__LINE__,__func__,
116 "Move of MoveNode is NULL");
122 * Returns true if it's a real move, not a pseudo move such as entry node.
125 MoveNode::isMove() const {
126 return move_ != NULL;
130 * Returns the instance of operation in the program whose input is the
131 * destination of this node.
133 * @return A program operation.
134 * @exception InvalidData if the given node does not write an operation
137 inline ProgramOperation&
138 MoveNode::destinationOperation(unsigned int index) const {
139 return *dstOps_[index].get();
142 inline ProgramOperationPtr
143 MoveNode::destinationOperationPtr(unsigned int index) const {
144 if (!isDestinationOperation()){
145 std::string msg = "MoveNode destination is not Operation.";
146 throw InvalidData(__FILE__, __LINE__, __func__, msg);
148 if (index >= dstOps_.size()) {
150 "MoveNode does not have dst Operation of index" +
151 Conversion::toString(index);
152 throw InvalidData(__FILE__, __LINE__, __func__, msg);
154 return dstOps_[index];
159 MoveNode::isFinalized() const {
164 MoveNode::finalize() {
169 MoveNode::isInFrontier() const {
170 return isInFrontier_;
174 MoveNode::setIsInFrontier(bool isInFrontier) {
175 isInFrontier_ = isInFrontier;