OpenASIP  2.0
InstructionTemplate.hh
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 InstructionTemplate.hh
26  *
27  * Declaration of class InstructionTemplate.
28  *
29  * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #ifndef TTA_INSTRUCTION_TEMPLATE_HH
34 #define TTA_INSTRUCTION_TEMPLATE_HH
35 
36 #include <string>
37 #include <vector>
38 
39 #include "MachinePart.hh"
40 #include "Exception.hh"
41 
42 namespace TTAMachine {
43 
44 class Bus;
45 class Machine;
46 class ImmediateUnit;
47 class TemplateSlot;
48 
50 public:
51  InstructionTemplate(const std::string& name, Machine& owner);
52  InstructionTemplate(const ObjectState* state, Machine& owner);
53  virtual ~InstructionTemplate();
54 
55  virtual void setName(const std::string& name);
56  virtual void addSlot(
57  const std::string& slotName, int width, ImmediateUnit& dstUnit);
58 
59  virtual void removeSlot(const std::string& slotName);
60  virtual void removeSlots(const ImmediateUnit& dstUnit);
61 
62  virtual int slotCount() const;
63  virtual TemplateSlot* slot(int index) const;
64  TemplateSlot* templateSlot(const std::string& slotName) const;
65 
66  virtual bool usesSlot(const std::string& slotName) const;
67  virtual bool destinationUsesSlot(
68  const std::string& slotName, const ImmediateUnit& dstUnit) const;
69  virtual int numberOfDestinations() const;
70  virtual bool isOneOfDestinations(const ImmediateUnit& dstUnit) const;
71  virtual ImmediateUnit* destinationOfSlot(const std::string& slotName) const;
72 
73  virtual int numberOfSlots(const ImmediateUnit& dstUnit) const;
74  virtual std::string slotOfDestination(
75  const ImmediateUnit& dstUnit, int index) const;
76 
77  virtual int supportedWidth() const;
78  virtual int supportedWidth(const ImmediateUnit& dstUnit) const;
79  virtual int supportedWidth(const std::string& slotName) const;
80 
81  virtual bool isEmpty() const;
82 
83  virtual void setMachine(Machine& machine);
84  virtual void unsetMachine();
85 
86  virtual ObjectState* saveState() const;
87  virtual void loadState(const ObjectState* state);
88 
89  /// ObjectState name for instruction template.
90  static const std::string OSNAME_INSTRUCTION_TEMPLATE;
91 
92 private:
93  /// Container for TemplateSlots.
94  typedef std::vector<TemplateSlot*> SlotTable;
95 
96  void deleteAllSlots();
97  /// Contains all the slots of the instruction template.
99 };
100 }
101 
102 #endif
TTAMachine::InstructionTemplate::slotOfDestination
virtual std::string slotOfDestination(const ImmediateUnit &dstUnit, int index) const
Definition: InstructionTemplate.cc:395
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
Exception.hh
TTAMachine::InstructionTemplate::loadState
virtual void loadState(const ObjectState *state)
Definition: InstructionTemplate.cc:558
TTAMachine::InstructionTemplate::templateSlot
TemplateSlot * templateSlot(const std::string &slotName) const
Definition: InstructionTemplate.cc:630
TTAMachine::InstructionTemplate::addSlot
virtual void addSlot(const std::string &slotName, int width, ImmediateUnit &dstUnit)
Definition: InstructionTemplate.cc:169
TTAMachine::InstructionTemplate::numberOfDestinations
virtual int numberOfDestinations() const
Definition: InstructionTemplate.cc:300
ObjectState
Definition: ObjectState.hh:59
TTAMachine::InstructionTemplate::unsetMachine
virtual void unsetMachine()
Definition: InstructionTemplate.cc:521
TTAMachine::InstructionTemplate::slotCount
virtual int slotCount() const
Definition: InstructionTemplate.cc:236
TTAMachine::InstructionTemplate::SlotTable
std::vector< TemplateSlot * > SlotTable
Container for TemplateSlots.
Definition: InstructionTemplate.hh:94
TTAMachine::InstructionTemplate::deleteAllSlots
void deleteAllSlots()
Definition: InstructionTemplate.cc:616
MachinePart.hh
TTAMachine::InstructionTemplate::InstructionTemplate
InstructionTemplate(const std::string &name, Machine &owner)
Definition: InstructionTemplate.cc:69
TTAMachine::InstructionTemplate::setMachine
virtual void setMachine(Machine &machine)
Definition: InstructionTemplate.cc:509
TTAMachine::InstructionTemplate
Definition: InstructionTemplate.hh:49
TTAMachine::InstructionTemplate::saveState
virtual ObjectState * saveState() const
Definition: InstructionTemplate.cc:536
TTAMachine::InstructionTemplate::setName
virtual void setName(const std::string &name)
Definition: InstructionTemplate.cc:134
TTAMachine::InstructionTemplate::numberOfSlots
virtual int numberOfSlots(const ImmediateUnit &dstUnit) const
Definition: InstructionTemplate.cc:367
TTAMachine::TemplateSlot
Definition: TemplateSlot.hh:55
TTAMachine::InstructionTemplate::~InstructionTemplate
virtual ~InstructionTemplate()
Definition: InstructionTemplate.cc:119
TTAMachine::Component
Definition: MachinePart.hh:90
TTAMachine::InstructionTemplate::supportedWidth
virtual int supportedWidth() const
Definition: InstructionTemplate.cc:427
TTAMachine::InstructionTemplate::removeSlots
virtual void removeSlots(const ImmediateUnit &dstUnit)
Definition: InstructionTemplate.cc:217
TTAMachine::InstructionTemplate::isOneOfDestinations
virtual bool isOneOfDestinations(const ImmediateUnit &dstUnit) const
Definition: InstructionTemplate.cc:323
TTAMachine::Component::machine
virtual Machine * machine() const
TTAMachine::InstructionTemplate::isEmpty
virtual bool isEmpty() const
Definition: InstructionTemplate.cc:494
TTAMachine::InstructionTemplate::destinationUsesSlot
virtual bool destinationUsesSlot(const std::string &slotName, const ImmediateUnit &dstUnit) const
Definition: InstructionTemplate.cc:280
TTAMachine
Definition: Assembler.hh:48
TTAMachine::InstructionTemplate::removeSlot
virtual void removeSlot(const std::string &slotName)
Definition: InstructionTemplate.cc:201
TTAMachine::InstructionTemplate::slot
virtual TemplateSlot * slot(int index) const
Definition: InstructionTemplate.cc:249
TTAMachine::InstructionTemplate::slots_
SlotTable slots_
Contains all the slots of the instruction template.
Definition: InstructionTemplate.hh:98
TTAMachine::InstructionTemplate::usesSlot
virtual bool usesSlot(const std::string &slotName) const
Definition: InstructionTemplate.cc:265
TTAMachine::InstructionTemplate::OSNAME_INSTRUCTION_TEMPLATE
static const std::string OSNAME_INSTRUCTION_TEMPLATE
ObjectState name for instruction template.
Definition: InstructionTemplate.hh:90
TTAMachine::Machine
Definition: Machine.hh:73
TTAMachine::InstructionTemplate::destinationOfSlot
virtual ImmediateUnit * destinationOfSlot(const std::string &slotName) const
Definition: InstructionTemplate.cc:346
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50