OpenASIP  2.0
TerminalInstructionReference.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 TerminalInstructionAddress.cc
26  *
27  * Implementation of TerminalInstructionAddress class.
28  *
29  * @author Ari Metsähalme 2005 (ari.metsahalme-no.spam-tut.fi)
30  * @author Pekka Jääskeläinen 2011
31  * @note rating: red
32  */
33 
35 #include "InstructionReference.hh"
36 #include "Instruction.hh"
38 #include "BasicBlock.hh"
39 
40 using namespace TTAMachine;
41 
42 namespace TTAProgram {
43 
44 /**
45  * The constructor.
46  *
47  * @param value The value of the inline immediate (the address).
48  * @param space The address space of the address the immediate refers to.
49  * @param ref The instruction this address refers to.
50  */
51 TerminalInstructionReference::TerminalInstructionReference(
53 }
54 
55 /**
56  * The destructor.
57  */
59 }
60 
61 /**
62  * Returns the value of the immediate (instruction address).
63  *
64  * @return The value of the immediate (instruction address).
65  */
66 Address
68  return ref_.instruction().address();
69 }
70 
71 /**
72  * Returns a reference to the instruction to which the immediate points.
73  *
74  * @return A reference to the instruction to which the immediate points.
75  * @exception WrongSubclass never.
76  */
79  return ref_;
80 }
81 
82 /**
83  * Returns a reference to the instruction to which the immediate points.
84  *
85  * @return A reference to the instruction to which the immediate points.
86  * @exception WrongSubclass never.
87  */
90  return ref_;
91 }
92 
93 /**
94  * Set a new referred instruction.
95  *
96  * @param ref The new instruction reference.
97  * @exception WrongSubclass never.
98  */
99 void
101  InstructionReference ref) {
102  ref_ = ref;
103 }
104 
105 /**
106  * Creates an exact copy of the terminal and returns it.
107  *
108  * @return A copy of the terminal.
109  */
110 Terminal*
113 }
114 
115 /**
116  * Checks if terminals are equal.
117  *
118  * @param other Terminal to compare.
119  * @return true if terminals are equal.
120  */
121 bool
123 
124  const TerminalBasicBlockReference* otherBBRef =
125  dynamic_cast<const TerminalBasicBlockReference*>(&other);
126  if (otherBBRef) {
127  const BasicBlock& bb = otherBBRef->basicBlock();
128  return &ref_.instruction() == &(bb.firstInstruction());
129  }
130 
131  const TerminalInstructionReference* otherInsRef =
132  dynamic_cast<const TerminalInstructionReference*>(&other);
133  if (otherInsRef) {
134  return otherInsRef->instructionReference() ==
135  ref_;
136  }
137  return false;
138 }
139 
140 }
TTAProgram::TerminalInstructionAddress
Definition: TerminalInstructionAddress.hh:45
TerminalInstructionReference.hh
TTAProgram
Definition: Estimator.hh:65
TTAProgram::InstructionReference::instruction
Instruction & instruction() const
Definition: InstructionReference.cc:138
TTAProgram::CodeSnippet::firstInstruction
virtual Instruction & firstInstruction() const
Definition: CodeSnippet.cc:216
TTAProgram::Address
Definition: Address.hh:51
TTAProgram::TerminalInstructionReference::~TerminalInstructionReference
virtual ~TerminalInstructionReference()
Definition: TerminalInstructionReference.cc:58
TTAProgram::TerminalInstructionReference::instructionReference
virtual const InstructionReference & instructionReference() const
Definition: TerminalInstructionReference.cc:78
TTAProgram::TerminalInstructionReference::equals
virtual bool equals(const Terminal &other) const
Definition: TerminalInstructionReference.cc:122
TerminalBasicBlockReference.hh
TTAProgram::TerminalInstructionReference::address
virtual Address address() const
Definition: TerminalInstructionReference.cc:67
TTAProgram::TerminalInstructionReference::setInstructionReference
virtual void setInstructionReference(InstructionReference ref)
Definition: TerminalInstructionReference.cc:100
Instruction.hh
TTAProgram::TerminalBasicBlockReference::basicBlock
virtual const BasicBlock & basicBlock() const
Definition: TerminalBasicBlockReference.hh:51
TTAProgram::TerminalInstructionReference::ref_
InstructionReference ref_
Referred instruction.
Definition: TerminalInstructionReference.hh:64
TTAProgram::TerminalInstructionReference::copy
virtual Terminal * copy() const
Definition: TerminalInstructionReference.cc:111
TTAProgram::TerminalInstructionReference
Definition: TerminalInstructionReference.hh:48
TTAProgram::TerminalBasicBlockReference
Definition: TerminalBasicBlockReference.hh:42
TTAProgram::BasicBlock
Definition: BasicBlock.hh:85
InstructionReference.hh
BasicBlock.hh
TTAProgram::Terminal
Definition: Terminal.hh:60
TTAProgram::TerminalInstructionReference::TerminalInstructionReference
TerminalInstructionReference(InstructionReference ref)
Definition: TerminalInstructionReference.cc:51
TTAMachine
Definition: Assembler.hh:48
TTAProgram::InstructionReference
Definition: InstructionReference.hh:49
TTAProgram::Instruction::address
Address address() const
Definition: Instruction.cc:327