1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics_NullSemantics_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics_NullSemantics_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #include <Rose/BinaryAnalysis/BasicTypes.h>
7 #include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics.h>
10 namespace BinaryAnalysis {
11 namespace InstructionSemantics {
18 namespace NullSemantics {
55 static SValuePtr
instance(
size_t nbits, uint64_t ) {
60 static SValuePtr
instance(
const SValuePtr &other) {
80 SValuePtr retval(
new SValue(*
this));
81 if (new_width!=0 && new_width!=retval->nBits())
82 retval->set_width(new_width);
96 ASSERT_not_null(retval);
108 stream <<
"VOID[" <<
nBits() <<
"]";
127 ASSERT_not_reachable(
"not a number");
139 return this == getRawPointer(other);
177 return instance(protoval, regdict);
185 RegisterStatePtr retval = boost::dynamic_pointer_cast<
RegisterState>(from);
186 ASSERT_not_null(retval);
195 virtual void zero()
override {}
245 return MemoryStatePtr(
new MemoryState(addrProtoval, valProtoval));
251 return instance(addrProtoval, valProtoval);
260 MemoryStatePtr retval = boost::dynamic_pointer_cast<
MemoryState>(x);
367 size_t begin_bit,
size_t end_bit)
override;
Base classes for instruction semantics.
virtual void updateReadProperties(RegisterDescriptor) override
Update register properties after reading a register.
static RiscOperatorsPtr instanceFromRegisters(const RegisterDictionaryPtr ®dict)
Instantiate a new RiscOperators object and configures it to use semantic values and states that are d...
virtual BaseSemantics::SValuePtr shiftLeft(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Returns arg shifted left.
virtual BaseSemantics::SValuePtr equalToZero(const BaseSemantics::SValuePtr &a_) override
Determines whether a value is equal to zero.
RegisterStatePtr Ptr
Shared-ownership pointer.
virtual void hash(Combinatorics::Hasher &, BaseSemantics::RiscOperators *) const override
Hash the register state.
virtual uint64_t get_number() const override
Virtual API.
size_t nBits() const
Property: Size in bits.
virtual bool is_number() const override
Virtual API.
virtual BaseSemantics::SValuePtr or_(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Computes bit-wise OR of two values.
SValuePtr protoval() const
Return the protoval.
virtual BaseSemantics::SValuePtr addWithCarries(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_, const BaseSemantics::SValuePtr &c_, BaseSemantics::SValuePtr &carry_out) override
Add two values of equal size and a carry bit.
static RiscOperatorsPtr instanceFromState(const BaseSemantics::StatePtr &, const SmtSolverPtr &solver=SmtSolverPtr())
Constructor.
virtual BaseSemantics::SValuePtr unsignedModulo(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Calculates modulo with unsigned values.
virtual void clear() override
Removes stored values from the register state.
virtual BaseSemantics::SValuePtr leastSignificantSetBit(const BaseSemantics::SValuePtr &a_) override
Returns position of least significant set bit; zero when no bits are set.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
virtual BaseSemantics::SValuePtr number_(size_t nBits, uint64_t number) const override
Create a new concrete semantic value.
void insert(const std::string &x)
Insert data into the digest.
virtual bool merge(const BaseSemantics::RegisterStatePtr &, BaseSemantics::RiscOperators *) override
Merge register states for data flow analysis.
RegisterDictionaryPtr regdict
Registers that are able to be stored by this state.
RiscOperatorsPtr Ptr
Shared-ownership pointer.
virtual BaseSemantics::RegisterStatePtr create(const BaseSemantics::SValuePtr &protoval, const RegisterDictionaryPtr ®dict) const override
Virtual constructor.
Holds a value or nothing.
virtual BaseSemantics::MemoryStatePtr create(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval) const override
Virtual allocating constructor.
static SValuePtr instance(size_t nbits, uint64_t)
Instantiate a new concrete value.
virtual BaseSemantics::SValuePtr readMemory(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *, BaseSemantics::RiscOperators *) override
Read a value from memory.
boost::shared_ptr< RegisterState > RegisterStatePtr
Shared-ownership pointer to a register state.
virtual void clear() override
Clear memory.
virtual BaseSemantics::SValuePtr concat(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Concatenates the bits of two values.
virtual BaseSemantics::SValuePtr negate(const BaseSemantics::SValuePtr &a_) override
Two's complement.
Main namespace for the ROSE library.
virtual BaseSemantics::SValuePtr signExtend(const BaseSemantics::SValuePtr &a_, size_t new_width) override
Sign extends a value.
virtual BaseSemantics::SValuePtr signedDivide(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Divides two signed values.
boost::shared_ptr< class RiscOperators > RiscOperatorsPtr
Shared-ownership pointer.
static SValuePtr instance(size_t nbits)
Instantiate a new undefined value.
virtual BaseSemantics::SValuePtr mostSignificantSetBit(const BaseSemantics::SValuePtr &a_) override
Returns position of most significant set bit; zero when no bits are set.
virtual bool must_equal(const BaseSemantics::SValuePtr &other, const SmtSolverPtr &=SmtSolverPtr()) const override
Virtual API.
Reference-counting intrusive smart pointer.
boost::shared_ptr< State > StatePtr
Shared-ownership pointer to a semantic state.
boost::shared_ptr< class MemoryState > MemoryStatePtr
Shared-ownership pointer.
virtual Sawyer::Optional< BaseSemantics::SValuePtr > createOptionalMerge(const BaseSemantics::SValuePtr &, const BaseSemantics::MergerPtr &, const SmtSolverPtr &) const override
Possibly create a new value by merging two existing values.
virtual BaseSemantics::SValuePtr copy(size_t new_width=0) const override
Create a new value from an existing value, changing the width if new_width is non-zero.
virtual BaseSemantics::SValuePtr undefined_(size_t nBits) const override
Create a new undefined semantic value.
virtual BaseSemantics::SValuePtr signedModulo(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Calculates modulo with signed values.
virtual BaseSemantics::SValuePtr extract(const BaseSemantics::SValuePtr &a_, size_t begin_bit, size_t end_bit) override
Extracts bits from a value.
boost::shared_ptr< class RegisterState > RegisterStatePtr
Shared-ownership pointer.
virtual bool may_equal(const BaseSemantics::SValuePtr &, const SmtSolverPtr &=SmtSolverPtr()) const override
Virtual API.
static SValuePtr promote(const BaseSemantics::SValuePtr &v)
Promote a base value to a NullSemantics value.
virtual void zero() override
Set all registers to the zero.
virtual BaseSemantics::SValuePtr shiftRightArithmetic(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Returns arg shifted right arithmetically (with sign bit).
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
virtual BaseSemantics::SValuePtr peekRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &, BaseSemantics::RiscOperators *) override
Read a register without side effects.
virtual BaseSemantics::SValuePtr unspecified_(size_t nBits) const override
Create a new unspecified semantic value.
IteStatus
Status for iteWithStatus operation.
virtual BaseSemantics::MemoryStatePtr clone() const override
Virtual allocating copy constructor.
virtual BaseSemantics::RegisterStatePtr clone() const override
Make a copy of this register state.
Describes (part of) a physical CPU register.
virtual void print(std::ostream &, BaseSemantics::Formatter &) const override
Print a memory state to more than one line of output.
virtual void updateWriteProperties(RegisterDescriptor, BaseSemantics::InputOutputProperty) override
Update register properties after writing to a register.
NullSemantics operators always return a new undefined value.
virtual BaseSemantics::SValuePtr unsignedMultiply(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Multiply two unsigned values.
virtual BaseSemantics::SValuePtr peekMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt) override
Read memory without side effects.
virtual BaseSemantics::SValuePtr add(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Adds two integers of equal size.
virtual BaseSemantics::SValuePtr xor_(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Computes bit-wise XOR of two values.
virtual BaseSemantics::SValuePtr invert(const BaseSemantics::SValuePtr &a_) override
One's complement.
The set of all registers and their values.
SharedPointer< U > dynamicCast() const
Dynamic cast.
static SValuePtr instance()
Instantiate a new prototypical values.
Base class for semantic values.
virtual BaseSemantics::SValuePtr peekMemory(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &dflt, BaseSemantics::RiscOperators *, BaseSemantics::RiscOperators *) override
Read a value from memory without side effects.
virtual void writeMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &data, const BaseSemantics::SValuePtr &cond) override
Writes a value to memory.
virtual bool isBottom() const override
Determines whether a value is a data-flow bottom.
Values in the NullSemantics domain.
static RiscOperatorsPtr instanceFromProtoval(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver=SmtSolverPtr())
Static allocating constructor.
virtual BaseSemantics::SValuePtr rotateRight(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Rotate bits to the right.
Sawyer::SharedPointer< class SValue > SValuePtr
Shared-ownership pointer.
virtual BaseSemantics::SValuePtr iteWithStatus(const BaseSemantics::SValuePtr &sel_, const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_, IteStatus &) override
If-then-else with status.
virtual SmtSolverPtr solver() const
Property: Satisfiability module theory (SMT) solver.
virtual BaseSemantics::SValuePtr bottom_(size_t nBits) const override
Data-flow bottom value.
virtual void writeRegister(RegisterDescriptor, const BaseSemantics::SValuePtr &, BaseSemantics::RiscOperators *) override
Write a value to a register.
std::shared_ptr< SmtSolver > SmtSolverPtr
Reference counting pointer.
virtual void hash(Combinatorics::Hasher &, BaseSemantics::RiscOperators *, BaseSemantics::RiscOperators *) const override
Calculate a hash for this memory state.
MemoryStatePtr Ptr
Shared-ownership pointer.
virtual BaseSemantics::SValuePtr and_(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Computes bit-wise AND of two values.
virtual bool merge(const BaseSemantics::MemoryStatePtr &, BaseSemantics::RiscOperators *, BaseSemantics::RiscOperators *) override
Merge memory states for data flow analysis.
virtual void hash(Combinatorics::Hasher &hasher) const override
Hash this semantic value.
virtual SValuePtr protoval() const
Property: Prototypical semantic value.
Base class for most instruction semantics RISC operators.
virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver=SmtSolverPtr()) const override
Virtual allocating constructor.
virtual BaseSemantics::SValuePtr readRegister(RegisterDescriptor reg, const BaseSemantics::SValuePtr &, BaseSemantics::RiscOperators *) override
Read a value from a register.
virtual void writeMemory(const BaseSemantics::SValuePtr &, const BaseSemantics::SValuePtr &, BaseSemantics::RiscOperators *, BaseSemantics::RiscOperators *) override
Write a value to memory.
virtual void print(std::ostream &stream, BaseSemantics::Formatter &) const override
Print a value to a stream using default format.
static SValuePtr instance(const SValuePtr &other)
Instantiate a new copy of an existing value.
virtual BaseSemantics::SValuePtr rotateLeft(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Rotate bits to the left.
Base class for semantics machine states.
InputOutputProperty
Boolean properties related to I/O.
virtual BaseSemantics::SValuePtr unsignedDivide(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Divides two unsigned values.
virtual void print(std::ostream &, BaseSemantics::Formatter &) const override
Print the register contents.
virtual BaseSemantics::SValuePtr readMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt, const BaseSemantics::SValuePtr &cond) override
Reads a value from memory.
virtual BaseSemantics::SValuePtr signedMultiply(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) override
Multiplies two signed values.
Represents all memory in the state.
virtual BaseSemantics::SValuePtr shiftRight(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &sa_) override
Returns arg shifted right logically (no sign bit).
size_t nBits() const
Property: value width.