OpenASIP  2.0
NullInstructionTemplate.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 NullInstructionTemplate.cc
26  *
27  * Implementation of NullInstructionTemplate class.
28  *
29  * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: yellow
31  */
32 
34 #include "Machine.hh"
35 
36 namespace TTAMachine {
37 
39 NullInstructionTemplate NullInstructionTemplate::instance_;
40 
41 /**
42  * The constructor.
43  */
45  InstructionTemplate("NULL", machine_) {
46 }
47 
48 
49 /**
50  * The destructor.
51  */
53 }
54 
55 
56 /**
57  * Returns the only instance of NullInstructionTemplate.
58  *
59  * @return The only instance of NullInstructionTemplate.
60  */
63  return instance_;
64 }
65 
66 
67 /**
68  * Aborts the program with error message.
69  *
70  * @return Never returns.
71  */
74  abortWithError("name()");
75  return "";
76 }
77 
78 
79 /**
80  * Aborts the program with error message.
81  *
82  * @exception ComponentAlreadyExists Never thrown.
83  * @exception InvalidName Never thrown.
84  */
85 void
86 NullInstructionTemplate::setName(const std::string&) {
87  abortWithError("setName()");
88 }
89 
90 /**
91  * Aborts the program with error message.
92  *
93  * @exception InstanceNotFound Never thrown.
94  * @exception ComponentAlreadyExists Never thrown.
95  * @exception OutOfRange Never thrown.
96  */
97 void
98 NullInstructionTemplate::addSlot(const std::string&, int, ImmediateUnit&) {
99  abortWithError("addSlot()");
100 }
101 
102 /**
103  * Aborts the program with error message.
104  */
105 void
107  abortWithError("removeSlot()");
108 }
109 
110 
111 /**
112  * Aborts the program with error message.
113  *
114  * @return Never returns.
115  */
116 void
118  abortWithError("removeSlots()");
119 }
120 
121 /**
122  * Aborts the program with error message.
123  *
124  * @return Never returns.
125  */
126 int
128  abortWithError("slotCount()");
129  return -1;
130 }
131 
132 /**
133  * Aborts the program with error message.
134  *
135  * @return Never returns.
136  */
139  abortWithError("slot()");
140  return NULL;
141 }
142 
143 
144 /**
145  * Aborts the program with error message.
146  *
147  * @return Never returns.
148  */
149 bool
150 NullInstructionTemplate::usesSlot(const std::string&) const {
151  abortWithError("usesSlot()");
152  return false;
153 }
154 
155 
156 /**
157  * Aborts the program with error message.
158  *
159  * @return Never returns.
160  */
161 bool
163  const std::string&,
164  const ImmediateUnit&) const {
165 
166  abortWithError("destinationUsesSlot()");
167  return false;
168 }
169 
170 
171 /**
172  * Aborts the program with error message.
173  *
174  * @return Never returns.
175  */
176 int
178  abortWithError("numberOfDestinations()");
179  return 0;
180 }
181 
182 
183 /**
184  * Aborts the program with error message.
185  *
186  * @return Never returns.
187  */
188 bool
190  abortWithError("isOneOfDestinations()");
191  return false;
192 }
193 
194 
195 /**
196  * Aborts the program with error message.
197  *
198  * @return Never returns.
199  */
202  abortWithError("destinationOfSlot()");
203  return NULL;
204 }
205 
206 /**
207  * Aborts the program with error message.
208  *
209  * @return Never returns.
210  */
211 int
213  abortWithError("numberOfSlots()");
214  return 0;
215 }
216 
217 
218 /**
219  * Aborts the program with error message.
220  *
221  * @return Never returns.
222  */
223 std::string
225  abortWithError("slotOfDestination()");
226  return NULL;
227 }
228 
229 /**
230  * Aborts the program with error message.
231  *
232  * @return Never returns.
233  */
234 int
236  abortWithError("supportedWidth()");
237  return 0;
238 }
239 
240 
241 /**
242  * Aborts the program with error message.
243  *
244  * @return Never returns.
245  */
246 int
248  abortWithError("supportedWidth()");
249  return 0;
250 }
251 
252 
253 /**
254  * Aborts the program with error message.
255  *
256  * @return Never returns.
257  */
258 int
259 NullInstructionTemplate::supportedWidth(const std::string&) const {
260  abortWithError("supportedWidth()");
261  return 0;
262 }
263 
264 
265 /**
266  * Aborts the program with error message.
267  *
268  * @return Never returns.
269  */
270 bool
272  abortWithError("isEmpty()");
273  return false;
274 }
275 
276 
277 /**
278  * Aborts the program with error message.
279  *
280  * @exception ComponentAlreadyExists Never thrown.
281  */
282 void
284  abortWithError("setMachine()");
285 }
286 
287 /**
288  * Aborts the program with error message.
289  */
290 void
292  abortWithError("unsetMachine()");
293 }
294 
295 
296 /**
297  * Aborts the program with error message.
298  *
299  * @return Never returns.
300  */
301 Machine*
303  abortWithError("machine()");
304  return NULL;
305 }
306 
307 
308 /**
309  * Aborts the program with error message.
310  *
311  * @exception IllegalRegistration Never thrown.
312  */
313 void
315  abortWithError("ensureRegistration()");
316 }
317 
318 /**
319  * Aborts the program with error message.
320  *
321  * @return Never returns.
322  */
323 bool
325  abortWithError("isRegistered()");
326  return false;
327 }
328 
329 /**
330  * Aborts the program with error message.
331  *
332  * @return Never returns.
333  */
336  abortWithError("saveState()");
337  return NULL;
338 }
339 
340 
341 /**
342  * Aborts the program with error message.
343  *
344  * @exception ObjectStateLoadingException Never thrown.
345  */
346 void
348  abortWithError("loadState()");
349 }
350 }
TTAMachine::NullInstructionTemplate::saveState
virtual ObjectState * saveState() const
Definition: NullInstructionTemplate.cc:335
TTAMachine::NullInstructionTemplate
Definition: NullInstructionTemplate.hh:45
TTAMachine::NullInstructionTemplate::loadState
virtual void loadState(const ObjectState *state)
Definition: NullInstructionTemplate.cc:347
TTAMachine::NullInstructionTemplate::isEmpty
virtual bool isEmpty() const
Definition: NullInstructionTemplate.cc:271
ObjectState
Definition: ObjectState.hh:59
TTAMachine::NullInstructionTemplate::ensureRegistration
virtual void ensureRegistration(const Component &component) const
Definition: NullInstructionTemplate.cc:314
TTAMachine::NullInstructionTemplate::instance_
static NullInstructionTemplate instance_
The only instance of NullInstructionTemplate.
Definition: NullInstructionTemplate.hh:93
TTAMachine::NullInstructionTemplate::addSlot
virtual void addSlot(const std::string &slotName, int width, ImmediateUnit &dstUnit)
Definition: NullInstructionTemplate.cc:98
TTAMachine::InstructionTemplate
Definition: InstructionTemplate.hh:49
TTAMachine::NullInstructionTemplate::NullInstructionTemplate
NullInstructionTemplate()
Definition: NullInstructionTemplate.cc:44
TTAMachine::NullInstructionTemplate::removeSlot
virtual void removeSlot(const std::string &slotName)
Definition: NullInstructionTemplate.cc:106
TTAMachine::NullInstructionTemplate::numberOfSlots
virtual int numberOfSlots(const ImmediateUnit &dstUnit) const
Definition: NullInstructionTemplate.cc:212
TTAMachine::NullInstructionTemplate::slotCount
virtual int slotCount() const
Definition: NullInstructionTemplate.cc:127
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
TTAMachine::NullInstructionTemplate::unsetMachine
virtual void unsetMachine()
Definition: NullInstructionTemplate.cc:291
TTAMachine::TemplateSlot
Definition: TemplateSlot.hh:55
TTAMachine::NullInstructionTemplate::removeSlots
virtual void removeSlots(const ImmediateUnit &dstUnit)
Definition: NullInstructionTemplate.cc:117
TTAMachine::Component
Definition: MachinePart.hh:90
TTAMachine::NullInstructionTemplate::supportedWidth
virtual int supportedWidth() const
Definition: NullInstructionTemplate.cc:235
NullInstructionTemplate.hh
Machine.hh
TTAMachine::NullInstructionTemplate::isRegistered
virtual bool isRegistered() const
Definition: NullInstructionTemplate.cc:324
TTAMachine::NullInstructionTemplate::destinationUsesSlot
virtual bool destinationUsesSlot(const std::string &slotName, const ImmediateUnit &dstUnit) const
Definition: NullInstructionTemplate.cc:162
TTAMachine::NullInstructionTemplate::slot
virtual TemplateSlot * slot(int index) const
Definition: NullInstructionTemplate.cc:138
TTAMachine::NullInstructionTemplate::destinationOfSlot
virtual ImmediateUnit * destinationOfSlot(const std::string &slotName) const
Definition: NullInstructionTemplate.cc:201
TTAMachine::NullInstructionTemplate::machine_
static Machine machine_
Machine to which the null instruction template is registered.
Definition: NullInstructionTemplate.hh:95
TTAMachine::NullInstructionTemplate::instance
static NullInstructionTemplate & instance()
Definition: NullInstructionTemplate.cc:62
TTAMachine::NullInstructionTemplate::usesSlot
virtual bool usesSlot(const std::string &slotName) const
Definition: NullInstructionTemplate.cc:150
TTAMachine::NullInstructionTemplate::isOneOfDestinations
virtual bool isOneOfDestinations(const ImmediateUnit &dstUnit) const
Definition: NullInstructionTemplate.cc:189
TCEString
Definition: TCEString.hh:53
TTAMachine::NullInstructionTemplate::numberOfDestinations
virtual int numberOfDestinations() const
Definition: NullInstructionTemplate.cc:177
TTAMachine::NullInstructionTemplate::slotOfDestination
virtual std::string slotOfDestination(const ImmediateUnit &dstUnit, int index) const
Definition: NullInstructionTemplate.cc:224
TTAMachine::NullInstructionTemplate::setMachine
virtual void setMachine(Machine &machine)
Definition: NullInstructionTemplate.cc:283
TTAMachine
Definition: Assembler.hh:48
TTAMachine::NullInstructionTemplate::name
virtual TCEString name() const
Definition: NullInstructionTemplate.cc:73
TTAMachine::NullInstructionTemplate::machine
virtual Machine * machine() const
Definition: NullInstructionTemplate.cc:302
TTAMachine::NullInstructionTemplate::~NullInstructionTemplate
virtual ~NullInstructionTemplate()
Definition: NullInstructionTemplate.cc:52
TTAMachine::NullInstructionTemplate::setName
virtual void setName(const std::string &name)
Definition: NullInstructionTemplate.cc:86
TTAMachine::Machine
Definition: Machine.hh:73
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50