ROSE  0.11.145.0
BaseSemantics/MemoryCellState.h
1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_MemoryCellState_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_MemoryCellState_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 
6 #include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/MemoryCell.h>
7 #include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/MemoryState.h>
8 #include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/BasicTypes.h>
9 
10 #include <boost/serialization/access.hpp>
11 #include <boost/serialization/base_object.hpp>
12 #include <boost/serialization/export.hpp>
13 
14 namespace Rose {
15 namespace BinaryAnalysis {
16 namespace InstructionSemantics {
17 namespace BaseSemantics {
18 
20 typedef boost::shared_ptr<class MemoryCellState> MemoryCellStatePtr;
21 
26 public:
28  using Super = MemoryState;
29 
32 
33 protected:
34  MemoryCellPtr protocell; // prototypical memory cell used for its virtual constructors
35  MemoryCellPtr latestWrittenCell_; // the cell whose value was most recently written to, if any
36 
37 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
38 private:
39  friend class boost::serialization::access;
40 
41  template<class S>
42  void serialize(S &s, const unsigned /*version*/) {
43  s & BOOST_SERIALIZATION_BASE_OBJECT_NVP(MemoryState);
44  s & BOOST_SERIALIZATION_NVP(protocell);
45  s & BOOST_SERIALIZATION_NVP(latestWrittenCell_);
46  }
47 #endif
48 
49 protected:
50  MemoryCellState() {} // for serialization
51 
52  explicit MemoryCellState(const MemoryCellPtr &protocell);
53 
54  MemoryCellState(const SValuePtr &addrProtoval, const SValuePtr &valProtoval);
55 
56  MemoryCellState(const MemoryCellState &other);
57 
58 public:
59  ~MemoryCellState();
60 
61 public:
64  static MemoryCellStatePtr promote(const BaseSemantics::MemoryStatePtr &m) {
65  MemoryCellStatePtr retval = boost::dynamic_pointer_cast<MemoryCellState>(m);
66  ASSERT_not_null(retval);
67  return retval;
68  }
69 
70 public:
71  virtual void clear() override;
72 
73 public:
77  virtual MemoryCellPtr latestWrittenCell() const {
78  return latestWrittenCell_;
79  }
80  virtual void latestWrittenCell(const MemoryCellPtr &cell) {
81  latestWrittenCell_ = cell;
82  }
91  virtual AddressSet getWritersUnion(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps,
92  RiscOperators *valOps) = 0;
93 
100  virtual AddressSet getWritersIntersection(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps,
101  RiscOperators *valOps) = 0;
102 
106  virtual std::vector<MemoryCellPtr> matchingCells(MemoryCell::Predicate&) const = 0;
107 
113  virtual std::vector<MemoryCellPtr> leadingCells(MemoryCell::Predicate&) const = 0;
114 
118  virtual void eraseMatchingCells(MemoryCell::Predicate&) = 0;
119 
124  virtual void eraseLeadingCells(MemoryCell::Predicate&) = 0;
125 
129  virtual void traverse(MemoryCell::Visitor&) = 0;
130 
136  virtual void updateReadProperties(const CellList&);
137 
143 
148  }
149 
151  std::vector<MemoryCellPtr> allCells() const {
153  return matchingCells(p);
154  }
155 };
156 
157 } // namespace
158 } // namespace
159 } // namespace
160 } // namespace
161 
162 #ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
164 #endif
165 
166 #endif
167 #endif
virtual void latestWrittenCell(const MemoryCellPtr &cell)
Property: Cell most recently written.
virtual void updateReadProperties(const CellList &)
Adjust I/O properties after reading memory.
virtual void eraseMatchingCells(MemoryCell::Predicate &)=0
Remove all matching cells.
boost::shared_ptr< class MemoryCellState > MemoryCellStatePtr
Shared-ownership pointer to a cell-based memory state.
virtual void eraseLeadingCells(MemoryCell::Predicate &)=0
Remove leading matching cells.
virtual AddressSet getWritersIntersection(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps)=0
Writers for an address.
Main namespace for the ROSE library.
virtual AddressSet getWritersUnion(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps)=0
Writers for an address.
boost::shared_ptr< MemoryCell > MemoryCellPtr
Shared-ownership pointer to a memory cell.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
virtual void updateWriteProperties(const CellList &, InputOutputPropertySet)
Adjust I/O properties after writing memory.
static MemoryCellStatePtr promote(const BaseSemantics::MemoryStatePtr &m)
Promote a base memory state pointer to a BaseSemantics::MemoryCellState pointer.
std::list< MemoryCellPtr > CellList
List of memory cells.
Definition: MemoryCell.h:274
virtual MemoryCellPtr latestWrittenCell() const
Property: Cell most recently written.
virtual std::vector< MemoryCellPtr > matchingCells(MemoryCell::Predicate &) const =0
Find all matching cells.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
Base class for most instruction semantics RISC operators.
Definition: RiscOperators.h:49
virtual std::vector< MemoryCellPtr > leadingCells(MemoryCell::Predicate &) const =0
Find leading matching cells.
virtual void traverse(MemoryCell::Visitor &)=0
Traverse and modify cells.