Otawa  0.10
BBPath.h
Go to the documentation of this file.
1 /*
2  * BBPath class interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2006, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef OTAWA_TSIM_BBPATH_H
22 #define OTAWA_TSIM_BBPATH_H
23 
24 #include <otawa/cfg.h>
25 #include <otawa/ilp.h>
26 #include <otawa/sim/State.h>
27 #include <elm/genstruct/Vector.h>
28 #include <otawa/tsim/TreePath.h>
29 
30 
31 namespace otawa { namespace tsim {
32 
33 class PathManager;
34 
35 class BBPath: public PropList {
36  friend class PathManager;
37 protected:
38  BBPath(BasicBlock *start);
40  //virtual ~BBPath();
41 
42  int _length;
44  //sim::State *ending_state;
45  WorkSpace *last_framework_used; // Last framework used for simulation
46 
47  /*virtual elm::IteratorInst<BasicBlock*> *visit(void);
48  virtual elm::MutableCollection<BasicBlock *> *empty(void);*/
49 
50  int simulate(WorkSpace *fw);
51  //sim::State *getEndingState(FrameWork *fw);
52 
53 public:
54  static BBPath* getBBPath(BasicBlock *start);
56 
58  int time(WorkSpace *fw);
59  int countInstructions();
60  inline int t(WorkSpace *fw);
61  inline int length();
62  inline int l();
63  inline BasicBlock* head();
64  inline BasicBlock* tail();
66  ilp::Var *getVar(ilp::System *system, bool explicit_names = false);
67  BBPath* sub(int begin, int end);
68  inline BBPath* operator() (int begin, int end);
69  //inline Collection<BasicBlock*>& bbs();
70 
71  // Iterator
72  class BBIterator: public elm::PreIterator<BBIterator, BasicBlock *> {
74  int pos;
75  public:
76  inline BBIterator(BBPath *bbpath);
77  inline bool ended(void) const;
78  inline BasicBlock *item(void) const;
79  inline void next(void);
80  };
81 
83  //static GenericIdentifier<TreePath<BasicBlock*,BBPath*>*> TREE;
84 
85  // Comparison
86  //bool equals (BBPath &bbpath);
87  //inline bool operator== (BBPath &bbpath);
88 };
89 
91 
92 // BBPath inlines
93 inline int BBPath::t(WorkSpace *fw) {return time(fw);}
94 inline int BBPath::l() {return length();}
95 inline int BBPath::length() {return _length;}
96 inline BBPath* BBPath::operator() (int begin, int end){return sub(begin, end);}
97 //inline bool BBPath::operator== (BBPath &bbpath){return equals(bbpath);}
98 inline BasicBlock* BBPath::head() {return basicBlocks[0];}
99 inline BasicBlock* BBPath::tail() {return basicBlocks.top();}
100 //inline Collection<BasicBlock*>& BBPath::bbs(){return *this;}
101 
102 // BBIterator inlines
104 : bbs(bbpath->basicBlocks), pos(0) {};
105 inline bool BBPath::BBIterator::ended(void) const {
106  return pos >= bbs.length();
107 };
109  return bbs[pos];
110 };
111 inline void BBPath::BBIterator::next(void) {
112  pos++;
113 };
114 
115 } } // otawa::tsim
116 
117 #endif /*OTAWA_TSIM_BBPATH_H*/
BasicBlock * item(void) const
Definition: BBPath.h:108
int t(WorkSpace *fw)
tests if two BBSequences are the same or not (same basic blocks in the path)
Definition: BBPath.h:93
int countInstructions()
Definition: BBPath.cpp:193
void next(void)
Definition: BBPath.h:111
elm::genstruct::Vector< BasicBlock * > basicBlocks
Definition: BBPath.h:43
BasicBlock * tail()
Definition: BBPath.h:99
BBPath(BasicBlock *start)
Builds a new BBPath (length=1) from a given basic block.
Definition: BBPath.cpp:56
const int end
Definition: Registration.h:42
int _length
Definition: BBPath.h:42
ilp::Var * getVar(ilp::System *system, bool explicit_names=false)
if this sequence doesn't have a var (for the ilp system) attached, creates a new one ...
Definition: BBPath.cpp:295
io::Output & operator<<(io::Output &out, BBPath &path)
Display a BB path as a sequence of basic blocks.
Definition: BBPath.cpp:373
elm::genstruct::Vector< BBPath * > * nexts()
Builds a vector containing this BBSequence made longer with all successors of the last basic block it...
Definition: BBPath.cpp:141
friend class PathManager
Definition: BBPath.h:36
BBPath * operator()(int begin, int end)
Definition: BBPath.h:96
int simulate(WorkSpace *fw)
Launches a simulation of the sequence.
Definition: BBPath.cpp:207
elm::genstruct::Vector< BasicBlock * > & bbs
Definition: BBPath.h:73
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
BBIterator(BBPath *bbpath)
Definition: BBPath.h:103
Definition: BBPath.h:72
static int instructions_simulated
Definition: BBPath.h:82
int time(WorkSpace *fw)
Returns the number of cycles the processor must do to cover the sequence.
Definition: BBPath.cpp:183
int length()
Gives the number of basic blocks that composes this path.
Definition: BBPath.h:95
Definition: BBPath.h:35
sys::SystemOutStream & out
int pos
Definition: BBPath.h:74
This is the minimal definition of a basic block.
Definition: BasicBlock.h:43
BasicBlock * head()
Definition: BBPath.h:98
This a list of properties.
Definition: PropList.h:63
WorkSpace * last_framework_used
Definition: BBPath.h:45
A variable is an identifier used for performing ILP computation.
Definition: Var.h:36
BBPath * sub(int begin, int end)
Returns a sub-path.
Definition: BBPath.cpp:319
An ILP system is a colletion of ILP constraint that may maximize or minimize some object function...
Definition: System.h:42
int l()
Same as BBPath::length() Gives the number of basic blocks that composes this path.
Definition: BBPath.h:94
static BBPath * getBBPath(BasicBlock *start)
Returns the path of length 1 composed by only the given basic block.
Definition: BBPath.cpp:94
elm::String makeVarName()
Creates a human-readable name (or representation) for this sequence This name is like Seq_x1_x2_x3 ...
Definition: BBPath.cpp:273
bool ended(void) const
Definition: BBPath.h:105