1 #ifndef Rose_ConcreteSemantics2_H
2 #define Rose_ConcreteSemantics2_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #ifndef __STDC_FORMAT_MACROS
7 #define __STDC_FORMAT_MACROS
11 #include "integerOps.h"
12 #include "BaseSemantics2.h"
13 #include "RegisterStateGeneric.h"
14 #include <Sawyer/BitVector.h>
18 namespace InstructionSemantics2 {
24 namespace ConcreteSemantics {
74 static SValuePtr
instance(
size_t nbits, uint64_t value) {
97 SValuePtr retval(
new SValue(*
this));
98 if (new_width!=0 && new_width!=retval->nBits())
99 retval->set_width(new_width);
112 ASSERT_not_null(retval);
140 virtual
void set_width(
size_t nbits) ROSE_OVERRIDE;
148 virtual uint64_t
get_number() const ROSE_OVERRIDE;
156 virtual const
Sawyer::Container::BitVector&
bits()
const {
return bits_; }
183 rose_addr_t pageSize_;
189 : BaseSemantics::MemoryState(addrProtoval, valProtoval), pageSize_(4096) {
195 : BaseSemantics::MemoryState(other), map_(other.map_), pageSize_(other.pageSize_) {
216 static MemoryStatePtr
instance(
const MemoryStatePtr &other) {
229 return instance(addrProtoval, valProtoval);
247 MemoryStatePtr retval = boost::dynamic_pointer_cast<
MemoryState>(x);
248 ASSERT_not_null(retval);
255 virtual void clear() ROSE_OVERRIDE {
262 virtual void print(std::ostream&, Formatter&) const ROSE_OVERRIDE;
283 bool allowSideEffects);
321 typedef BaseSemantics::State State;
410 RiscOperatorsPtr retval = boost::dynamic_pointer_cast<
RiscOperators>(x);
411 ASSERT_not_null(retval);
419 SValuePtr svalueNumber(
size_t nbits, uint64_t value) {
425 SValuePtr svalueBoolean(
bool b) {
429 SValuePtr svalueZero(
size_t nbits) {
436 virtual void interrupt(
int majr,
int minr) ROSE_OVERRIDE;
445 size_t begin_bit,
size_t end_bit) ROSE_OVERRIDE;
504 virtual
void writeMemory(RegisterDescriptor segreg,
512 const
BaseSemantics::SValuePtr &dflt,
bool allowSideEffects);
518 BaseSemantics::SValuePtr doubleToExpr(
double d, SgAsmFloatType*);
static RegisterStateGenericPtr instance(const SValuePtr &protoval, const RegisterDictionary *regdict)
Instantiate a new register state.
Defines RISC operators for the ConcreteSemantics domain.
boost::shared_ptr< RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to a RISC operators object.
static MemoryStatePtr instance(const MemoryStatePtr &other)
Instantiates a new deep copy of an existing state.
virtual BaseSemantics::SValuePtr copy(size_t new_width=0) const ROSE_OVERRIDE
Create a new value from an existing value, changing the width if new_width is non-zero.
virtual BaseSemantics::SValuePtr addWithCarries(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_, const BaseSemantics::SValuePtr &c_, BaseSemantics::SValuePtr &carry_out) ROSE_OVERRIDE
Used for printing RISC operators with formatting.
virtual void print(std::ostream &, BaseSemantics::Formatter &) const ROSE_OVERRIDE
Print a value to a stream using default format.
boost::shared_ptr< class RiscOperators > RiscOperatorsPtr
Shared-ownership pointer to concrete RISC operations.
boost::shared_ptr< class RegisterStateGeneric > RegisterStateGenericPtr
Shared-ownership pointer to generic register states.
static SValuePtr instance()
Instantiate a new prototypical value.
virtual BaseSemantics::SValuePtr negate(const BaseSemantics::SValuePtr &a_) ROSE_OVERRIDE
Two's complement.
virtual BaseSemantics::SValuePtr signedDivide(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Divides two signed values.
virtual void writeMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &data, const BaseSemantics::SValuePtr &cond) ROSE_OVERRIDE
Writes a value to memory.
static RiscOperatorsPtr instance(const RegisterDictionary *regdict, const SmtSolverPtr &solver=SmtSolverPtr())
Instantiates a new RiscOperators object and configures it to use semantic values and states that are ...
virtual BaseSemantics::SValuePtr fpRoundTowardZero(const BaseSemantics::SValuePtr &a, SgAsmFloatType *) ROSE_OVERRIDE
Round toward zero.
Type of values manipulated by the concrete domain.
boost::shared_ptr< MemoryState > MemoryStatePtr
Shared-ownership pointer to a memory state.
virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver=SmtSolverPtr()) const ROSE_OVERRIDE
Virtual allocating constructor.
boost::shared_ptr< State > StatePtr
Shared-ownership pointer to a semantic state.
static RiscOperatorsPtr promote(const BaseSemantics::RiscOperatorsPtr &x)
Run-time promotion of a base RiscOperators pointer to concrete operators.
Holds a value or nothing.
Buffer< A, T >::Ptr buffer() const
Property: buffer.
virtual const Sawyer::Container::BitVector & bits() const
Returns the bit vector storing the concrete value.
virtual uint64_t get_number() const ROSE_OVERRIDE
Virtual API.
virtual BaseSemantics::SValuePtr unsignedModulo(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Calculates modulo with unsigned values.
bool copyOnWrite() const
Property: Copy on write.
virtual SValuePtr protoval() const
Property: Prototypical semantic value.
virtual BaseSemantics::SValuePtr fpMultiply(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b, SgAsmFloatType *) ROSE_OVERRIDE
Multiply two floating-point values.
virtual bool is_number() const ROSE_OVERRIDE
Virtual API.
Main namespace for the ROSE library.
virtual BaseSemantics::MemoryStatePtr create(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval) const ROSE_OVERRIDE
Virtual constructor.
virtual void interrupt(int majr, int minr) ROSE_OVERRIDE
Invoked for instructions that cause an interrupt.
Reference-counting intrusive smart pointer.
BitVector & fromInteger(const BitRange &range, boost::uint64_t value)
Obtain bits from an integer.
Name space for the entire library.
virtual BaseSemantics::SValuePtr signedModulo(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Calculates modulo with signed values.
virtual BaseSemantics::SValuePtr fpToInteger(const BaseSemantics::SValuePtr &fpValue, SgAsmFloatType *fpType, const BaseSemantics::SValuePtr &dflt) ROSE_OVERRIDE
Construct an integer value from a floating-point value.
virtual BaseSemantics::SValuePtr boolean_(bool value) const ROSE_OVERRIDE
Create a new, Boolean value.
virtual BaseSemantics::SValuePtr unsignedDivide(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Divides two unsigned values.
Base classes for instruction semantics.
Sawyer::SharedPointer< class SValue > SValuePtr
Smart-ownership pointer to a concrete semantic value.
rose_addr_t pageSize() const
Size of each page of memory.
virtual BaseSemantics::SValuePtr number_(size_t nbits, uint64_t value) const ROSE_OVERRIDE
Create a new concrete semantic value.
virtual BaseSemantics::SValuePtr undefined_(size_t nbits) const ROSE_OVERRIDE
Create a new undefined semantic value.
static SValuePtr instance(size_t nbits)
Instantiate a new undefined value of specified width.
boost::shared_ptr< class MemoryState > MemoryStatePtr
Shared-ownership pointer to a concrete memory state.
static RiscOperatorsPtr instance(const BaseSemantics::SValuePtr &protoval, const SmtSolverPtr &solver=SmtSolverPtr())
Instantiates a new RiscOperators object with specified prototypical values.
virtual BaseSemantics::SValuePtr fpFromInteger(const BaseSemantics::SValuePtr &intValue, SgAsmFloatType *) ROSE_OVERRIDE
Construct a floating-point value from an integer value.
virtual void set_width(size_t nbits) ROSE_OVERRIDE
Virtual API.
virtual void hash(Combinatorics::Hasher &) const override
Hash this semantic value.
virtual BaseSemantics::SValuePtr fpAdd(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b, SgAsmFloatType *) ROSE_OVERRIDE
Add two floating-point values.
virtual bool may_equal(const BaseSemantics::SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const ROSE_OVERRIDE
Virtual API.
virtual BaseSemantics::RiscOperatorsPtr create(const BaseSemantics::StatePtr &state, const SmtSolverPtr &solver=SmtSolverPtr()) const ROSE_OVERRIDE
Virtual allocating constructor.
Base class for semantic values.
An efficient mapping from an address space to stored data.
virtual BaseSemantics::SValuePtr unsignedMultiply(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Multiply two unsigned values.
virtual BaseSemantics::SValuePtr unspecified_(size_t nbits) const ROSE_OVERRIDE
Create a new unspecified semantic value.
static SValuePtr promote(const BaseSemantics::SValuePtr &v)
Promote a base value to a SymbolicSemantics value.
virtual BaseSemantics::SValuePtr readMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt, const BaseSemantics::SValuePtr &cond) ROSE_OVERRIDE
Reads a value from memory.
static MemoryStatePtr instance(const BaseSemantics::SValuePtr &addrProtoval, const BaseSemantics::SValuePtr &valProtoval)
Instantiates a new memory state having specified prototypical value.
SharedPointer< U > dynamicCast() const
Dynamic cast.
Base class for most instruction semantics RISC operators.
static RiscOperatorsPtr instance(const BaseSemantics::StatePtr &state, const SmtSolverPtr &solver=SmtSolverPtr())
Instantiates a new RiscOperators object with specified state.
virtual Sawyer::Optional< BaseSemantics::SValuePtr > createOptionalMerge(const BaseSemantics::SValuePtr &other, const BaseSemantics::MergerPtr &, const SmtSolverPtr &) const ROSE_OVERRIDE
Possibly create a new value by merging two existing values.
const MemoryMap::Ptr memoryMap() const
Returns the memory map.
virtual bool must_equal(const BaseSemantics::SValuePtr &other, const SmtSolverPtr &solver=SmtSolverPtr()) const ROSE_OVERRIDE
Virtual API.
virtual BaseSemantics::SValuePtr peekMemory(RegisterDescriptor segreg, const BaseSemantics::SValuePtr &addr, const BaseSemantics::SValuePtr &dflt) ROSE_OVERRIDE
Read memory without side effects.
A RegisterState for any architecture.
static SValuePtr instance(size_t nbits, uint64_t value)
Instantiate a new concrete value.
Defines registers available for a particular architecture.
virtual SmtSolverPtr solver() const
Property: Satisfiability module theory (SMT) solver.
virtual BaseSemantics::SValuePtr bottom_(size_t nbits) const ROSE_OVERRIDE
Data-flow bottom value.
void allocatePage(rose_addr_t va)
Allocate a page of memory.
virtual const std::string & name() const
Property: Name used for debugging.
BaseSemantics::Formatter Formatter
Formatter for symbolic values.
virtual BaseSemantics::SValuePtr signedMultiply(const BaseSemantics::SValuePtr &a_, const BaseSemantics::SValuePtr &b_) ROSE_OVERRIDE
Multiplies two signed values.
boost::shared_ptr< RegisterState > RegisterStatePtr
Shared-ownership pointer to a register state.
virtual BaseSemantics::SValuePtr fpSubtract(const BaseSemantics::SValuePtr &a, const BaseSemantics::SValuePtr &b, SgAsmFloatType *) ROSE_OVERRIDE
Subtract one floating-point value from another.
virtual BaseSemantics::MemoryStatePtr clone() const ROSE_OVERRIDE
Virtual copy constructor.
static MemoryStatePtr promote(const BaseSemantics::MemoryStatePtr &x)
Recasts a base pointer to a concrete memory state.
std::shared_ptr< class SmtSolver > SmtSolverPtr
Reference-counting pointer for SMT solvers.
virtual bool isBottom() const ROSE_OVERRIDE
Determines whether a value is a data-flow bottom.