ilasynth  1.0
ILASynth: Template-based ILA Synthesis Engine
memvalues.hpp
Go to the documentation of this file.
1 #ifndef __MEMVALUES_HPP_DEFINED__
2 #define __MEMVALUES_HPP_DEFINED__
3 
4 #include <iostream>
5 #include <map>
6 
7 #include <ilasynth/ast/node.hpp>
8 #include <ilasynth/common.hpp>
9 #include <ilasynth/type.hpp>
10 
11 #include <boost/python.hpp>
12 #include <z3++.h>
13 
14 namespace ilasynth {
15 class Z3ExprAdapter;
16 class MemVar;
17 
18 // This structure represents a memory with known values.
19 // It is passed into python during synthesis.
20 struct MemValues {
21  typedef std::map<mp_int_t, mp_int_t> map_t;
22 
23  static z3::context c_eq;
24  static z3::solver S_eq;
25 
28 
31 
32  // default.
33  MemValues();
34  // constructor.
35  MemValues(int addrWidth, int dataWidth, const py::object& def_val);
36  // constructor from imported memvalue.
37  MemValues(int addrWidth, int dataWidth, const map_t values,
38  const mp_int_t def_value);
39  // construct from a model.
40  MemValues(Z3ExprAdapter& c, const z3::model& m, const MemVar* mem);
41  // copy constructor.
42  MemValues(const MemValues& that);
43  // destructor.
44  ~MemValues();
45 
46  // assignment operator.
47  MemValues& operator=(const MemValues& that);
48 
49  // return def_value
50  py::object getDefault() const;
51  // set def_value.
52  void setDefault(const py::object& dv);
53  // get nondefault values.
54  py::object getValues() const;
55  // __getitem__
56  py::object getItem(const py::object& index) const;
57  // __setitem__
58  void setItem(const py::object& index, const py::object& value);
59 
60  // equality for python.
61  bool eq(const MemValues& mv) const { return *this == mv; }
62  // equality.
63  bool operator==(const MemValues& mv) const;
64  // equality using smt.
65  bool semanticEqual(const MemValues& mv) const;
66  // convert to z3.
67  z3::expr toZ3(z3::context& c) const;
68  // write to a string.
69  std::string str() const;
70  // gc: remove entries which are equal to the default.
71  void gc();
72 
73  // support for __getitem__
74  mp_int_t getItemInt(const mp_int_t& index) const;
75 };
76 std::ostream& operator<<(std::ostream& out, const MemValues& mv);
77 } // namespace ilasynth
78 
79 #endif
static z3::solver S_eq
Definition: memvalues.hpp:24
map_t values
Definition: memvalues.hpp:30
mp_int_t getItemInt(const mp_int_t &index) const
py::object getValues() const
void setDefault(const py::object &dv)
py::object getDefault() const
bool eq(const MemValues &mv) const
Definition: memvalues.hpp:61
Definition: type.hpp:11
bool semanticEqual(const MemValues &mv) const
boost::multiprecision::cpp_int mp_int_t
Definition: common.hpp:9
MemValues & operator=(const MemValues &that)
void setItem(const py::object &index, const py::object &value)
NodeType type
Definition: memvalues.hpp:26
Definition: memvalues.hpp:20
Definition: smt.hpp:14
Definition: abstraction.hpp:21
Definition: mem.hpp:30
std::string str() const
py::object getItem(const py::object &index) const
z3::expr toZ3(z3::context &c) const
bool operator==(const MemValues &mv) const
mp_int_t def_value
Definition: memvalues.hpp:29
std::ostream & operator<<(std::ostream &out, const Node &that)
static z3::context c_eq
Definition: memvalues.hpp:23
std::map< mp_int_t, mp_int_t > map_t
Definition: memvalues.hpp:21
mp_int_t MAX_ADDR
Definition: memvalues.hpp:27