Otawa  0.10
Resource.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * Interface to the xxxResource classes.
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2007, IRIT UPS.
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
24 #ifndef _RESOURCE_H_
25 #define _RESOURCE_H_
26 
28 #include <otawa/hard/Register.h>
29 #include <otawa/hard/Platform.h>
30 
31 namespace otawa {
32 
33  class ParExeInst;
34 
35  class Resource {
36  public:
38  // last value must be RES_TYPE_NUM
39  typedef struct input_t {
43  } input_t;
44  private:
47  int _index;
48  public:
49  inline Resource(elm::String name, resource_type_t type, int index) : _name(name), _type(type), _index(index) {}
50  inline elm::String name() {return _name;}
51  inline resource_type_t type() {return _type;}
52  inline int index() {return _index;}
53  inline void setIndex(int index) {_index = index;}
54  };
55 
56  class StartResource : public Resource {
57  public:
58  inline StartResource(elm::String name, int index) : Resource(name,BLOCK_START, index) {}
59  };
60 
61  class StageResource : public Resource {
62  private:
64  int _slot;
65  public:
66  inline StageResource(elm::String name, ParExeStage *stage, int slot, int index) : Resource(name,STAGE, index), _stage(stage), _slot(slot) {}
67  inline ParExeStage * stage() {return _stage;}
68  inline int slot() {return _slot;}
69  };
70 
71  class QueueResource : public Resource {
72  private:
74  int _slot;
75  int _uid; // upper bound index
76  int _offset;
77  public:
78  inline QueueResource(elm::String name, ParExeQueue * queue, int slot, int index, StageResource * upper_bound, int num_stages)
79  : Resource(name,QUEUE, index), _queue(queue), _slot(slot)/*, _upper_bound(upper_bound)*/ {
80  _uid = upper_bound->index();
81  _offset = num_stages - upper_bound->stage()->index();
82  }
83  inline ParExeQueue * queue() {return _queue;}
84  inline int slot() {return _slot;}
85  inline int uid() {return _uid;}
86  inline int offset() {return _offset;}
87  };
88 
89  class RegResource : public Resource {
90  private:
94  public:
95  inline RegResource(elm::String name, otawa::hard::RegBank * reg_bank, int reg_index, int index)
96  : Resource(name,REG, index), _reg_bank(reg_bank), _reg_index(reg_index) {}
97  inline ~RegResource() {
98  _using_instructions.clear();
99  }
101  inline int regIndex() {return _reg_index;}
102  inline void addUsingInst(ParExeInst * inst) {
103  if (! _using_instructions.contains(inst) )
104  _using_instructions.add(inst);
105  }
106  class UsingInstIterator : public elm::genstruct::Vector<ParExeInst *>::Iterator {
107  public:
109  : elm::genstruct::Vector<ParExeInst *>::Iterator(res->_using_instructions) {}
110  };
111  };
112 
113 // class ExternalConflictResource : public Resource {
114 // private:
115 // ParExeInst * _instruction;
116 // public:
117 // ExternalConflictResource(elm::String name, ParExeInst * instruction, int index)
118 // : Resource(name,EXTERNAL_CONFLICT, index), _instruction(instruction) {}
119 // ParExeInst * instruction()
120 // {return _instruction;}
121 // };
122 //
123 // class InternalConflictResource : public Resource {
124 // private:
125 // ParExeInst * _instruction;
126 // ParExeNode * _node;
127 // public:
128 // InternalConflictResource(elm::String name, ParExeInst * instruction, int index)
129 // : Resource(name,INTERNAL_CONFLICT, index), _instruction(instruction) {}
130 // ParExeInst* instruction()
131 // {return _instruction;}
132 // void setNode(ParExeNode *node)
133 // {_node = node;}
134 // ParExeNode *node()
135 // {return _node;}
136 //
137 // };
138 
140  private:
141  elm::genstruct::Vector<Resource *> _resources; // resources available in the processor: pipeline stages, queue slots, registers, etc.
142  public:
144  inline int numResources() {return _resources.length();}
145  class ResourceIterator: public elm::genstruct::Vector<Resource *>::Iterator {
146  public:
147  inline ResourceIterator(const ResourceList *list) : elm::genstruct::Vector<Resource *>::Iterator(list->_resources) {}
148  };
149  };
150 
151 
152 
153 
154 } // namespace otawa
155 
156 #endif //_RESOURCE_H_
int slot()
Definition: Resource.h:68
Definition: Resource.h:106
struct otawa::sem::inst inst
This class represents a bank of registers.
Definition: Register.h:68
Representation of a pipeline stage to be used to build a ParExeGraph.
Definition: ParExeProc.h:86
int _slot
Definition: Resource.h:74
elm::String _name
Definition: Resource.h:45
ParExeQueue * queue()
Definition: Resource.h:83
int index()
Definition: Resource.h:52
QueueResource(elm::String name, ParExeQueue *queue, int slot, int index, StageResource *upper_bound, int num_stages)
Definition: Resource.h:78
Definition: Resource.h:37
Definition: Resource.h:145
int _slot
Definition: Resource.h:64
resource_type_t
Definition: Resource.h:37
int _reg_index
Definition: Resource.h:93
otawa::hard::RegBank * regBank()
Definition: Resource.h:100
resource_type_t type()
Definition: Resource.h:51
StartResource(elm::String name, int index)
Definition: Resource.h:58
elm::String name()
Definition: Resource.h:50
Représentation of a processor (to be used to build a ParExeGraph).
Definition: ParExeProc.h:195
hard::RegBank * reg_bank
Definition: Resource.h:40
Definition: Resource.h:61
resource_type_t _type
Definition: Resource.h:46
Definition: Resource.h:35
elm::genstruct::AllocatedTable< int > * _resource_index
Definition: Resource.h:42
StringOption proc(command, 'p',"processor","used processor","path","")
elm::genstruct::Vector< ParExeInst * > _using_instructions
Definition: Resource.h:91
Definition: Resource.h:56
int index(void)
Definition: ParExeProc.h:116
Definition: Resource.h:37
int regIndex()
Definition: Resource.h:101
elm::genstruct::Vector< Resource * > _resources
Definition: Resource.h:141
int numResources()
Definition: Resource.h:144
otawa::hard::RegBank * _reg_bank
Definition: Resource.h:92
Definition: Resource.h:139
Definition: Resource.h:37
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
void setIndex(int index)
Definition: Resource.h:53
Definition: Resource.h:71
Definition: Resource.h:89
Definition: Resource.h:37
int uid()
Definition: Resource.h:85
UsingInstIterator(const RegResource *res)
Definition: Resource.h:108
StageResource(elm::String name, ParExeStage *stage, int slot, int index)
Definition: Resource.h:66
int offset()
Definition: Resource.h:86
int _offset
Definition: Resource.h:76
Definition: Resource.h:37
Resource(elm::String name, resource_type_t type, int index)
Definition: Resource.h:49
RegResource(elm::String name, otawa::hard::RegBank *reg_bank, int reg_index, int index)
Definition: Resource.h:95
struct otawa::Resource::input_t input_t
~RegResource()
Definition: Resource.h:97
Definition: Resource.h:37
ParExeQueue * _queue
Definition: Resource.h:73
Instruction as presented in the ParExeGraph.
Definition: ParExeGraph.h:63
int _index
Definition: Resource.h:47
ParExeStage * stage()
Definition: Resource.h:67
ResourceIterator(const ResourceList *list)
Definition: Resource.h:147
int slot()
Definition: Resource.h:84
Definition: Resource.h:39
ParExeStage * _stage
Definition: Resource.h:63
Representation of a hardware instruction queue to be used to build a ParExeGraph. ...
Definition: ParExeProc.h:57
Definition: Resource.h:37
ResourceList(WorkSpace *ws, ParExeProc *proc)
Definition: parexegraph_Resource.cpp:54
void addUsingInst(ParExeInst *inst)
Definition: Resource.h:102
elm::genstruct::AllocatedTable< bool > * _is_input
Definition: Resource.h:41
int _uid
Definition: Resource.h:75