Otawa  0.10
CachePenalty.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
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 #ifndef CACHE_PENALTY_H_
24 #define CACHE_PENALTY_H_
25 
26 #include <otawa/prop/Identifier.h>
27 
28 
29 namespace otawa {
30 
31  class CachePenalty {
32  public:
34  private:
36  int _penalty[4];
37  public:
39  _header[0] = NULL;
40  _header[1] = NULL;
41  for (int i=0 ; i<4 ; i++){
42  _penalty[i] = 0;
43  }
44  }
45  inline void setHeader(int index, BasicBlock *bb)
46  { _header[index] = bb;}
47  inline BasicBlock *header(int index){
48  return _header[index];
49  }
50  inline void setPenalty(cache_penalty_type_t type, int value)
51  { _penalty[type] = value; }
53  return _penalty[type];
54  }
56  if (_header[0]){
57  out << "h0=b" << _header[0]->number();
58  if (_header[1])
59  out << " - h1=b" << _header[1]->number();
60  if (!_header[1])
61  out << " - p[MISS]=" << _penalty[MISS];
62  else {
63  out << " - p[MISS_MISS]=" << _penalty[MISS_MISS];
64  out << " - p[HIT_MISS]=" << _penalty[HIT_MISS];
65  out << " - p[x_HIT]=" << _penalty[x_HIT];
66  }
67  }
68  }
69  };
70 
71  extern Identifier<CachePenalty *> ICACHE_PENALTY;
72 
73 
74 }
75 
76 #endif /*CACHE_PENALTY_H_*/
void setPenalty(cache_penalty_type_t type, int value)
Definition: CachePenalty.h:50
Identifier< CachePenalty * > ICACHE_PENALTY
int _penalty[4]
Definition: CachePenalty.h:36
dtd::Element bb(dtd::make("bb", _BB).attr(id).attr(address).attr(size))
void dump(elm::io::Output &out)
Definition: CachePenalty.h:55
Definition: CachePenalty.h:33
int number(void) const
Get the number hooked on this basic block, that is, value of ID_Index property.
Definition: BasicBlock.h:146
sys::SystemOutStream & out
Definition: CachePenalty.h:33
This is the minimal definition of a basic block.
Definition: BasicBlock.h:43
BasicBlock * header(int index)
Definition: CachePenalty.h:47
int penalty(cache_penalty_type_t type)
Definition: CachePenalty.h:52
CachePenalty()
Definition: CachePenalty.h:38
This class can be used to express the penalties due to the instruction cache.
Definition: CachePenalty.h:31
cache_penalty_type_t
Definition: CachePenalty.h:33
void setHeader(int index, BasicBlock *bb)
Definition: CachePenalty.h:45
Definition: CachePenalty.h:33
const Type & type(void)
Definition: type.h:163
BasicBlock * _header[2]
Definition: CachePenalty.h:35
Definition: CachePenalty.h:33