Otawa  0.10
ACSBuilder.h
Go to the documentation of this file.
1 /*
2  * dcache::ACSBuilder class interface
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2009, 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 
22 #ifndef OTAWA_DCACHE_ACSBUILDER_H_
23 #define OTAWA_DCACHE_ACSBUILDER_H_
24 
25 #include "features.h"
26 #include <otawa/util/HalfAbsInt.h>
27 
28 namespace otawa {
29 
30 using namespace elm;
31 
32 namespace dcache {
33 
34 // Cache analysis
35 class MUSTProblem {
36 public:
37  class Domain: public ACS {
38  public:
39  inline Domain(const int _size, const int _A): ACS(_size, _A, 0) { }
40  inline Domain(const Domain &source): ACS(source) { }
41  inline Domain(const ACS& source): ACS(source) { }
42  inline Domain& operator=(const ACS& d) { ACS::operator=(d); return *this; }
43 
44  /*inline void glb(const Domain &dom) {
45  ASSERT((A == dom.A) && (size == dom.size));
46  for (int i = 0; i < size; i++)
47  if (((age[i] > dom.age[i]) && (dom.age[i] != -1)) || (age[i] == -1))
48  age[i] = dom.age[i];
49  }*/
50 
51  /*inline void lub(const Domain &dom) {
52  ASSERT((A == dom.A) && (size == dom.size));
53  for (int i = 0; i < size; i++)
54  if (((age[i] < dom.age[i]) && (age[i] != -1))|| (dom.age[i] == -1))
55  age[i] = dom.age[i];
56  }*/
57 
58  inline void addDamage(const int id, const int damage) {
59  ASSERT((id >= 0) && (id < size));
60  if (age[id] == -1)
61  return;
62  age[id] += damage;
63  if (age[id] >= A)
64  age[id] = -1;
65  }
66 
67  inline void inject(const int id) {
68  if (contains(id))
69  for (int i = 0; i < size; i++) {
70  if ((age[i] < age[id]) && (age[i] != -1))
71  age[i]++;
72  }
73  else
74  for (int i = 0; i < size; i++) {
75  if (age[i] != -1)
76  age[i]++;
77  if (age[i] == A)
78  age[i] = -1;
79  }
80  age[id] = 0;
81  }
82 
83  inline void ageAll(void) {
84  for (int i = 0; i < size; i++) {
85  if (age[i] != -1)
86  age[i]++;
87  if (age[i] == A)
88  age[i] = -1;
89  }
90  }
91 
92  };
93 
95 
96  MUSTProblem(int _size, int _set, WorkSpace *_fw, const hard::Cache *_cache, int _A);
97 
98  const Domain& bottom(void) const;
99  const Domain& entry(void) const;
100  inline void lub(Domain &a, const Domain &b) const {
101  for (int i = 0; i < size; i++)
102  if (((a[i] < b[i]) && (a[i] != -1))|| (b[i] == -1))
103  a[i] = b[i];
104  }
105  inline void assign(Domain &a, const Domain &b) const { a = b; }
106  inline void assign(Domain &a, const ACS &b) const { a = b; }
107  inline bool equals(const Domain &a, const Domain &b) const { return (a.equals(b)); }
108  void update(Domain& out, const Domain& in, BasicBlock* bb);
109  void update(Domain& s, const BlockAccess& access);
110  void purge(Domain& out, const BlockAccess& acc);
111  inline void enterContext(Domain &dom, BasicBlock *header, util::hai_context_t ctx) { }
112  inline void leaveContext(Domain &dom, BasicBlock *header, util::hai_context_t ctx) { }
113 
114 private:
116  int set;
120  int size;
121 };
122 
124 
125 
126 // ACSBuilder processor
127 class ACSBuilder : public otawa::Processor {
128 public:
129  static p::declare reg;
130  ACSBuilder(p::declare& r = reg);
131  virtual void processWorkSpace(otawa::WorkSpace*);
132  virtual void configure(const PropList &props);
133 
134 private:
135  void processLBlockSet(otawa::WorkSpace*, const BlockCollection& coll, const hard::Cache *);
137  bool unrolling;
139 };
140 
141 } } // otawa::dcache
142 
143 #endif /* OTAWA_DCACHE_ACSBUILDER_H_ */
dtd::RefAttr< BasicBlock * > source("source", dtd::STRICT|dtd::REQUIRED)
A block access represents a data memory access of an instruction.
Definition: features.h:125
int set
Definition: ACSBuilder.h:116
bool equals(const ACS &dom) const
Test if two ACS are equals.
Definition: features.h:61
This builder performs analysis of the L1 data cache and produces ACS for MUST and, according to the configuration proerties, persistence.
Definition: ACSBuilder.h:127
Domain(const int _size, const int _A)
Definition: ACSBuilder.h:39
void assign(Domain &a, const Domain &b) const
Definition: ACSBuilder.h:105
Definition: ACSBuilder.h:37
Class to declare simple a processor.
Definition: Registration.h:213
Domain callstate
Definition: ACSBuilder.h:94
void addDamage(const int id, const int damage)
Definition: ACSBuilder.h:58
sys::SystemInStream & in
dtd::Element bb(dtd::make("bb", _BB).attr(id).attr(address).attr(size))
elm::io::Output & operator<<(elm::io::Output &out, Address addr)
Definition: base.cpp:188
Domain(const ACS &source)
Definition: ACSBuilder.h:41
uint32 size
Domain bot
Definition: ACSBuilder.h:118
The processor class is implemented by all code processor.
Definition: Processor.h:49
Domain ent
Definition: ACSBuilder.h:119
void leaveContext(Domain &dom, BasicBlock *header, util::hai_context_t ctx)
Definition: ACSBuilder.h:112
genstruct::Vector< ACS * > * must_entry
Definition: ACSBuilder.h:138
dtd::Element entry(dtd::make("entry", _ENTRY).attr(id))
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
const hard::Cache * cache
Definition: ACSBuilder.h:117
This class contains the configuration of a level of cache of processor.
Definition: Cache.h:34
bool equals(const Domain &a, const Domain &b) const
Definition: ACSBuilder.h:107
Domain & operator=(const ACS &d)
Definition: ACSBuilder.h:42
bool unrolling
Definition: ACSBuilder.h:137
void ageAll(void)
Definition: ACSBuilder.h:83
sys::SystemOutStream & out
void enterContext(Domain &dom, BasicBlock *header, util::hai_context_t ctx)
Definition: ACSBuilder.h:111
hai_context_t
Definition: HalfAbsInt.h:50
void lub(Domain &a, const Domain &b) const
Definition: ACSBuilder.h:100
This is the minimal definition of a basic block.
Definition: BasicBlock.h:43
static p::declare reg
Definition: ACSBuilder.h:129
data_fmlevel_t level
Definition: ACSBuilder.h:136
This a list of properties.
Definition: PropList.h:63
The MUST problem provides the abstract interpretation of L1 data cache for the MUST case...
Definition: ACSBuilder.h:35
Domain(const Domain &source)
Definition: ACSBuilder.h:40
Representation of an Abstract Cache State where each data cache block is represented by its age...
Definition: features.h:47
data_fmlevel_t
Definition: features.h:38
void inject(const int id)
Definition: ACSBuilder.h:67
int size
Definition: ACSBuilder.h:120
A block collections stores the list of data blocks used in a task for a specific line.
Definition: features.h:108
void assign(Domain &a, const ACS &b) const
Definition: ACSBuilder.h:106
WorkSpace * fw
Definition: ACSBuilder.h:115