Otawa  0.10
UnrollingListener.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * Listener associated with FirstUnrollingFixPoint
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
21  * 02110-1301 USA
22  */
23 
24 #ifndef OTAWA_DFA_HAI_UNROLLINGLISTENER_H_
25 #define OTAWA_DFA_HAI_UNROLLINGLISTENER_H_
26 
27 #include "FirstUnrollingFixPoint.h"
28 #include <otawa/cfg/CFG.h>
29 #include <otawa/cfg/CFGCollector.h>
30 #include <otawa/cfg/BasicBlock.h>
31 #include <otawa/cfg/Edge.h>
32 #include <otawa/prop/PropList.h>
33 #include <otawa/prop/Identifier.h>
34 #include <elm/genstruct/Vector.h>
35 
36 namespace otawa { namespace dfa { namespace hai {
37 
38 
39 template <class P>
41 
42  public:
43  typedef P Problem;
44 
46 
47  typename Problem::Domain ***results;
48 
50  : fw(_fw), prob(_prob) {
51  const CFGCollection *col = INVOLVED_CFGS(fw);
52  results = new typename Problem::Domain**[col->count()];
53 
54  for (int i = 0; i < col->count(); i++) {
55  CFG *cfg = col->get(i);
56  results[i] = new typename Problem::Domain*[cfg->countBB()];
57  for (int j = 0; j < cfg->countBB(); j++)
58  results[i][j] = new typename Problem::Domain(prob.bottom());
59  }
60  }
61 
63  const CFGCollection *col = INVOLVED_CFGS(fw);
64  for (int i = 0; i < col->count(); i++) {
65  CFG *cfg = col->get(i);
66  for (int j = 0; j < cfg->countBB(); j++)
67  delete results[i][j];
68  delete [] results[i];
69  }
70  delete [] results;
71  }
72 
73  void blockInterpreted(const FirstUnrollingFixPoint< UnrollingListener > *fp, BasicBlock* bb, const typename Problem::Domain& in, const typename Problem::Domain& out, CFG *cur_cfg, elm::genstruct::Vector<Edge*> *callStack) const;
74 
76 
77  inline Problem& getProb() {
78  return(prob);
79  }
80 
81  private:
84 
85 
86 
87 
88 
89 
90 
91 };
92 
93 template <class Problem >
95 
96 template <class Problem >
97 void UnrollingListener<Problem>::blockInterpreted(const FirstUnrollingFixPoint<UnrollingListener> *fp, BasicBlock* bb, const typename Problem::Domain& in, const typename Problem::Domain& out, CFG *cur_cfg, elm::genstruct::Vector<Edge*> *callStack) const {
98 
99  int bbnumber = bb->number() ;
100  int cfgnumber = cur_cfg->number();
101 
102  prob.lub(*results[cfgnumber][bbnumber], in);
103 
104  if (BB_OUT_STATE(bb) != 0)
105  prob.lub(**BB_OUT_STATE(bb), out);
106 
107 #ifdef DEBUG
108  cout << "[TRACE] CFG " << cur_cfg->label() << " BB " << bbnumber << ": IN=" << in << " OUT=" << out << "\n";
109  cout << "[TRACE] result: " << *results[cfgnumber][bbnumber] << "\n";
110 #endif
111 }
112 
113 template <class Problem >
115 }
116 
117 } } } // otawa::dfa::hai
118 
119 #endif // OTAWA_DFA_HAI
void fixPointReached(const FirstUnrollingFixPoint< UnrollingListener > *fp, BasicBlock *bb)
This is called whenever a loop's fixpoint is reached.
Definition: UnrollingListener.h:114
P Problem
Definition: UnrollingListener.h:43
Problem::Domain *** results
Definition: UnrollingListener.h:47
This listener gathers in an array the LUB of the in-states for all analyzed basic blocks...
Definition: UnrollingListener.h:40
Problem & prob
Definition: UnrollingListener.h:83
sys::SystemInStream & in
int number(void)
Definition: CFG.h:111
dtd::Element bb(dtd::make("bb", _BB).attr(id).attr(address).attr(size))
Control Flow Graph representation.
Definition: CFG.h:42
CFG * get(int index) const
Get a CFG from the collection using its index.
Definition: features.h:51
static Identifier< typename Problem::Domain * > BB_OUT_STATE
Definition: UnrollingListener.h:45
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
FixPoint class for HalfAbsInt The DefaultFixPoint manages loops in a simple way.
Definition: FirstUnrollingFixPoint.h:38
Contains a collection of CFGs (used with INVOLVED_CFGS property).
Definition: features.h:45
int number(void) const
Get the number hooked on this basic block, that is, value of ID_Index property.
Definition: BasicBlock.h:146
UnrollingListener(WorkSpace *_fw, Problem &_prob)
Definition: UnrollingListener.h:49
sys::SystemOutStream & out
Identifier< const CFGCollection * > INVOLVED_CFGS
This property is used to link the current computation involved CFG on the framework.
WorkSpace * fw
Definition: UnrollingListener.h:82
~UnrollingListener()
Definition: UnrollingListener.h:62
dtd::Element cfg(dtd::make("cfg", _CFG).attr(id).content((entry,*bb, exit,*edge)))
This is the minimal definition of a basic block.
Definition: BasicBlock.h:43
string label(void)
Get some label to identify the CFG.
Definition: CFG.cpp:368
int count(void) const
Get the count of CFG in the collection.
Definition: features.h:50
void blockInterpreted(const FirstUnrollingFixPoint< UnrollingListener > *fp, BasicBlock *bb, const typename Problem::Domain &in, const typename Problem::Domain &out, CFG *cur_cfg, elm::genstruct::Vector< Edge * > *callStack) const
Definition: UnrollingListener.h:97
io::Output cout
Problem & getProb()
Definition: UnrollingListener.h:77
int countBB(void)
Definition: CFG.h:105