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