Otawa  0.10
BHT.h
Go to the documentation of this file.
1 /*
2  * BHT support interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2005, 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_HARD_BHT_H
22 #define OTAWA_HARD_BHT_H
23 
24 #include <elm/io.h>
25 #include <elm/serial2/macros.h>
26 #include <elm/genstruct/Vector.h>
27 #include <otawa/base.h>
28 #include <otawa/hard/PureCache.h>
30 
31 namespace otawa { namespace hard {
32 
33 // default prediction type
34 const static int PREDICT_NONE = 0,
35  PREDICT_TAKEN = 1,
36  PREDICT_NOT_TAKEN = 2,
37  PREDICT_DIRECT = 3,
38  PREDICT_UNKNOWN = 4;
39 
40 // BHT class
41 class BHT: public PureCache {
42 private:
47 
48  SERIALIZABLE(BHT, ELM_BASE(PureCache) &
49  DFIELD(cond_penalty, 10) &
50  DFIELD(indirect_penalty, 10) &
51  DFIELD(cond_indirect_penalty, 10) &
52  DFIELD(def_predict, PREDICT_TAKEN)
53  );
54 
55 public:
56  inline BHT(void) { }
57  virtual ~BHT(void) { }
58 
59  // Modifiers
60  inline void setCondPenalty(int time) { cond_penalty = time; }
61  inline void setIndirectPenalty(int time) { indirect_penalty = time; }
63  inline void setDefaultPrediction(int def) { def_predict = def; }
64 
65  // Accessors
66  inline int getCondPenalty(void) const { return cond_penalty; }
67  inline int getIndirectPenalty(void) const { return indirect_penalty; }
68  inline int getCondIndirectPenalty(void) const { return cond_indirect_penalty; }
69  inline int getDefaultPrediction(void) const { return def_predict; }
70 };
71 
72 extern p::feature BHT_FEATURE;
74 
75 } } // otawa::hard
76 
77 #endif // OTAWA_HARD_BHT_H
Definition: PureCache.h:19
int getIndirectPenalty(void) const
Definition: BHT.h:67
int indirect_penalty
Definition: BHT.h:44
int getCondPenalty(void) const
Definition: BHT.h:66
virtual ~BHT(void)
Definition: BHT.h:57
Identifier< BHT * > BHT_CONFIG
Gives the current BHT description.
int getDefaultPrediction(void) const
Definition: BHT.h:69
void setCondIndirectPenalty(int time)
Definition: BHT.h:62
void setCondPenalty(int time)
Definition: BHT.h:60
void setIndirectPenalty(int time)
Definition: BHT.h:61
int getCondIndirectPenalty(void) const
Definition: BHT.h:68
int cond_indirect_penalty
Definition: BHT.h:45
This class contains all information about the Branch History Predictor, that is,. ...
Definition: BHT.h:41
int def_predict
Definition: BHT.h:46
int cond_penalty
Definition: BHT.h:43
SERIALIZABLE(BHT, ELM_BASE(PureCache)&DFIELD(cond_penalty, 10)&DFIELD(indirect_penalty, 10)&DFIELD(cond_indirect_penalty, 10)&)
p::feature BHT_FEATURE
This feature ensures that the BHT description has been loaded.
This class represents identifier with a typed associated value.
Definition: Identifier.h:51
void setDefaultPrediction(int def)
Definition: BHT.h:63
t::int64 time
Definition: base.h:47
BHT(void)
Definition: BHT.h:56
Shortcut to create a feature with a maker (without the mess of SilentFeature).
Definition: AbstractFeature.h:51