OpenASIP 2.2
Loading...
Searching...
No Matches
Terminal.cc
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 Terminal.cc
26 *
27 * Implementation of Terminal class.
28 *
29 * @author Ari Metsähalme 2005 (ari.metsahalme-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include "Exception.hh"
34#include "Terminal.hh"
36
37using namespace TTAMachine;
38
39namespace TTAProgram {
40
41/////////////////////////////////////////////////////////////////////////////
42// Terminal
43/////////////////////////////////////////////////////////////////////////////
44
45/**
46 * The constructor.
47 */
50
51/**
52 * The destructor.
53 */
56
57/**
58 * Tells whether the terminal is an inline immediate value.
59 *
60 * @return True if the terminal is an inline immediate value.
61 */
62bool
64 return false;
65}
66
67/**
68 * Tells whether the terminal is an inline immediate value that refers
69 * to an address.
70 *
71 * @return True if the terminal is an inline immediate value that refers
72 * to an address.
73 */
74bool
76 return false;
77}
78
79/**
80 * Tells whether the terminal is an inline immediate value that refers
81 * to an instruction address.
82 *
83 * @return True if the terminal is an inline immediate value that refers
84 * to an instruction address.
85 */
86bool
88 return false;
89}
90
91/**
92 * Tells whether the terminal is a long immediate register.
93 *
94 * @return True if the terminal is a long immediate register.
95 */
96bool
98 return false;
99}
100
101/**
102 * Tells whether the terminal is a general-purpose register.
103 *
104 * @return True if the terminal is a general-purpose register.
105 */
106bool
108 return false;
109}
110
111/**
112 * Tells whether the terminal is a function unit port (possibly,
113 * including an operation code).
114 *
115 * @return True if the terminal is a function unit port.
116 */
117bool
119 return false;
120}
121
122/**
123 * Tells whether the terminal is a the return address port
124 * in gcu.
125 *
126 * @return True if the terminal is a the RA port.
127 */
128bool
130 return false;
131}
132
133/**
134 * Tells whether the terminal is reference to a basic block.
135 *
136 * @return True if the terminal is a ref to a basic block
137 */
138bool
140 return false;
141}
142
143bool
145 return false;
146}
147
148/**
149 * Tells whether the terminal is reference to a code symbol
150 *
151 * @return True if the terminal is a ref to a code symbol
152 */
153bool
155 return false;
156}
157
158/**
159 * Tells whether the terminal is a reg in UniversalMachine
160 *
161 * @return True if the terminal is a register in universalmachine,
162 * ie. not in any real machine. This practically means the
163 * register is unallocated and meant to be bypassed.
164 */
165bool
167 return false;
168}
169
170/**
171 * Returns the value of the inline immediate.
172 *
173 * @return The value of the inline immediate.
174 * @exception WrongSubclass if the terminal is not an instance of
175 * TerminalImmediate.
176 */
179 throw WrongSubclass(__FILE__, __LINE__);
180}
181
182/**
183 * Returns a reference to the instruction to which the immediate points.
184 *
185 * @return A reference to the instruction to which the immediate points.
186 */
189 throw WrongSubclass(__FILE__, __LINE__);
190}
191
192/**
193 * Returns a reference to the instruction to which the immediate points.
194 *
195 * @return A reference to the instruction to which the immediate points.
196 */
199 throw WrongSubclass(__FILE__, __LINE__);
200}
201
202/**
203 * Returns the address held by this terminal.
204 *
205 * @return A memory address.
206 * @exception WrongSubclass if the terminal is not an instance of
207 * TerminalAddress.
208 */
211 throw WrongSubclass(__FILE__, __LINE__);
212}
213
214/**
215 * Returns the register file of the general-purpose register.
216 *
217 * Applicable only if the unit of the terminal is an instance of
218 * RegisterFile.
219 *
220 * @return The register file of the general-purpose register.
221 * @exception WrongSubclass if the unit of the terminal is not an instance
222 * of RegisterFile.
223 */
224const RegisterFile&
226 throw WrongSubclass(__FILE__, __LINE__);
227}
228
229/**
230 * Returns the immediate unit of the long immediate register.
231 *
232 * Applicable only if the unit of the terminal is an instance of
233 * ImmediateUnit.
234 *
235 * @return The immediate unit of the long immediate register.
236 * @exception WrongSubclass if the unit of the terminal is not an instance
237 * of ImmediateUnit.
238 */
239const ImmediateUnit&
241 throw WrongSubclass(__FILE__, __LINE__);
242}
243
244/**
245 * Returns the function unit of the port.
246 *
247 * @exception WrongSubclass if the terminal is not an instance of
248 * TerminalFUPort.
249 */
250const FunctionUnit&
252 throw WrongSubclass(__FILE__, __LINE__);
253}
254
255/**
256 * Returns a reference to the basic block to which the immediate points.
257 *
258 * @return A reference to the basic block to which the immediate points.
259 */
260const BasicBlock&
262 throw WrongSubclass(__FILE__, __LINE__);
263}
264
265/**
266 * Return the index of the register (either a long immediate or a
267 * general-purpose register).
268 *
269 * @return The index of the register.
270 * @exception WrongSubclass if the terminal is not an instance of
271 * TerminalRegister.
272 */
273int
275 throw WrongSubclass(__FILE__, __LINE__);
276}
277
278/**
279 * Tells whether terminal transports an opcode to a function unit port.
280 *
281 * @return True if the terminal transports an opcode to a function unit port.
282 * @exception WrongSubclass always.
283*/
284bool
286 throw WrongSubclass(
287 __FILE__, __LINE__, __func__,
288 "Terminal must be TerminalFUPort for this method.");
289}
290
291/**
292 * Tells whether terminal is a triggering FU port.
293 *
294 * @return True if the terminal is a triggering port.
295 * @exception WrongSubclass always.
296*/
297bool
299 throw WrongSubclass(
300 __FILE__, __LINE__, __func__,
301 "Terminal must be TerminalFUPort for this method.");
302}
303
304/**
305 * Return the operation code transported into the function unit port by this
306 * terminal.
307 *
308 * Throws an error condition if the terminal does not read from or write to
309 * a function unit port (that is, if the terminal if of a wrong type).
310 * Throws an error condition also if the terminal does not access an
311 * opcode-setting function unit port.
312 *
313 * @exception WrongSubclass If the terminal is of the wrong type.
314 * @exception InvalidData If the terminal is of the right type, but it does
315 * not carry an operation-code.
316 * @return The operation carried by this terminal.
317 */
320 throw WrongSubclass(
321 __FILE__, __LINE__, __func__,
322 "Terminal must be TerminalFUPort for this method.");
323}
324
325/**
326 * Return the operation to which this terminal was originally bound.
327 *
328 * NOTE! : Method must not be used for checkin if terminal contains
329 * opcode. See. operation().
330 *
331 * Method is mainly used for preserving information to which operation
332 * port reference is bound, during TPEF -> POM -> TPEF write cycles.
333 *
334 * @return The operation code to which terminal was originally bound.
335 * Null operation if terminal does not contain operation code.
336 *
337 * @todo This should be probably merged with operation() as "hints" are
338 * not really useful, we should make sure the operation of the move is known.
339 */
342 throw WrongSubclass(
343 __FILE__, __LINE__, __func__,
344 "Terminal must be TerminalFUPort for this method.");
345}
346
347/**
348 * Return the index that identifies the operation input or output that
349 * is represented by this terminal.
350 *
351 * Throws an error condition if the terminal does not read from or write to
352 * a function unit port (that is, if the terminal if of a wrong type).
353 * Throws an error condition also if the terminal does not access an
354 * opcode-setting function unit port, nor it bears auxiliary "hint
355 * operation" information.
356 *
357 * @return The index that identifies the operation input or output that
358 * is represented by this terminal.
359 * @exception WrongSubclass If the terminal is of the wrong type.
360 * @exception InvalidData If the terminal is of the right type, but does
361 * not have any operation-related information.
362 */
363int
365 throw WrongSubclass(
366 __FILE__, __LINE__, __func__,
367 "Terminal must be TerminalFUPort for this method.");
368}
369
370/**
371 * Return the port accessed by this terminal.
372 *
373 * @return The port of the unit of the terminal.
374 * @exception WrongSubclass if the terminal is not an instance of
375 * TerminalFUPort or TerminalRegister.
376 */
377const Port&
379 throw WrongSubclass(__FILE__, __LINE__);
380}
381
382/**
383 * Change the register of the register file to the given index.
384 *
385 * @param index The new register index.
386 * @exception OutOfRange if index is not smaller than the size of the
387 * register file or immediate unit it belongs to.
388 * @exception WrongSubclass if the terminal is not an instance of
389 * TerminalRegister.
390 */
391void
393 throw WrongSubclass(__FILE__, __LINE__);
394}
395
396/**
397 * Set a new referred instruction.
398 *
399 * @param ref The new instruction reference.
400 * @exception WrongSubclass if the terminal is not an instance of
401 * TerminalInstructionAddress
402 */
403void
407
408/**
409 * Comparison operator for Terminals.
410 *
411 * Delegates the comparison to dynamically bound equals() method.
412 *
413 * @param other Comparison target.
414 * @return True in case the objects are equal.
415 */
416bool
417Terminal::operator==(const Terminal& other) const {
418 return equals(other);
419}
420
421}
#define __func__
virtual SimValue value() const
Definition Terminal.cc:178
virtual bool isAddress() const
Definition Terminal.cc:75
virtual bool isRA() const
Definition Terminal.cc:129
virtual bool isTriggering() const
Definition Terminal.cc:298
virtual Operation & hintOperation() const
Definition Terminal.cc:341
virtual bool isBasicBlockReference() const
Definition Terminal.cc:139
virtual bool isCodeSymbolReference() const
Definition Terminal.cc:154
virtual const TTAMachine::FunctionUnit & functionUnit() const
Definition Terminal.cc:251
virtual int index() const
Definition Terminal.cc:274
virtual void setIndex(int index)
Definition Terminal.cc:392
virtual Address address() const
Definition Terminal.cc:210
virtual bool isOpcodeSetting() const
Definition Terminal.cc:285
virtual Operation & operation() const
Definition Terminal.cc:319
virtual bool equals(const Terminal &other) const =0
virtual const BasicBlock & basicBlock() const
Definition Terminal.cc:261
virtual const InstructionReference & instructionReference() const
Definition Terminal.cc:188
virtual void setInstructionReference(InstructionReference ref)
Definition Terminal.cc:404
virtual bool isProgramOperationReference() const
Definition Terminal.cc:144
bool operator==(const Terminal &other) const
Definition Terminal.cc:417
virtual bool isGPR() const
Definition Terminal.cc:107
virtual int operationIndex() const
Definition Terminal.cc:364
virtual bool isInstructionAddress() const
Definition Terminal.cc:87
virtual ~Terminal()
Definition Terminal.cc:54
virtual bool isImmediateRegister() const
Definition Terminal.cc:97
virtual bool isUniversalMachineRegister() const
Definition Terminal.cc:166
virtual const TTAMachine::Port & port() const
Definition Terminal.cc:378
virtual bool isImmediate() const
Definition Terminal.cc:63
virtual const TTAMachine::ImmediateUnit & immediateUnit() const
Definition Terminal.cc:240
virtual const TTAMachine::RegisterFile & registerFile() const
Definition Terminal.cc:225
virtual bool isFUPort() const
Definition Terminal.cc:118