Otawa  0.10
BPredProcessor.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * BPredProcessor class interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2008, 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_IPET_BRANCHINSPECTION_
23 #define OTAWA_IPET_BRANCHINSPECTION_
24 
25 #include <otawa/otawa.h>
26 #include <otawa/dfa/BitSet.h>
27 #include <elm/genstruct/HashTable.h>
30 #include <otawa/ipet/IPET.h>
31 #include <otawa/bpred/features.h>
32 
33 
34 #define CLAIRE_INFOS 0
35 
36 
37 namespace otawa { namespace bpred {
38 
39 class BSets;
40 class BCG;
41 class BHG;
42 class BHGEdge;
43 class BHGNode;
44 class BBHG;
45 class BBHGNode;
46 
48 public:
49  static p::declare reg;
50  String getStats(void);
52  ~BPredProcessor(void);
53 
54 protected:
55  virtual void configure(const PropList &props);
56 
57 private:
58  unsigned int BHT;
61  unsigned int BHG_history_size;
68  // STATS
71 
72  // GENERAL
73  BasicBlock* getBB(int id,CFG* cfg);
74  virtual void processCFG(WorkSpace *ws,CFG* cfg);
75  String bin_to_str(int i);
76  inline int getBit(int v,int n) { return ((v & 1 << n)>0)?1:0; }
77  inline void setBit(int&v, int n) { v |= (1<<n); }
79  dfa::BitSet lshift_BitSet(dfa::BitSet bs,int dec,bool val_in=false);
80  void setMitraInit(const char* binary_histo);
81 
82  // Global 1bit
86  void generateBBHG(CFG* cfg,BBHG& bbhg);
87  bool contains(const elm::genstruct::Vector< BBHGNode* >& v, BBHGNode& n, BBHGNode * &contained);
88  bool isBranch(BasicBlock* bb);
89 
90  // Global 2bits
93  bool isClassEntry(BHG* bhg, BHGNode* src);
94  bool isClassExit(BHG* bhg, BHGNode* src, bool& src_withT,bool& src_withNT);
95  bool contains(const elm::genstruct::Vector< BHGNode* >& v, BHGNode& n, BHGNode * &contained);
96  void historyPlusOne(dfa::BitSet& h);
97  bool isLinked(BHGEdge* dir, BHGNode* dest, dfa::BitSet& h, elm::genstruct::HashTable<BHGNode* , BHGNode*>& visited_nodes);
100  void generateBHG(CFG* cfg,BHG& bhg);
101  void generateBCGs(elm::genstruct::Vector<BCG*>& bcgs, BHG& bhg);
103 
104 
105  // No Conflict 2bits Counter
108 
109  // Bi Modal
110  void CS__BiModal(WorkSpace *fw, CFG *cfg, BSets& bs, elm::genstruct::Vector<BCG*> &graphs);
111  void generateClasses(CFG *cfg, BSets& bs);
112  void computePredecessors(CFG *cfg,
113  BasicBlock *bb,
114  elm::genstruct::Vector<int> *bit_sets,
115  elm::genstruct::Vector<int> &in_outs,
116  BSets &bs,
117  int addr,
118  int visited[]);
119  void simplifyCFG(CFG* cfg, BSets& bs, int addr, elm::genstruct::Vector<BCG*> &graphs);
121 };
122 
123 } } // otawa::bpred
124 
125 #endif /* OTAWA_IPET_BRANCHINSPECTION_ */
void processCFG__Global2B(WorkSpace *ws, CFG *cfg)
void processCFG__Global1B(WorkSpace *ws, CFG *cfg)
bool isClassEntry(BHG *bhg, BHGNode *src)
CFG * cfg(void) const
Get the current CFG.
Definition: CFGProcessor.h:56
elm::genstruct::Vector< int > stat_nbbr
Definition: BPredProcessor.h:63
void setMitraInit(const char *binary_histo)
Converts a string containing a binary number into a bitset and sets the class parameter mitraInit...
Definition: BPredProcessor.cpp:211
bool explicit_mode
Definition: BPredProcessor.h:67
unsigned int BHT
Definition: BPredProcessor.h:58
virtual void configure(const PropList &props)
Configures the parameters of the class from the given PropList.
Definition: BPredProcessor.cpp:301
BasicBlock * getFirstBranch(BasicBlock *bb, CFG *cfg)
bool withStats
Definition: BPredProcessor.h:62
Class to declare simple a processor.
Definition: Registration.h:213
This class implements a set as a bit vector.
Definition: BitSet.h:82
String BitSet_to_String(const dfa::BitSet &bs)
Converts a BitSet into a String.
Definition: BPredProcessor.cpp:231
bool contains(const elm::genstruct::Vector< BBHGNode * > &v, BBHGNode &n, BBHGNode *&contained)
~BPredProcessor(void)
The destructor.
Definition: BPredProcessor.cpp:201
void setBit(int &v, int n)
Definition: BPredProcessor.h:77
This is a specialization of the CFGProcessor class dedicated to branch prediction.
Definition: BPredProcessor.h:47
dfa::BitSet * mitraInit
Definition: BPredProcessor.h:66
String stats_str
Definition: BPredProcessor.h:64
void generateClasses(CFG *cfg, BSets &bs)
WorkSpace * ws
Definition: Processor.h:185
dtd::Element bb(dtd::make("bb", _BB).attr(id).attr(address).attr(size))
Control Flow Graph representation.
Definition: CFG.h:42
elm::genstruct::Vector< dfa::BitSet * > stat_hist
Definition: BPredProcessor.h:65
void generateBBHG(CFG *cfg, BBHG &bbhg)
void historyPlusOne(dfa::BitSet &h)
method_t
Definition: features.h:28
void CS__Global1b(WorkSpace *fw, CFG *cfg, BHG *bhg, BBHG *bbhg, elm::genstruct::Vector< BCG * > &bcgs, elm::genstruct::HashTable< String, ilp::Var * > &ht_vars)
String bin_to_str(int i)
Definition: BPredProcessor.cpp:318
bool dumpBBHG
Definition: BPredProcessor.h:59
void CS__Global2b_not_mitra(WorkSpace *fw, CFG *cfg, BHG *bhg, elm::genstruct::Vector< BCG * > &graphs, elm::genstruct::HashTable< String, ilp::Var * > &ht_vars)
method_t method
Definition: BPredProcessor.h:60
BasicBlock * getBB(int id, CFG *cfg)
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
void generateBCGs(elm::genstruct::Vector< BCG * > &bcgs, BHG &bhg)
void processCFG__Bimodal(WorkSpace *ws, CFG *cfg)
bool isClassExit(BHG *bhg, BHGNode *src, bool &src_withT, bool &src_withNT)
This is a specialization of the processor class dedicated to CFG processing.
Definition: CFGProcessor.h:35
bool dumpBCG
Definition: BPredProcessor.h:59
bool isBranch(BasicBlock *bb)
elm::genstruct::Vector< int > stat_addr
Definition: BPredProcessor.h:63
void CS__NoConflict_2bCounter(WorkSpace *fw, BasicBlock *bb)
bool dumpBHG
Definition: BPredProcessor.h:59
void CS__BiModal(WorkSpace *fw, CFG *cfg, BSets &bs, elm::genstruct::Vector< BCG * > &graphs)
unsigned int BHG_history_size
Definition: BPredProcessor.h:61
bool isLinked(BHGEdge *dir, BHGNode *dest, dfa::BitSet &h, elm::genstruct::HashTable< BHGNode *, BHGNode * > &visited_nodes)
This is the minimal definition of a basic block.
Definition: BasicBlock.h:43
void computePredecessors(CFG *cfg, BasicBlock *bb, elm::genstruct::Vector< int > *bit_sets, elm::genstruct::Vector< int > &in_outs, BSets &bs, int addr, int visited[])
dfa::BitSet lshift_BitSet(dfa::BitSet bs, int dec, bool val_in=false)
Operates a left-shift to the BitSet, filling the new free bit(s) with the given state (true or false)...
Definition: BPredProcessor.cpp:248
This a list of properties.
Definition: PropList.h:63
void simplifyCFG(CFG *cfg, BSets &bs, int addr, elm::genstruct::Vector< BCG * > &graphs)
void CS__Global1b_mitra(WorkSpace *fw, CFG *cfg, BBHG *bhg, elm::genstruct::HashTable< String, ilp::Var * > &ht_vars)
virtual void processCFG(WorkSpace *ws, CFG *cfg)
That's the overloaded method that creates the new constraint system defined by the given method...
Definition: BPredProcessor.cpp:271
void processCFG__NoConflict_2bCounter(WorkSpace *ws, CFG *cfg)
BPredProcessor(p::declare &r=reg)
Build a new branch prediction processor.
Definition: BPredProcessor.cpp:192
void getBranches(BasicBlock *bb, dfa::BitSet bs, elm::genstruct::Vector< BHGNode * > &suivants, CFG *cfg, BasicBlock *entryBr)
bool withMitra
Definition: BPredProcessor.h:62
String genStats(WorkSpace *ws, CFG *cfg)
int getBit(int v, int n)
Definition: BPredProcessor.h:76
void generateBHG(CFG *cfg, BHG &bhg)
static p::declare reg
Definition: BPredProcessor.h:49
void CS__Global2b(WorkSpace *fw, CFG *cfg, BHG *bhg, elm::genstruct::Vector< BCG * > &graphs, elm::genstruct::HashTable< String, ilp::Var * > &ht_vars)