OpenASIP  2.0
TerminalProgramOperation.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2011 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 TerminalProgramOperation.cc
26  *
27  * Implementation of the TerminalProgramOperation class.
28  *
29  * @author Pekka Jääskeläinen 2011
30  * @note rating: red
31  */
32 
34 #include "Instruction.hh"
35 #include "ProgramOperation.hh"
36 #include "MoveNode.hh"
37 #include "Move.hh"
38 
39 using namespace TTAMachine;
40 
41 namespace TTAProgram {
42 
43 /**
44  * The constructor.
45  *
46  * @param po The ProgramOperation to track.
47  */
48 TerminalProgramOperation::TerminalProgramOperation(
49  std::shared_ptr<ProgramOperation> po) :
50  TerminalInstructionAddress(), po_(po) {
51 }
52 
53 /**
54  * Constructs an incomplete TerminalProgramOperation.
55  *
56  * This can be used when a TerminalProgramOperation might point to
57  * an non-existing PO during builing of the program.
58  *
59  * @param label A textual label of the target PO. Should be used later
60  * to find the correct PO.
61  */
63  TCEString label) :
64  TerminalInstructionAddress(), label_(label) {
65 }
66 
67 
68 /**
69  * The destructor.
70  */
72 }
73 
74 /**
75  * Returns the instruction address of the trigger move in the tracked
76  * ProgramOperation.
77  *
78  * Returns 0 in case the target PO is not in a program, thus its address
79  * is not known.
80  */
81 Address
84  return po_->triggeringMove()->move().parent().address();
85 }
86 
87 bool
89  return isProgramOperationKnown() &&
90  po_->triggeringMove() != NULL &&
91  po_->triggeringMove()->move().isInInstruction() &&
92  po_->triggeringMove()->move().parent().isInProcedure();
93 }
94 
95 /**
96  * Creates an exact copy of the terminal and returns it.
97  */
98 Terminal*
101  newObj->label_ = this->label_;
102  return newObj;
103 }
104 
105 /**
106  * Checks if terminals are equal.
107  */
108 bool
110 
111  if (!other.isInstructionAddress()) {
112  return false;
113  }
114  return &dynamic_cast<const TerminalProgramOperation&>(other).po_ ==
115  &this->po_;
116 }
117 
118 }
TTAProgram::TerminalInstructionAddress
Definition: TerminalInstructionAddress.hh:45
TTAProgram
Definition: Estimator.hh:65
TTAProgram::TerminalProgramOperation::label_
TCEString label_
Definition: TerminalProgramOperation.hh:84
TTAProgram::TerminalProgramOperation::po_
ProgramOperationPtr po_
The referred PO. The pointer can be copied, e.g. to DDG.
Definition: TerminalProgramOperation.hh:83
TTAProgram::Terminal::isInstructionAddress
virtual bool isInstructionAddress() const
Definition: Terminal.cc:87
TTAProgram::Address
Definition: Address.hh:51
TTAProgram::TerminalProgramOperation::copy
virtual Terminal * copy() const
Definition: TerminalProgramOperation.cc:99
TTAProgram::TerminalProgramOperation::address
virtual Address address() const
Definition: TerminalProgramOperation.cc:82
TTAProgram::TerminalProgramOperation::isProgramOperationKnown
bool isProgramOperationKnown() const
Definition: TerminalProgramOperation.hh:65
TTAProgram::TerminalProgramOperation::~TerminalProgramOperation
virtual ~TerminalProgramOperation()
Definition: TerminalProgramOperation.cc:71
assert
#define assert(condition)
Definition: Application.hh:86
TTAProgram::TerminalProgramOperation::isAddressKnown
bool isAddressKnown() const
Definition: TerminalProgramOperation.cc:88
Instruction.hh
TTAProgram::TerminalProgramOperation::equals
virtual bool equals(const Terminal &other) const
Definition: TerminalProgramOperation.cc:109
ProgramOperation.hh
TerminalProgramOperation.hh
TCEString
Definition: TCEString.hh:53
TTAProgram::Terminal
Definition: Terminal.hh:60
TTAProgram::TerminalProgramOperation::TerminalProgramOperation
TerminalProgramOperation(TCEString instructionLabel)
Definition: TerminalProgramOperation.cc:62
Move.hh
TTAMachine
Definition: Assembler.hh:48
MoveNode.hh
TTAProgram::TerminalProgramOperation
Definition: TerminalProgramOperation.hh:51