1#ifndef ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_RegisterStateGeneric_H
2#define ROSE_BinaryAnalysis_InstructionSemantics_BaseSemantics_RegisterStateGeneric_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
6#include <Rose/BinaryAnalysis/BasicTypes.h>
7#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/BasicTypes.h>
8#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics/RegisterState.h>
9#include <Rose/Exception.h>
11#include <boost/serialization/access.hpp>
12#include <boost/serialization/base_object.hpp>
13#include <boost/serialization/export.hpp>
14#include <Sawyer/IntervalSetMap.h>
17namespace BinaryAnalysis {
18namespace InstructionSemantics {
57 :
Rose::Exception(
"accessed register is not available in register state") {}
72#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
74 friend class boost::serialization::access;
77 void serialize(S &s,
const unsigned ) {
78 s & BOOST_SERIALIZATION_NVP(majr);
79 s & BOOST_SERIALIZATION_NVP(minr);
88 bool operator<(
const RegStore &other)
const {
89 return majr<other.majr || (majr==other.majr && minr<other.minr);
103#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
105 friend class boost::serialization::access;
108 void serialize(S &s,
const unsigned ) {
109 s & BOOST_SERIALIZATION_NVP(desc);
110 s & BOOST_SERIALIZATION_NVP(value);
167 bool accessModifiesExistingLocations_;
168 bool accessCreatesLocations_;
184#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
186 friend class boost::serialization::access;
189 void serialize(S &s,
const unsigned ) {
191 s & BOOST_SERIALIZATION_NVP(properties_);
192 s & BOOST_SERIALIZATION_NVP(writers_);
193 s & BOOST_SERIALIZATION_NVP(accessModifiesExistingLocations_);
194 s & BOOST_SERIALIZATION_NVP(accessCreatesLocations_);
206 : accessModifiesExistingLocations_(true), accessCreatesLocations_(true) {}
209 : RegisterState(
protoval,
regdict), accessModifiesExistingLocations_(true), accessCreatesLocations_(true) {
213 RegisterStateGeneric(
const RegisterStateGeneric &other)
214 : RegisterState(other), properties_(other.properties_), writers_(other.writers_),
215 accessModifiesExistingLocations_(other.accessModifiesExistingLocations_),
261 ASSERT_not_null(retval);
591 virtual std::vector<RegisterDescriptor>
603 void deep_copy_values();
619 void assertStorageConditions(
const std::string &where,
RegisterDescriptor what)
const;
627#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
Guards whether access is able to create new locations.
Exception when register storage is not present.
Functors for traversing register values in a register state.
Guards whether access can change set of existing locations.
A RegisterState for any architecture.
virtual void updateReadProperties(RegisterDescriptor) override
Update register properties after reading a register.
virtual void zero() override
Set all registers to the zero.
virtual bool insertProperties(RegisterDescriptor, const InputOutputPropertySet &)
Insert Boolean properties.
virtual bool insertWriters(RegisterDescriptor, const AddressSet &writerVas)
Insert writer information.
virtual void accessCreatesLocations(bool b)
Property: Whether access can create new locations.
virtual void print(std::ostream &, Formatter &) const override
Print the register contents.
virtual ExtentMap stored_parts(RegisterDescriptor) const
Returns a description of which bits of a register are stored.
virtual void eraseWriters(RegisterDescriptor)
Erase all writers.
virtual void erase_register(RegisterDescriptor, RiscOperators *)
Cause a register to not be stored.
virtual RegisterStatePtr clone() const override
Make a copy of this register state.
virtual void hash(Combinatorics::Hasher &, RiscOperators *) const override
Hash the register state.
Sawyer::Container::IntervalSetMap< BitRange, AddressSet > BitAddressSet
Virtual addresses per bit.
virtual SValuePtr readRegister(RegisterDescriptor, const SValuePtr &dflt, RiscOperators *) override
Read a value from a register.
virtual void clear() override
Removes stored values from the register state.
virtual void setWriters(RegisterDescriptor, const AddressSet &writers)
Set writer information.
virtual bool is_wholly_stored(RegisterDescriptor) const
Determines if the specified register is wholly stored in the state.
virtual void traverse(Visitor &)
Traverse register/value pairs.
virtual RegPairs overlappingRegisters(RegisterDescriptor) const
Find stored registers overlapping with specified register.
virtual bool hasWritersAny(RegisterDescriptor) const
Whether a register has writers.
virtual void initialize_large()
Initialize all registers of the dictionary.
virtual void eraseWriters()
Erase all writers.
virtual bool is_exactly_stored(RegisterDescriptor) const
Determines if the specified register is stored exactly in the state.
static RegisterStateGenericPtr instance(const SValuePtr &protoval, const RegisterDictionaryPtr ®dict)
Instantiate a new register state.
virtual bool is_partly_stored(RegisterDescriptor) const
Determines if some of the specified register is stored in the state.
Sawyer::Container::Interval< size_t > BitRange
A range of bits indexes.
virtual RegisterStatePtr create(const SValuePtr &protoval, const RegisterDictionaryPtr ®dict) const override
Virtual constructor.
virtual void initialize_small()
Initialize all registers of the dictionary.
virtual void eraseProperties(RegisterDescriptor)
Erase all Boolean properties.
virtual bool hasPropertyAny(RegisterDescriptor, InputOutputProperty) const
Whether a register has the specified property.
static RegisterStateGenericPtr promote(const RegisterStatePtr &from)
Run-time promotion of a base register state pointer to a RegisterStateGeneric pointer.
virtual bool hasWritersAll(RegisterDescriptor) const
Whether a register has writers.
virtual AddressSet getWritersIntersection(RegisterDescriptor) const
Get writer information.
virtual AddressSet getWritersUnion(RegisterDescriptor) const
Get writer information.
virtual void eraseProperties()
Erase all Boolean properties.
Sawyer::Container::Map< RegStore, BitAddressSet > RegisterAddressSet
Virtual addresses for all registers.
Sawyer::Container::Map< RegStore, BitProperties > RegisterProperties
Boolean properties for all registers.
virtual bool merge(const RegisterStatePtr &other, RiscOperators *) override
Merge register states for data flow analysis.
virtual SValuePtr peekRegister(RegisterDescriptor, const SValuePtr &dflt, RiscOperators *) override
Read a register without side effects.
virtual void accessModifiesExistingLocations(bool b)
Property: Whether stored registers are adapted to access patterns.
void initialize_nonoverlapping(const std::vector< RegisterDescriptor > &, bool initialize_to_zero)
Initialize the specified registers of the dictionary.
virtual bool eraseProperties(RegisterDescriptor, const InputOutputPropertySet &)
Erase Boolean properties.
std::vector< RegPair > RegPairs
Vector of register/value pairs.
virtual void eraseWriters(RegisterDescriptor, const AddressSet &writerVas)
Erase specified writers.
virtual void writeRegister(RegisterDescriptor, const SValuePtr &value, RiscOperators *) override
Write a value to a register.
bool accessModifiesExistingLocations() const
Property: Whether stored registers are adapted to access patterns.
bool accessCreatesLocations() const
Property: Whether access can create new locations.
virtual void updateWriteProperties(RegisterDescriptor, InputOutputProperty) override
Update register properties after writing to a register.
RegisterStateGenericPtr Ptr
Shared-ownership pointer.
static RegisterStateGenericPtr instance(const RegisterStateGenericPtr &other)
Instantiate a new copy of an existing register state.
Sawyer::Container::Set< rose_addr_t > AddressSet
Set of virtual addresses.
virtual bool hasPropertyAll(RegisterDescriptor, InputOutputProperty) const
Whether a register has the specified property.
virtual InputOutputPropertySet getPropertiesUnion(RegisterDescriptor) const
Get properties.
virtual std::vector< RegisterDescriptor > findProperties(const InputOutputPropertySet &required, const InputOutputPropertySet &prohibited=InputOutputPropertySet()) const
Get registers having certain properties.
virtual RegPairs get_stored_registers() const
Returns the list of all registers and their values.
Registers registers_
Values for registers that have been accessed.
virtual void setProperties(RegisterDescriptor, const InputOutputPropertySet &)
Assign property set.
virtual InputOutputPropertySet getPropertiesIntersection(RegisterDescriptor) const
Get properties.
Sawyer::Container::Map< RegStore, RegPairs > Registers
Values for all registers.
Sawyer::Container::IntervalSetMap< BitRange, InputOutputPropertySet > BitProperties
Boolean properties per bit.
The set of all registers and their values.
SValuePtr protoval() const
Return the protoval.
RegisterDictionaryPtr regdict
Registers that are able to be stored by this state.
Base class for most instruction semantics RISC operators.
Describes (part of) a physical CPU register.
size_t offset() const
Property: Offset to least-significant bit.
unsigned minorNumber() const
Property: Minor number.
unsigned majorNumber() const
Property: Major number.
size_t nBits() const
Property: Size in bits.
Base class for all ROSE exceptions.
Mapping from integers to sets.
Range of values delimited by endpoints.
static Interval baseSize(size_t lo, size_t size)
Construct an interval from one endpoint and a size.
Container associating values with keys.
Base classes for instruction semantics.
InputOutputProperty
Boolean properties related to I/O.
boost::shared_ptr< class RegisterStateGeneric > RegisterStateGenericPtr
Shared-ownership pointer to generic register states.
Sawyer::SharedPointer< SValue > SValuePtr
Shared-ownership pointer to a semantic value in any domain.
Sawyer::Container::Set< InputOutputProperty > InputOutputPropertySet
Set of Boolean properties.
boost::shared_ptr< RegisterState > RegisterStatePtr
Shared-ownership pointer to a register state.
A register descriptor and its value.