Otawa  0.10
Config.h
Go to the documentation of this file.
1 /*
2  * Config and ConfigSet class interfaces
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_ETIME_CONFIG_H_
22 #define OTAWA_ETIME_CONFIG_H_
23 
24 #include <elm/types.h>
25 
26 namespace otawa { namespace etime {
27 
28 using namespace elm;
29 
30 class Config {
31 public:
32  inline Config(void): b(0) { }
33  inline Config(t::uint32 bits): b(bits) { }
34  inline Config(const Config& conf): b(conf.b) { }
35  inline t::uint32 bits(void) const { return b; }
36  inline void set(int n) { b |= 1 << n; }
37  inline void clear(int n) { b &= ~(1 << n); }
38  inline bool bit(int n) const { return b & (1 << n); }
39  string toString(int n) const;
40 
41 private:
43 };
44 
45 
46 class ConfigSet {
47 public:
48  ConfigSet(void): t(0) { }
49  ConfigSet(ot::time time): t(time) { }
50  ConfigSet(const ConfigSet& set): t(set.t), confs(set.confs) { }
51  inline ot::time time(void) const { return t; }
52  inline int count(void) const { return confs.length(); }
53  inline void add(Config conf) { confs.add(conf); }
54  inline void add(const ConfigSet& set) { t = max(t, set.time()); confs.addAll(set.confs); }
55 
56  inline void push(const ConfigSet& set) { t = max(t, set.time()); confs.addAll(set.confs); }
57  inline void pop(const ConfigSet& set) { for(int i = 0; i < set.confs.length(); i++) confs.pop(); }
58 
59  t::uint32 posConst(void) const;
60  t::uint32 negConst(void) const;
61  t::uint32 unused(t::uint32 neg, t::uint32 pos, int n) const;
62  t::uint32 complex(t::uint32 neg, t::uint32 pos, t::uint32 unused, int n) const;
63  void scan(t::uint32& pos, t::uint32& neg, t::uint32& unus, t::uint32& comp, int n) const;
64  bool isFeasible(int n);
65  void dump(io::Output& out, int n);
66 
67  class Iter: public genstruct::Vector<Config>::Iterator {
68  public:
69  inline Iter(const ConfigSet& set): genstruct::Vector<Config>::Iterator(set.confs) { }
70  };
71 
72 private:
75 };
76 
77 
78 } } // otawa::etime
79 
80 #endif /* OTAWA_ETIME_CONFIG_H_ */
ot::time t
Definition: Config.h:73
Represents a configuration for computing cost of a BB.
Definition: Config.h:30
t::uint32 bits(void) const
Definition: Config.h:35
void add(const ConfigSet &set)
Definition: Config.h:54
void pop(const ConfigSet &set)
Definition: Config.h:57
Config(void)
Definition: Config.h:32
ot::time time(void) const
Definition: Config.h:51
Config(const Config &conf)
Definition: Config.h:34
ConfigSet(const ConfigSet &set)
Definition: Config.h:50
void push(const ConfigSet &set)
Definition: Config.h:56
ConfigSet(ot::time time)
Definition: Config.h:49
bool bit(int n) const
Definition: Config.h:38
t::uint32 b
Definition: Config.h:42
void add(Config conf)
Definition: Config.h:53
ConfigSet(void)
Definition: Config.h:48
sys::SystemOutStream & out
Definition: Config.h:67
Config(t::uint32 bits)
Definition: Config.h:33
t::int64 time
Definition: base.h:47
void clear(int n)
Definition: Config.h:37
void set(int n)
Definition: Config.h:36
Set of configurations with the same or with a maximum of time.
Definition: Config.h:46
genstruct::Vector< Config > confs
Definition: Config.h:74
intn_t max(intn_t a, intn_t b)
Return the max with a signed comparison.
Definition: clp_analysis.cpp:180
int count(void) const
Definition: Config.h:52
inst neg(int d, int a)
Definition: inst.h:168
Iter(const ConfigSet &set)
Definition: Config.h:69
uint32_t uint32