Otawa  0.10
AccessedAddress.h
Go to the documentation of this file.
1 /*
2  * AccessAddress and AccessesAddresses classes 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
20  * 02110-1301 USA
21  */
22 #ifndef OTAWA_ACCESSEDADDRESS_H_
23 #define OTAWA_ACCESSEDADDRESS_H_
24 
25 #include <otawa/base.h>
26 #include <otawa/prop/Identifier.h>
27 #include <otawa/proc/Feature.h>
28 #include <otawa/proc/BBProcessor.h>
29 #include <otawa/stack/features.h>
30 
31 namespace otawa {
32 
33 class Inst;
34 
35 typedef struct address_stat_t {
36  int all, sprel, abs, total;
38 
40 public:
41  typedef enum {
42  ANY,
43  SP,
45  } kind_t;
46 
47  inline AccessedAddress(Inst *instruction, bool is_store, kind_t kind = ANY)
48  : inst(instruction), store(is_store), knd(kind) { }
49  inline kind_t kind(void) const { return (kind_t )knd; }
50  inline bool isStore(void) const { return store; }
51  inline bool isLoad(void) const { return !store; }
52  inline Inst *instruction(void) const { return inst; }
53 
54  void print(io::Output& out) const;
55 
56 private:
58  unsigned char store;
59  unsigned char knd;
60 };
61 
62 
63 class SPAddress: public AccessedAddress {
64 public:
65  inline SPAddress(Inst *instruction, bool is_store, t::int32 offset)
66  : AccessedAddress(instruction, is_store, SP), off(offset) { }
67  inline t::int32 offset(void) const { return off; }
68 
69 private:
71 };
72 
73 
74 class AbsAddress: public AccessedAddress {
75 public:
76  inline AbsAddress(Inst *instruction, bool is_store, const Address& address)
77  : AccessedAddress(instruction, is_store, ABS), addr(address) { }
78  inline const Address& address(void) const { return addr; }
79 
80 private:
82 };
83 inline io::Output& operator<< (io::Output& out, const AccessedAddress *addr) { addr->print(out); return out; }
84 
85 
86 // AccessedAddresses class
88 public:
90  inline ~AccessedAddresses(void) { clear(); }
91 
92  template <class C>
93  void set(const C& coll) {
94  clear();
95  _size = coll.count();
96  addrs = new AccessedAddress *[_size];
97  int i = 0;
98  for(typename C::Iterator aa(coll); aa; aa++, i++)
99  addrs[i] = aa;
100  }
101 
102  void clear(void) {
103  if(_size) {
104  for(int i = 0; i < _size; i++)
105  delete addrs[i];
106  delete [] addrs;
107  _size = 0;
108  }
109  }
110 
111  inline int size(void) const { return _size; }
112  inline AccessedAddress *get(int index) { ASSERT(index < _size); return addrs[index]; }
113 
114  void print(io::Output& out) const {
115  for(int i = 0; i < _size; i++)
116  addrs[i]->print(out);
117  }
118 
119 private:
120  int _size;
122 };
123 inline io::Output& operator<<(io::Output& out, const AccessedAddresses *aa) { aa->print(out); return out; }
124 inline io::Output& operator<<(io::Output& out, AccessedAddresses *aa) { aa->print(out); return out; }
125 
126 
127 // AccessedAddressFromStack class
129 public:
131 
132  static p::declare reg;
134  virtual void configure(const PropList& props);
135 
136 protected:
137  virtual void setup (WorkSpace *fw);
138  virtual void cleanup (WorkSpace *fw);
139  virtual void processBB (WorkSpace *fw, CFG *cfd, BasicBlock *bb);
140 
141 private:
143  bool display;
144 };
145 
147 
151 
152 } //otawa
153 
154 #endif /* OTAWA_ACCESSEDADDRESS_H_ */
155 
For each basic block, provide the list of performed memory accesses and their addresses.
Definition: AccessedAddress.h:87
This processor is dedicated to the basic block process thru proccessBB() method.
Definition: BBProcessor.h:72
bool isStore(void) const
Test if a store is performed on the accessed address.
Definition: AccessedAddress.h:50
int total
Definition: AccessedAddress.h:36
int _size
Definition: AccessedAddress.h:120
static p::declare reg
Definition: AccessedAddress.h:132
p::feature ADDRESS_ANALYSIS_FEATURE
This feature ensures that accessed memory information (class AccessedAddress) is provided for each ba...
kind_t
Describe the different implementation of an accessed address.
Definition: AccessedAddress.h:41
Subclass of AccessedAddress, this class represents address with a constant offset relative to the sta...
Definition: AccessedAddress.h:63
virtual void configure(const PropList &props)
Configure the current processor.
virtual void processBB(WorkSpace *fw, CFG *cfd, BasicBlock *bb)
Perform the work of the given basic block.
int32_t int32
Class to declare simple a processor.
Definition: Registration.h:213
AccessedAddresses()
Definition: AccessedAddress.h:89
const Address & address(void) const
Definition: AccessedAddress.h:78
Represents an stack pointer relative address with a constant offset.
Definition: AccessedAddress.h:43
void print(io::Output &out) const
Definition: AccessedAddress.h:114
Parent class of classes representing accesses to memory.
Definition: AccessedAddress.h:39
bool display
Definition: AccessedAddress.h:143
dtd::Element bb(dtd::make("bb", _BB).attr(id).attr(address).attr(size))
AccessedAddress ** addrs
Definition: AccessedAddress.h:121
elm::io::Output & operator<<(elm::io::Output &out, Address addr)
Definition: base.cpp:188
Control Flow Graph representation.
Definition: CFG.h:42
virtual void setup(WorkSpace *fw)
This method is called before an anlysis to let the processor do some initialization.
SPAddress(Inst *instruction, bool is_store, t::int32 offset)
Definition: AccessedAddress.h:65
uint32 offset
int all
Definition: AccessedAddress.h:36
Subclass of AccessedAddress, this class represents an absolute address access, to a global variable o...
Definition: AccessedAddress.h:74
Represents an address defined by its absolute and constant value.
Definition: AccessedAddress.h:44
Definition: AccessedAddress.h:35
Address addr
Definition: AccessedAddress.h:81
A workspace represents a program, its run-time and all information about WCET computation or any othe...
Definition: WorkSpace.h:67
AccessedAddressFromStack(p::declare &r=reg)
The representation of an address in OTAWA.
Definition: base.h:54
address_stat_t * stats
Definition: AccessedAddress.h:142
bool isLoad(void) const
Test if a store is performed on the accessed address.
Definition: AccessedAddress.h:51
Represents the most imprecise memory access: it may potentially concern the full memory address space...
Definition: AccessedAddress.h:42
~AccessedAddresses(void)
Definition: AccessedAddress.h:90
sys::SystemOutStream & out
address_stat_t istats
Definition: AccessedAddress.h:142
AccessedAddress(Inst *instruction, bool is_store, kind_t kind=ANY)
Definition: AccessedAddress.h:47
unsigned char store
Definition: AccessedAddress.h:58
virtual void cleanup(WorkSpace *fw)
This method is called after the end of the processor analysis to let it do some clean up...
This is the minimal definition of a basic block.
Definition: BasicBlock.h:43
void print(io::Output &out) const
Print the given address.
Definition: util_AccessedAddress.cpp:72
int size(void) const
Definition: AccessedAddress.h:111
This class represents assembly instruction of a piece of code.
Definition: Inst.h:62
t::int32 offset(void) const
Definition: AccessedAddress.h:67
AbsAddress(Inst *instruction, bool is_store, const Address &address)
Definition: AccessedAddress.h:76
This a list of properties.
Definition: PropList.h:63
Inst * instruction(void) const
Get the instruction where this memory access applies.
Definition: AccessedAddress.h:52
kind_t kind(void) const
Get the kind of the address.
Definition: AccessedAddress.h:49
void set(const C &coll)
Definition: AccessedAddress.h:93
static Identifier< bool > DISPLAY
Definition: AccessedAddress.h:130
unsigned char knd
Definition: AccessedAddress.h:59
int sprel
Definition: AccessedAddress.h:36
Definition: AccessedAddress.h:128
Identifier< address_stat_t * > ADDRESS_STATS
This property provides statistics about ADDRESS_ANALYSIS_FEATURE.
struct otawa::address_stat_t address_stat_t
int abs
Definition: AccessedAddress.h:36
Shortcut to create a feature with a maker (without the mess of SilentFeature).
Definition: AbstractFeature.h:51
void clear(void)
Definition: AccessedAddress.h:102
t::int32 off
Definition: AccessedAddress.h:70
Inst * inst
Definition: AccessedAddress.h:57
Identifier< AccessedAddresses * > ADDRESSES
Provide the set of accesses to the memory for the current basic block.