OpenASIP  2.0
SimpleResourceManager.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 SimpleResourceManager.hh
26  *
27  * Declaration of SimpleResourceManager class.
28  *
29  * @author Ari Mets�halme 2006 (ari.metsahalme-no.spam-tut.fi)
30  * @author Vladimir Guzma 2007 (vladimir.guzma-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_SIMPLE_RESOURCE_MANAGER_HH
35 #define TTA_SIMPLE_RESOURCE_MANAGER_HH
36 
37 #include <list>
38 #include <map>
39 #include <memory>
40 
41 #include "ResourceManager.hh"
42 #include "AssignmentPlan.hh"
43 #include "ResourceBuildDirector.hh"
44 
45 class BasicBlockNode;
47 class ControlFlowGraph;
49 namespace TTAProgram {
50  class Instruction;
51  class Immediate;
52  class TerminalImmediate;
53 }
54 
55 /**
56  * A simple resource manager.
57  */
59 public:
61  const TTAMachine::Machine& machine, unsigned int ii = 0);
62  static void disposeRM(SimpleResourceManager* rm, bool allowReuse = true);
63 
64  virtual bool canAssign(
65  int cycle, MoveNode& node,
66  const TTAMachine::Bus* bus = NULL,
67  const TTAMachine::FunctionUnit* srcFU = NULL,
68  const TTAMachine::FunctionUnit* dstFU = NULL,
69  int immWriteCycle = -1,
70  const TTAMachine::ImmediateUnit* immu = nullptr,
71  int immRegIndex = -1) const override;
72 
73  virtual bool canTransportImmediate(
74  const MoveNode& node,
75  const TTAMachine::Bus* preAssignedBus = NULL) const;
76  virtual void assign(
77  int cycle, MoveNode& node,
78  const TTAMachine::Bus* bus = NULL,
79  const TTAMachine::FunctionUnit* srcFU = NULL,
80  const TTAMachine::FunctionUnit* dstFU = NULL,
81  int immWriteCycle = -1,
82  const TTAMachine::ImmediateUnit* immu = nullptr,
83  int immRegIndex = -1) override;
84 
85  virtual void unassign(MoveNode& node) override;
86 
87  virtual int earliestCycle(MoveNode& node,
88  const TTAMachine::Bus* bus = NULL,
89  const TTAMachine::FunctionUnit* srcFU = NULL,
90  const TTAMachine::FunctionUnit* dstFU = NULL,
91  int immWriteCycle = -1,
92  const TTAMachine::ImmediateUnit* immu = nullptr,
93  int immRegIndex = -1) const override;
94 
95  virtual int earliestCycle(int cycle, MoveNode& node,
96  const TTAMachine::Bus* bus = NULL,
97  const TTAMachine::FunctionUnit* srcFU = NULL,
98  const TTAMachine::FunctionUnit* dstFU = NULL,
99  int immWriteCycle = -1,
100  const TTAMachine::ImmediateUnit* immu = nullptr,
101  int immRegIndex = -1) const override;
102 
103  virtual int latestCycle(MoveNode& node,
104  const TTAMachine::Bus* bus = NULL,
105  const TTAMachine::FunctionUnit* srcFU = NULL,
106  const TTAMachine::FunctionUnit* dstFU = NULL,
107  int immWriteCycle = -1,
108  const TTAMachine::ImmediateUnit* immu = nullptr,
109  int immRegIndex = -1) const override;
110 
111  virtual int latestCycle(int cycle, MoveNode& node,
112  const TTAMachine::Bus* bus = NULL,
113  const TTAMachine::FunctionUnit* srcFU = NULL,
114  const TTAMachine::FunctionUnit* dstFU = NULL,
115  int immWriteCycle = -1,
116  const TTAMachine::ImmediateUnit* immu = nullptr,
117  int immRegIndex = -1) const override;
118 
119  virtual bool hasGuard(const MoveNode& node) const;
120  virtual TTAProgram::Instruction* instruction(int cycle) const override;
121  virtual bool supportsExternalAssignments() const override;
122  virtual int largestCycle() const override;
123  virtual int smallestCycle() const override;
124  virtual void loseInstructionOwnership(int cycle);
125  virtual std::shared_ptr<TTAProgram::TerminalImmediate>
126  immediateValue(const MoveNode&);
127  virtual int immediateWriteCycle(const MoveNode&) const;
128  virtual bool isTemplateAvailable(
129  int, std::shared_ptr<TTAProgram::Immediate>) const;
130 
131  virtual unsigned int resourceCount() const;
132  virtual void print(std::ostream& target) const;
133  virtual std::string toString() const;
134 
135  virtual unsigned initiationInterval() const {return initiationInterval_;}
136  virtual void clearOldResources();
137  void setDDG(const DataDependenceGraph* ddg);
138  void setCFG(const ControlFlowGraph* cfg);
139  void setBBN(const BasicBlockNode* bbn);
140 
141  void setMaxCycle(unsigned int maxCycle);
142  int maxCycle() { return maxCycle_; }
143  unsigned int instructionIndex(unsigned int) const;
144 private:
146  const TTAMachine::Machine& machine, unsigned int ii = 0);
147 
148  virtual ~SimpleResourceManager();
149  /// Clears all bookkeeping done by this RM.
150  /// The RM can then be reused for different BB.
151  void clear();
152 
154 
155  /// Resource manager's broker director.
157  /// Resource assignment plan.
159  /// Resource build director.
161 
162  unsigned int initiationInterval_;
163  unsigned int maxCycle_;
164 
165  unsigned int resources;
166 
167  static std::map<const TTAMachine::Machine*,
168  std::map<int, std::list< SimpleResourceManager*> > >
170 };
171 
172 #endif
SimpleResourceManager::rmPool_
static std::map< const TTAMachine::Machine *, std::map< int, std::list< SimpleResourceManager * > > > rmPool_
Definition: SimpleResourceManager.hh:169
TTAProgram
Definition: Estimator.hh:65
SimpleResourceManager::immediateWriteCycle
virtual int immediateWriteCycle(const MoveNode &) const
Definition: SimpleResourceManager.cc:520
SimpleResourceManager::buildResourceModel
void buildResourceModel(const TTAMachine::Machine &machine)
Definition: SimpleResourceManager.cc:111
SimpleResourceManager::canAssign
virtual bool canAssign(int cycle, MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override
Definition: SimpleResourceManager.cc:186
SimpleResourceManager::largestCycle
virtual int largestCycle() const override
Definition: SimpleResourceManager.cc:463
TTAProgram::Instruction
Definition: Instruction.hh:57
SimpleResourceManager::smallestCycle
virtual int smallestCycle() const override
Definition: SimpleResourceManager.cc:480
TTAMachine::Bus
Definition: Bus.hh:53
SimpleResourceManager::immediateValue
virtual std::shared_ptr< TTAProgram::TerminalImmediate > immediateValue(const MoveNode &)
Definition: SimpleResourceManager.cc:509
SimpleResourceManager::setCFG
void setCFG(const ControlFlowGraph *cfg)
Definition: SimpleResourceManager.cc:634
MoveNode
Definition: MoveNode.hh:65
SimpleResourceManager::assign
virtual void assign(int cycle, MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) override
Definition: SimpleResourceManager.cc:221
SimpleResourceManager::initiationInterval
virtual unsigned initiationInterval() const
Definition: SimpleResourceManager.hh:135
SimpleResourceManager::unassign
virtual void unassign(MoveNode &node) override
Definition: SimpleResourceManager.cc:252
SimpleResourceManager::clearOldResources
virtual void clearOldResources()
Definition: SimpleResourceManager.cc:610
SimpleResourceManager::~SimpleResourceManager
virtual ~SimpleResourceManager()
Definition: SimpleResourceManager.cc:162
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
SimpleResourceManager::hasGuard
virtual bool hasGuard(const MoveNode &node) const
Definition: SimpleResourceManager.cc:426
SimpleResourceManager::clear
void clear()
Clears all bookkeeping done by this RM. The RM can then be reused for different BB.
Definition: SimpleResourceManager.cc:619
ResourceManager
Definition: ResourceManager.hh:53
BasicBlockNode
Definition: BasicBlockNode.hh:64
SimpleResourceManager::earliestCycle
virtual int earliestCycle(MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override
Definition: SimpleResourceManager.cc:278
SimpleResourceManager::disposeRM
static void disposeRM(SimpleResourceManager *rm, bool allowReuse=true)
Definition: SimpleResourceManager.cc:92
AssignmentPlan.hh
SimpleResourceManager::SimpleResourceManager
SimpleResourceManager(const TTAMachine::Machine &machine, unsigned int ii=0)
Definition: SimpleResourceManager.cc:58
ResourceBuildDirector
Definition: ResourceBuildDirector.hh:51
SimpleBrokerDirector
Definition: SimpleBrokerDirector.hh:67
SimpleResourceManager::createRM
static SimpleResourceManager * createRM(const TTAMachine::Machine &machine, unsigned int ii=0)
Definition: SimpleResourceManager.cc:73
SimpleResourceManager::instructionIndex
unsigned int instructionIndex(unsigned int) const
Definition: SimpleResourceManager.cc:534
SimpleResourceManager::resourceCount
virtual unsigned int resourceCount() const
Definition: SimpleResourceManager.cc:556
SimpleResourceManager::maxCycle_
unsigned int maxCycle_
Definition: SimpleResourceManager.hh:163
ResourceBuildDirector.hh
SimpleResourceManager::print
virtual void print(std::ostream &target) const
Definition: SimpleResourceManager.cc:566
SimpleResourceManager::director_
SimpleBrokerDirector * director_
Resource manager's broker director.
Definition: SimpleResourceManager.hh:156
AssignmentPlan
Definition: AssignmentPlan.hh:56
SimpleResourceManager::setMaxCycle
void setMaxCycle(unsigned int maxCycle)
Definition: SimpleResourceManager.cc:647
SimpleResourceManager::canTransportImmediate
virtual bool canTransportImmediate(const MoveNode &node, const TTAMachine::Bus *preAssignedBus=NULL) const
Definition: SimpleResourceManager.cc:411
ResourceManager::machine
const TTAMachine::Machine & machine() const
Definition: ResourceManager.cc:56
SimpleResourceManager::setDDG
void setDDG(const DataDependenceGraph *ddg)
Definition: SimpleResourceManager.cc:629
SimpleResourceManager::plan_
AssignmentPlan plan_
Resource assignment plan.
Definition: SimpleResourceManager.hh:158
SimpleResourceManager::buildDirector_
ResourceBuildDirector buildDirector_
Resource build director.
Definition: SimpleResourceManager.hh:160
DataDependenceGraph
Definition: DataDependenceGraph.hh:67
SimpleResourceManager::latestCycle
virtual int latestCycle(MoveNode &node, const TTAMachine::Bus *bus=NULL, const TTAMachine::FunctionUnit *srcFU=NULL, const TTAMachine::FunctionUnit *dstFU=NULL, int immWriteCycle=-1, const TTAMachine::ImmediateUnit *immu=nullptr, int immRegIndex=-1) const override
Definition: SimpleResourceManager.cc:349
SimpleResourceManager::isTemplateAvailable
virtual bool isTemplateAvailable(int, std::shared_ptr< TTAProgram::Immediate >) const
Definition: SimpleResourceManager.cc:543
SimpleResourceManager::setBBN
void setBBN(const BasicBlockNode *bbn)
Definition: SimpleResourceManager.cc:639
SimpleResourceManager::maxCycle
int maxCycle()
Definition: SimpleResourceManager.hh:142
SimpleResourceManager::loseInstructionOwnership
virtual void loseInstructionOwnership(int cycle)
Definition: SimpleResourceManager.cc:498
SimpleResourceManager::initiationInterval_
unsigned int initiationInterval_
Definition: SimpleResourceManager.hh:162
SimpleResourceManager
Definition: SimpleResourceManager.hh:58
SimpleResourceManager::supportsExternalAssignments
virtual bool supportsExternalAssignments() const override
Definition: SimpleResourceManager.cc:453
SimpleResourceManager::toString
virtual std::string toString() const
Definition: SimpleResourceManager.cc:582
ResourceManager.hh
ControlFlowGraph
Definition: ControlFlowGraph.hh:100
TTAMachine::Machine
Definition: Machine.hh:73
SimpleResourceManager::resources
unsigned int resources
Definition: SimpleResourceManager.hh:165
SimpleResourceManager::instruction
virtual TTAProgram::Instruction * instruction(int cycle) const override
Definition: SimpleResourceManager.cc:442
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50