ROSE 0.11.145.147
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
14namespace Rose {
15namespace BinaryAnalysis {
16namespace InstructionSemantics {
17namespace BaseSemantics {
18
20typedef boost::shared_ptr<class MemoryCellState> MemoryCellStatePtr;
21
26public:
29
32
33protected:
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
38private:
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
49protected:
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
58public:
59 ~MemoryCellState();
60
61public:
65 MemoryCellStatePtr retval = boost::dynamic_pointer_cast<MemoryCellState>(m);
66 ASSERT_not_null(retval);
67 return retval;
68 }
69
70public:
71 virtual void clear() override;
72
73public:
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
119
125
129 virtual void traverse(MemoryCell::Visitor&) = 0;
130
136 virtual void updateReadProperties(const CellList&);
137
143
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 std::vector< MemoryCellPtr > matchingCells(MemoryCell::Predicate &) const =0
Find all matching cells.
virtual void latestWrittenCell(const MemoryCellPtr &cell)
Property: Cell most recently written.
virtual void updateReadProperties(const CellList &)
Adjust I/O properties after reading memory.
virtual AddressSet getWritersIntersection(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps)=0
Writers for an address.
virtual MemoryCellPtr latestWrittenCell() const
Property: Cell most recently written.
virtual void eraseMatchingCells(MemoryCell::Predicate &)=0
Remove all matching cells.
virtual void eraseLeadingCells(MemoryCell::Predicate &)=0
Remove leading matching cells.
virtual void updateWriteProperties(const CellList &, InputOutputPropertySet)
Adjust I/O properties after writing memory.
virtual std::vector< MemoryCellPtr > leadingCells(MemoryCell::Predicate &) const =0
Find leading matching cells.
static MemoryCellStatePtr promote(const BaseSemantics::MemoryStatePtr &m)
Promote a base memory state pointer to a BaseSemantics::MemoryCellState pointer.
virtual void traverse(MemoryCell::Visitor &)=0
Traverse and modify cells.
virtual AddressSet getWritersUnion(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps)=0
Writers for an address.
Base class for most instruction semantics RISC operators.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
boost::shared_ptr< MemoryCell > MemoryCellPtr
Shared-ownership pointer to a memory cell.
std::list< MemoryCellPtr > CellList
List of memory cells.
Definition MemoryCell.h:276
boost::shared_ptr< class MemoryCellState > MemoryCellStatePtr
Shared-ownership pointer to a cell-based memory state.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
The ROSE library.