OpenASIP  2.0
ExecutableInstruction.icc
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 ExecutableInstruction.icc
26  *
27  * Inline method definitions of ExecutableInstruction class.
28  *
29  * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include "ExecutableInstruction.hh"
34 #include "ExecutableMove.hh"
35 #include "LongImmUpdateAction.hh"
36 #include "SequenceTools.hh"
37 
38 /**
39  * Executes the instruction.
40  *
41  * First all long immediate update actions are executed.
42  * Next, guards are evaluated to decide which moves will be squashed and
43  * which not. Finally, data transports of the unsquashed moves are
44  * executed.
45  */
46 inline void
47 ExecutableInstruction::execute() {
48 
49  for (std::size_t i = 0; i < updateActions_.size(); ++i) {
50  updateActions_[i]->execute();
51  }
52  // have to evaluate the guards before either a long immediate
53  // or a register transport overwrites it
54  for (std::size_t i = 0; i < moves_.size(); ++i) {
55  moves_[i]->evaluateGuard();
56  }
57  for (std::size_t i = 0; i < moves_.size(); ++i) {
58  moves_[i]->executeRead();
59  }
60  for (std::size_t i = 0; i < moves_.size(); ++i) {
61  moves_[i]->executeWrite();
62  }
63  executionCount_++;
64 }
65 
66 /**
67  * Returns true in case the move with the given index was squashed the last
68  * time the instruction was executed.
69  *
70  * Being squashed means that the move is guarded and the guard expression
71  * evaluated to false.
72  *
73  * @param moveIndex Index of the move to query.
74  * @return True in case move was squashed.
75  */
76 inline bool
77 ExecutableInstruction::moveSquashed(std::size_t moveIndex) const {
78  return moves_[moveIndex]->squashed();
79 }
80 
81 /**
82  * Returns true in case this instruction is considered a program
83  * exit point: the simulation should stop *after* executing this instruction.
84  */
85 inline bool
86 ExecutableInstruction::isExitPoint() const {
87  return exitPoint_;
88 }
89 
90 /**
91  * Sets the instruction's exit point status.
92  *
93  * @see isExitPoint()
94  */
95 inline void
96 ExecutableInstruction::setExitPoint(bool b) {
97  exitPoint_ = b;
98 }