Otawa  0.10
features.h
Go to the documentation of this file.
1 /*
2  * features for CCG plugin
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2014, 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_CCG_FEATURES_H_
22 #define OTAWA_CCG_FEATURES_H_
23 
24 #include <elm/inhstruct/DLList.h>
25 #include <otawa/util/GenGraph.h>
26 #include <otawa/proc/Feature.h>
27 #include <otawa/prog/Inst.h>
28 
29 namespace otawa {
30 
31 class BasicBlock;
32 namespace ilp { class Var; }
33 namespace hard { class Cache; }
34 
35 namespace ccg {
36 
37 class Collection;
38 class Edge;
39 class LBlockSet;
40 class Node;
41 
42 
43 // LBlock class
44 class LBlock: public elm::inhstruct::DLNode, public PropList {
45  friend class LBlockSet;
46 public:
47  LBlock(LBlockSet *set, BasicBlock *bb, Inst *inst, t::uint32 size, int cache_index);
48  inline int index(void) const { return idx; }
49  inline Address address(void) const { return _inst->address(); }
50  inline BasicBlock *bb(void) const { return _bb; }
51  inline ot::size size(void) const { return _size; }
52  //inline bool sameCacheBlock(const LBlock *block) const { return cacheBlock() == block->cacheBlock(); }
53  inline LBlockSet *lblockset(void) const { return lbs; }
54  int countInsts(void);
55  inline int cacheBlock(void) const { return cid - 1; }
56  inline Inst *instruction(void) const { return _inst; }
57 
58  // deprecated
59  inline int number(void) const { return idx; }
60  inline int id(void) { return idx; }
61  inline int cacheblock(void) const { return cid; }
62 
63 private:
64  ~LBlock(void);
69  int idx, cid;
70 };
71 
72 Output& operator<<(Output& out, const LBlock *block);
73 
74 
75 class LBlockSet {
76  friend class CCGDFA;
77 public:
78 
79  // Iterator class
80  class Iterator: public elm::genstruct::Vector<LBlock *>::Iterator {
81  public:
82  inline Iterator(LBlockSet& lbset):
83  elm::genstruct::Vector<LBlock *>::Iterator(lbset.listelbc) { }
84  };
85 
86  // Methods
87  LBlockSet(int row, const hard::Cache *cache);
88  int add(LBlock *node);
89  inline int count(void) { return listelbc.length(); }
90  inline int cacheBlockCount(void) { return listelbc.length(); }
91  inline LBlock *lblock(int i) { return listelbc[i]; }
92  inline int set(void) { return linenumber; }
93  inline const hard::Cache *cache(void) const { return _cache; }
94 
95  // deprecated
96  int line(void) { return linenumber; }
97 
98 private:
103 };
104 
105 
106 // Graph class
107 class Graph: public GenGraph<Node, Edge> {
108 public:
109 
110  // Properties
113 };
114 
115 // Features
119 
120 // CCG feature
121 extern p::feature FEATURE;
122 
123 // constraint feature
126 
127 } } // otawa::ccg
128 
129 #endif /* OTAWA_CCG_FEATURES_H_ */
struct otawa::sem::inst inst
int cid
Definition: features.h:69
Definition: GenGraph.h:38
void set(T *target, int size, const T &v)
Inst * instruction(void) const
Definition: features.h:56
BasicBlock * _bb
Definition: features.h:68
Definition: features.h:80
Inst * _inst
Definition: features.h:66
p::feature COLLECTED_LBLOCKS_FEATURE
This feature ensures that the L-blocks of the current task has been collected.
int index(void) const
Definition: features.h:48
Identifier< genstruct::AllocatedTable< LBlock * > * > BB_LBLOCKS
This property is used for storing the list of L-Blocks of a BasicBlock.
Iterator(LBlockSet &lbset)
Definition: features.h:82
elm::genstruct::Vector< LBlock * > listelbc
Definition: features.h:100
uint32 size
Output & operator<<(Output &out, const LBlock *block)
Definition: ccg_LBlockBuilder.cpp:279
LBlockSet * lblockset(void) const
Definition: features.h:53
ot::size size(void) const
Get the size of the current l-block.
Definition: features.h:51
int add(LBlock *node)
Add a new l-block.
Definition: ccg_LBlockBuilder.cpp:318
Identifier< ilp::Var * > MISS_VAR
Gives the variable counting the number of misses.
int id(void)
Definition: features.h:60
t::uint32 size
Definition: base.h:46
int line(void)
Definition: features.h:96
int idx
Definition: features.h:69
int countInsts(void)
Count the instructions in the l-block.
Definition: ccg_LBlockBuilder.cpp:219
The l-block is an abstraction allowing to split the basic block according to the bound of the cache b...
Definition: features.h:44
int cacheblock(void) const
Definition: features.h:61
This class contains the configuration of a level of cache of processor.
Definition: Cache.h:34
int count(void)
Get a number for a new l-block in the set.
Definition: features.h:89
The representation of an address in OTAWA.
Definition: base.h:54
p::feature CONSTRAINT_FEATURE
This feature ensures that the CCG has been translated in the form of ILP constraints.
LBlockSet * lbs
Definition: features.h:65
virtual address_t address(void) const =0
Get the address of the item .
sys::SystemOutStream & out
LBlockSet(int row, const hard::Cache *cache)
Build a l-block set.
Definition: ccg_LBlockBuilder.cpp:331
static Identifier< Collection * > GRAPHS
This property stores the list of CCG for the current task.
Definition: features.h:112
Identifier< LBlockSet ** > LBLOCKS
This property is used for storing the list of L-Blocks.
const hard::Cache * _cache
Definition: features.h:102
Address address(void) const
Definition: features.h:49
static Identifier< Node * > NODE
This property stores the CCG node matching the L-Block it is hooked to.
Definition: features.h:111
This class represents identifier with a typed associated value.
Definition: Identifier.h:51
This class represents the list of l-blocks of a task for a chosen cache row.
Definition: features.h:75
This is the minimal definition of a basic block.
Definition: BasicBlock.h:43
LBlock(LBlockSet *set, BasicBlock *bb, Inst *inst, t::uint32 size, int cache_index)
Build a new LBlock.
Definition: ccg_LBlockBuilder.cpp:188
int set(void)
Get the set number of the l-blocks in the cache.
Definition: features.h:92
const hard::Cache * cache(void) const
Definition: features.h:93
BasicBlock * bb(void) const
Definition: features.h:50
int cacheBlockCount(void)
Get the internal counter of l-block number (only used internally).
Definition: features.h:90
This class represents assembly instruction of a piece of code.
Definition: Inst.h:62
This a list of properties.
Definition: PropList.h:63
~LBlock(void)
Definition: ccg_LBlockBuilder.cpp:203
p::feature FEATURE
This feature ensures that Cache Conflict Graphs has been built.
friend class CCGDFA
Definition: features.h:76
Definition: features.h:107
int number(void) const
Get the number of the LBlock in its cache row.
Definition: features.h:59
t::uint32 _size
Definition: features.h:67
LBlock * lblock(int i)
Get the l-block with the given index.
Definition: features.h:91
int cblock_count
Definition: features.h:101
int linenumber
Definition: features.h:99
Shortcut to create a feature with a maker (without the mess of SilentFeature).
Definition: AbstractFeature.h:51
uint32_t uint32
int cacheBlock(void) const
Compute the cache block of this L-block.
Definition: features.h:55