Otawa  0.10
BBProcessor.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * BBProcessor class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2005-10, 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 #ifndef OTAWA_PROC_BBPROCESSOR_H
23 #define OTAWA_PROC_BBPROCESSOR_H
24 
25 #include <otawa/cfg/BasicBlock.h>
27 
28 namespace otawa {
29 
30 using namespace elm;
31 
32 // BBCleaner class
33 class BBCleaner: public Cleaner {
34 public:
35  BBCleaner(WorkSpace *_ws): ws(_ws) { }
36  virtual void clean(void);
37 protected:
38  virtual void clean(WorkSpace *ws, CFG *cfg, BasicBlock *bb) = 0;
39 private:
41 };
42 
43 
44 // BBRemover class
45 template <class T>
46 class BBRemover: public BBCleaner {
47 public:
48  inline BBRemover(WorkSpace *ws, Identifier<T>& identifier)
49  : BBCleaner(ws), id(identifier) { }
50 protected:
52  virtual void clean(WorkSpace *ws, CFG *cfg, BasicBlock *bb)
53  { bb->removeProp(id); }
54 };
55 
56 
57 // BBDeletor class
58 template <class T>
59 class BBDeletor: public BBRemover<T> {
60 public:
61  inline BBDeletor(WorkSpace *ws, Identifier<T *>& identifier)
62  : BBRemover<T>(ws), id(identifier) { }
63  virtual ~BBDeletor(void) { }
64 protected:
66  virtual void clean(WorkSpace *ws, CFG *cfg, BasicBlock *bb)
67  { T *p = id(bb); if(p) delete p; BBRemover<T>::clean(ws, cfg, bb); }
68 };
69 
70 
71 // BBProcessor class
72 class BBProcessor: public CFGProcessor {
73 protected:
74  virtual void processCFG(WorkSpace *ws, CFG *cfg);
75  virtual void processBB(WorkSpace *ws, CFG *cfd, BasicBlock *bb) = 0;
76  virtual void cleanupCFG(WorkSpace *ws, CFG *cfg);
77  virtual void cleanupBB(WorkSpace *ws, CFG *cfg, BasicBlock *bb);
78 
79 public:
80  BBProcessor(void);
82  inline BBProcessor(cstring name, const Version& version, AbstractRegistration& reg)
83  : CFGProcessor(name, version, reg) { }
85 
86 protected:
87  template <class T> void trackBB(const AbstractFeature& feature, const Identifier<T *>& id)
88  { addCleaner(feature, new BBDeletor<T>(workspace(), id)); }
89  template <class T> void trackBB(const AbstractFeature& feature, const Identifier<T>& id)
90  { addCleaner(feature, new BBRemover<T>(workspace(), id)); }
91 };
92 
93 } // otawa
94 
95 #endif // OTAWA_PROC_BBPROCESSOR_H
This processor is dedicated to the basic block process thru proccessBB() method.
Definition: BBProcessor.h:72
Efficient implementation of a cleaner for properties found on a basic block.
Definition: BBProcessor.h:33
virtual ~BBDeletor(void)
Definition: BBProcessor.h:63
virtual void clean(WorkSpace *ws, CFG *cfg, BasicBlock *bb)
Definition: BBProcessor.h:66
Abstract class to represent the registered processors.
Definition: Registration.h:80
BBDeletor(WorkSpace *ws, Identifier< T * > &identifier)
Definition: BBProcessor.h:61
BBProcessor(cstring name, const Version &version, AbstractRegistration &reg)
Definition: BBProcessor.h:82
BBRemover(WorkSpace *ws, Identifier< T > &identifier)
Definition: BBProcessor.h:48
Identifier< T * > & id
Definition: BBProcessor.h:65
dtd::Element bb(dtd::make("bb", _BB).attr(id).attr(address).attr(size))
void trackBB(const AbstractFeature &feature, const Identifier< T * > &id)
Track and delete the content of the given identifier on each basic block.
Definition: BBProcessor.h:87
Control Flow Graph representation.
Definition: CFG.h:42
Definition: BBProcessor.h:46
static const Version ZERO
BBCleaner(WorkSpace *_ws)
Definition: BBProcessor.h:35
BBProcessor(AbstractRegistration &reg)
Definition: BBProcessor.h:81
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
WorkSpace * ws
Definition: BBProcessor.h:40
This is a specialization of the processor class dedicated to CFG processing.
Definition: CFGProcessor.h:35
Basic block cleaner removing an identifier and deleting its content.
Definition: BBProcessor.h:59
virtual void clean(void)
Definition: proc_BBProcessor.cpp:108
dtd::Element cfg(dtd::make("cfg", _CFG).attr(id).content((entry,*bb, exit,*edge)))
void removeProp(const AbstractIdentifier *id)
Remove a property matching the given identifier.
Definition: prop_PropList.cpp:409
This class represents identifier with a typed associated value.
Definition: Identifier.h:51
This is the minimal definition of a basic block.
Definition: BasicBlock.h:43
cstring name
Definition: odisasm.cpp:107
See Feature.
Definition: AbstractFeature.h:36
Identifier< T > & id
Definition: BBProcessor.h:51
virtual void clean(WorkSpace *ws, CFG *cfg, BasicBlock *bb)
Definition: BBProcessor.h:52
void trackBB(const AbstractFeature &feature, const Identifier< T > &id)
Track and remove properties put on basic blocks.
Definition: BBProcessor.h:89