1#ifndef ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_MemoryCellList_H
2#define ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_MemoryCellList_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
6#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/MemoryCellState.h>
7#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/RiscOperators.h>
9#include <boost/serialization/access.hpp>
10#include <boost/serialization/base_object.hpp>
11#include <boost/serialization/export.hpp>
14namespace BinaryAnalysis {
15namespace InstructionSemantics {
49 bool occlusionsErased_;
53#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
55 friend class boost::serialization::access;
58 void serialize(S &s,
const unsigned ) {
60 s & BOOST_SERIALIZATION_NVP(cells);
61 s & BOOST_SERIALIZATION_NVP(occlusionsErased_);
69 : occlusionsErased_(false) {}
72 : MemoryCellState(protocell), occlusionsErased_(false) {}
75 : MemoryCellState(addrProtoval, valProtoval), occlusionsErased_(false) {}
78 MemoryCellList(
const MemoryCellList &other)
79 : MemoryCellState(other), occlusionsErased_(other.occlusionsErased_) {
80 for (CellList::const_iterator ci=other.cells.begin(); ci!=other.cells.end(); ++ci)
81 cells.push_back((*ci)->clone());
109 return instance(addrProtoval, valProtoval);
128 ASSERT_not_null(retval);
217 template<
class Iterator>
220 ASSERT_not_null(addr);
223 for (; cursor!=cells.end(); ++cursor) {
224 if (tempCell->mayAlias(*cursor, addrOps)) {
225 retval.push_back(*cursor);
226 if (tempCell->mustAlias(*cursor, addrOps))
270#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
Simple list-based memory state.
virtual void clear() override
Clear memory.
virtual const CellList & get_cells() const
Returns the list of all memory cells.
virtual void traverse(MemoryCell::Visitor &) override
Traverse and modify cells.
virtual SValuePtr peekMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps) override
Read a value from memory without side effects.
bool mergeWithAliasing(const MemoryStatePtr &other, RiscOperators *addrOps, RiscOperators *valOps)
Merge two states with aliasing.
virtual std::vector< MemoryCellPtr > matchingCells(MemoryCell::Predicate &) const override
Find all matching cells.
static MemoryCellListPtr instance(const MemoryCellListPtr &other)
Instantiate a new copy of an existing memory state.
virtual CellList & get_cells()
Returns the list of all memory cells.
MemoryCellListPtr Ptr
Shared-ownership pointer.
virtual MemoryStatePtr create(const MemoryCellPtr &protocell) const
Virtual allocating constructor.
void occlusionsErased(bool b)
Property: erase occluded cells.
virtual AddressSet getWritersIntersection(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps) override
Writers for an address.
virtual std::vector< MemoryCellPtr > leadingCells(MemoryCell::Predicate &) const override
Find leading matching cells.
CellList scan(Iterator &cursor, const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps) const
Scan cell list to find matching cells.
virtual void eraseLeadingCells(MemoryCell::Predicate &) override
Remove leading matching cells.
virtual void hash(Combinatorics::Hasher &, RiscOperators *addrOps, RiscOperators *valOps) const override
Calculate a hash for this memory state.
virtual bool isAllPresent(const SValuePtr &address, size_t nBytes, RiscOperators *addrOps, RiscOperators *valOps) const
Predicate to determine whether all bytes are present.
virtual void writeMemory(const SValuePtr &addr, const SValuePtr &value, RiscOperators *addrOps, RiscOperators *valOps) override
Write a value to memory.
static MemoryCellListPtr promote(const BaseSemantics::MemoryStatePtr &m)
Promote a base memory state pointer to a BaseSemantics::MemoryCellList pointer.
virtual SValuePtr readMemory(const SValuePtr &address, const SValuePtr &dflt, RiscOperators *addrOps, RiscOperators *valOps) override
Read a value from memory.
bool occlusionsErased() const
Property: erase occluded cells.
virtual MemoryStatePtr create(const SValuePtr &addrProtoval, const SValuePtr &valProtoval) const override
Virtual allocating constructor.
virtual bool merge(const MemoryStatePtr &other, RiscOperators *addrOps, RiscOperators *valOps) override
Merge memory states for data flow analysis.
virtual AddressSet getWritersUnion(const SValuePtr &addr, size_t nBits, RiscOperators *addrOps, RiscOperators *valOps) override
Writers for an address.
virtual MemoryStatePtr clone() const override
Virtual allocating copy constructor.
static MemoryCellListPtr instance(const SValuePtr &addrProtoval, const SValuePtr &valProtoval)
Instantiate a new prototypical memory state.
static MemoryCellListPtr instance(const MemoryCellPtr &protocell)
Instantiate a new memory state with prototypical memory cell.
virtual void print(std::ostream &, Formatter &) const override
Print a memory state to more than one line of output.
virtual void eraseMatchingCells(MemoryCell::Predicate &) override
Remove all matching cells.
bool mergeNoAliasing(const MemoryStatePtr &other, RiscOperators *addrOps, RiscOperators *valOps)
Merge two states without aliasing.
Predicate for matching cells.
Visitor for traversing a cells.
Base class for most instruction semantics RISC operators.
virtual SValuePtr undefined_(size_t nbits)
Returns a new undefined value.
Base classes for instruction semantics.
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.
boost::shared_ptr< class MemoryCellList > MemoryCellListPtr
Shared-ownership pointer to a list-based memory state.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.